https://bugzilla.samba.org/show_bug.cgi?id=2436

--- Comment #4 from roland <[email protected]> ---
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.
-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to