samba-bugs at samba.org
2026-Apr-21 14:15 UTC
[Bug 2436] Please support binding to specific interfaces
https://bugzilla.samba.org/show_bug.cgi?id=2436 --- Comment #4 from roland <devzero at web.de> --- to be honest, there aren't many unix daemons coming to my mind which have such feature to bind to specific interface/nic name, it's totally common to specify ip address to bind/listen to. can you provide an example where we can bind tcp based service to specific nic/interface by interface name ? most general purpose daemons (and rsyncd is one) stick to ip-based binding, and the reason for that is portability (which is important for rsync). socat is one of the very few coming to my mind which can do that. and systemd ( via BindToDevice=) and thus you could use rsyncd under control of systemd to get what you want. it won't make sense to implement this. AI tells this for it: Short answer: no, SO_BINDTODEVICE is not portable. SO_BINDTODEVICE is a Linux-specific socket option. It lets you bind a socket to a particular network interface (e.g., "eth0"), but: It is defined in Linux headers (<linux/socket.h> / <net/if.h>), not by POSIX. It works on Linux kernels, but won?t compile or run on most other systems like: -BSD variants (FreeBSD, OpenBSD, NetBSD) -macOS -Windows What to use instead (portable approaches) If you need similar behavior across platforms, you generally have to rethink the approach: - Bind to a specific IP address - Instead of binding to an interface, bind to the IP assigned to that interface using bind(). This is portable and works everywhere. - Use routing configuration - Let the OS routing table decide which interface to use (often the most idiomatic solution). Platform-specific alternatives - On BSD/macOS: IP_BOUND_IF or SO_RECV_IF (different semantics, not a drop-in replacement) - On Windows: IP_UNICAST_IF / IPV6_UNICAST_IF When SO_BINDTODEVICE makes sense It?s useful if: You are writing Linux-only software (e.g., containers, networking tools, VPNs) You need strict interface-level control beyond IP binding Otherwise, relying on it will lock you into Linux. -- You are receiving this mail because: You are the QA Contact for the bug.