Description
reqwest
's ClientBuilder
provides an interface
method that will configure the client to bind all sockets on a particular interface. Currently, this method is only available on Linux/Android, as it uses the Linux-specific socket option SO_BINDTODEVICE
.
On BSD-like systems, including macOS, illumos, etc, similar functionality exists for IP sockets in the form of the IP_BOUND_IF
socket option. Per the manual page ip(4p)
:
IP_BOUND_IF
Limit reception and transmission of packets to this interface. Takes an integer as an argument. The integer is the selected interface index.
It seems like reqwest
could probably provide an implementation of the ClientBuilder::interface
method on BSD-ish systems using this socket option. I'd be happy to contribute such an implementation if maintainers are open to it.