IP_FREEBIND(2const)
π IP_FREEBIND(2const) π
okay bestie so real talk β this is the IP_FREEBIND socket option from the Linux man-pages, section 2const, and it's genuinely one of the most underrated little gremlins in the whole networking toolbox. it lives in the standard C library (libc, -lc). let's get into it π«Ά
β¨ NAME β¨
IP_FREEBIND β bind to a nonlocal or nonexistent IP address
like. the name says it all. you want to bind to an IP that isn't yours? that doesn't exist yet? the vibe check has been passed, queen π
π LIBRARY π
Standard C library (libc, -lc)
she's in libc. no extra dependency required. iconic behaviour, no notes π
π SYNOPSIS π
#include <netinet/in.h> /* Definition of IP* constants */
#include <sys/socket.h>
int setsockopt(int sockfd, IPPROTO_IP, IP_FREEBIND,
const int *enable, sizeof(int));
soooo you're calling setsockopt() with the level IPPROTO_IP and the option name IP_FREEBIND, and you're passing in a pointer to an int (enable) plus sizeof(int) because obviously she needs to know how big your little boolean is. no cap, that's the whole call signature. π¦
πΈ DESCRIPTION πΈ
If enabled, this boolean option allows binding to an IP address that is nonlocal or does not (yet) exist.
the way that this option just lets you do it with your chest π normally the kernel would be like "bestie that IP isn't yours, absolutely not," but flip IP_FREEBIND on and she's like "okay slay, do your thing."
This permits listening on a socket, without requiring the underlying network interface or the specified dynamic IP address to be up at the time that the application is trying to bind to it.
translation from the group chat: you do not need the network interface to already be up, and you do not need that dynamic IP address to already exist when your app hits bind(). your app can show up early, bind anyway, and the interface/address can pull up fashionably late. the main character arrives first. periodt. π
This option is the per-socket equivalent of the /proc/sys/net/ipv4/ip_nonlocal_bind interface.
so if you've ever vibed with the system-wide /proc/sys/net/ipv4/ip_nonlocal_bind knob, this is literally the per-socket version of that exact energy. one socket at a time instead of the whole machine. iykyk. π
π ERRORS π
See IPPROTO_IP(2const). See setsockopt(2). See ip(7).
like, the error situation is not spelled out right here β she's pointing you at the actual sources. go read those three, they're the ones with the receipts. π
β STANDARDS β
Linux.
that's it. that's the whole section. Linux only, bestie. no POSIX, no BSD, just us. π§
π§ HISTORY π§
Linux 2.4.
she's been here since Linux 2.4. an elder icon. a founding mother. respect her name. π
π SEE ALSO π
go read these too because the lore is deep and the universe is interconnected. no crumbs left behind. π
heads up bestie: this is a Linux thing only, and the actual error codes live over inIPPROTO_IP(2const),setsockopt(2), andip(7)β so don't come for this page expecting the full error tea, okay? π€
and that's the whole page, babes β sourced from Linux man-pages 6.20, dated 2025-11-25. mwah, go bind something nonlocal πβ¨π
π¦ 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