<div dir="auto"><div>If wg was binding to a particular interface, I don't think it would be possible to support roaming scenarios. I have a travel wifi router, and I love the fact that it will automatically switch between connecting through the Ethernet interface or the USB tethering one.<div dir="auto"><br></div><div dir="auto">The need you describe is orthogonal to the role of wireguard. If you want to tightly control what wireguard is doing, you should use 1) good routing rules and 2) iptables to match these rules.</div><br><br><div class="gmail_quote"><div dir="ltr">On Sat, May 5, 2018, 11:33 Kalin KOZHUHAROV <<a href="mailto:me.kalin@gmail.com">me.kalin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, May 5, 2018 at 10:18 AM, ѽ҉ᶬḳ℠ <<a href="mailto:vtol@gmx.net" target="_blank" rel="noreferrer">vtol@gmx.net</a>> wrote:<br>
> I like to keep things neat/controlled and any necessary open socket is only<br>
> sticking out like a sore (wondering why it is opened when not wanted for).<br>
> It would certainly instill more confidence in network security/control if it<br>
> would be possible to define which sockets are opened by WG, like other apps<br>
> do.<br>
><br>
+1 !<br>
<br>
> Which brings up the next point, I have asked previously twice about -<br>
> wildcard ip 0.0.0.0 . How to bind WG to a particular iface/subnet, as a<br>
> another matter of network security?<br>
><br>
It is not possible AFAIK. I am not sure in the intrinsic workings, may<br>
be it is not possible by design?<br>
<br>
Hmm, should be, given that it only listens to UDP on a single IP<br>
address (as configured on the wgX interface).<br>
Well, one can configure multiple addresses to a single interface, but still<br>
What about when we have more than one wgX interface, do they share memory?<br>
<br>
Certainly, the source lists it is binds to any interface:<br>
<a href="https://git.zx2c4.com/WireGuard/tree/src/socket.c#n330" rel="noreferrer noreferrer" target="_blank">https://git.zx2c4.com/WireGuard/tree/src/socket.c#n330</a><br>
unconditionally.<br>
<br>
So I guess we can use (from `man 7 socket`)<br>
<br>
SO_BINDTODEVICE<br>
Bind this socket to a particular device like “eth0”, as<br>
specified in the passed interface name. If the<br>
name is an empty string or the option length is zero,<br>
the socket device binding is removed. The passed<br>
option is a variable-length null-terminated interface<br>
name string with the maximum size of IFNAMSIZ. If<br>
a socket is bound to an interface, only packets received<br>
from that particular interface are processed by<br>
the socket. Note that this works only for some socket<br>
types, particularly AF_INET sockets. It is not<br>
supported for packet sockets (use normal bind(2) there).<br>
<br>
Before Linux 3.8, this socket option could be set,<br>
but could not retrieved with getsockopt(2). Since<br>
Linux 3.8, it is readable. The optlen argument should<br>
contain the buffer size available to receive the<br>
device name and is recommended to be IFNAMSZ bytes. The<br>
real device name length is reported back in the<br>
optlen argument.<br>
<br>
Just a wild guess.<br>
<br>
Cheers,<br>
Kalin.<br>
_______________________________________________<br>
WireGuard mailing list<br>
<a href="mailto:WireGuard@lists.zx2c4.com" target="_blank" rel="noreferrer">WireGuard@lists.zx2c4.com</a><br>
<a href="https://lists.zx2c4.com/mailman/listinfo/wireguard" rel="noreferrer noreferrer" target="_blank">https://lists.zx2c4.com/mailman/listinfo/wireguard</a><br>
</blockquote></div></div></div>