IPV6_V6ONLY(2const)

πŸ“¦
version 6.20 Β· 4 versions
, in arch rolling, nixpkgs unstable

πŸ’– IPV6_V6ONLY(2const) πŸ’–

okay bestie, so this one lives in the IPV6_V6ONLY(2const) corner of the manual pages, and it's literally the little socket flag that decides whether your v6 socket is a v6-only girlie or a dual-stack queen. library-wise it's just the standard C library, libc, -lc, nothing extra to install, we love a low-effort icon ✨


🌸 SYNOPSIS 🌸

so you're gonna pull in these headers, right:

#include <netinet/in.h>  /* Definition of IP* constants */
#include <sys/socket.h>

and then you hit setsockopt() like this:

int setsockopt(int sockfd, IPPROTO_IPV6, IPV6_V6ONLY,
               const int *enable, sizeof(int));

that's it. that's the whole call. IPPROTO_IPV6 level, IPV6_V6ONLY option, and a pointer to an int named enable that's sizeof(int) big. slay πŸ’…


✨ DESCRIPTION ✨

okay so here's the tea πŸ“ β€” it all depends on what you put in enable.

  • if this flag is set to true (that means nonzero), your socket is restricted to sending and receiving IPv6 packets only. that's the v6-only era. and the cute part? an IPv4 application and an IPv6 application can bind to a single port at the same time. no fighting, no EADDRINUSE drama, both get their lil port. iconic πŸŽ€
  • if this flag is set to false (zero), then the socket can be used to send and receive packets to and from an IPv6 address or an IPv4-mapped IPv6 address. dual-stack mode. main character energy 🌈

now, what's the default? bestie, it's not vibes-based, it's file-based 😭 β€” the default value for this flag is defined by the contents of the file

/proc/sys/net/ipv6/bindv6only

and the default value for that file is 0 (false). so out of the box, dual-stack. noted. πŸ’œ


πŸ’€ ERRORS πŸ’€

ngl this page doesn't spell them out, it just points you elsewhere:

that's where the error lore lives, go read those 🫢


πŸ‘‘ HISTORY πŸ‘‘

  • POSIX.1-2001
  • Linux 2.4.21
  • Linux 2.6

so she's been around a minute. vintage. legendary. periodt. ⭐


πŸ¦‹ SEE ALSO πŸ¦‹


reminder, bestie: IPV6_V6ONLY only does its thing at the IPPROTO_IPV6 level, and the value you hand it is a pointer to an int β€” not the int itself. don't be out here passing integers raw, iykyk πŸ™ˆ

and that's the whole page, no cap πŸ’– this lil writeup came from Linux man-pages 6.20, dated 2026-06-21 β€” go forth and set your socket options, you absolute IPV6_V6ONLY icon 🌟

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms