IPV6_V6ONLY(2const)
π 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
EADDRINUSEdrama, 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:
- See
IPPROTO_IPV6(2const). - See
setsockopt(2). - See
ipv6(7).
that's where the error lore lives, go read those π«Ά
π HISTORY π
POSIX.1-2001Linux 2.4.21Linux 2.6
so she's been around a minute. vintage. legendary. periodt. β
π¦ SEE ALSO π¦
reminder, bestie:IPV6_V6ONLYonly does its thing at theIPPROTO_IPV6level, and the value you hand it is a pointer to anintβ not theintitself. 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