Re: Behavior of SO_BINDTODEVICE

From: Bernd Eckenfels
Date: Wed Nov 12 2008 - 15:46:12 EST


In article <6d71560527183fab0093d18a9a83a3c6.squirrel@xxxxxxxxxxxxxx> you wrote:
> However, do you or anyone else know how to do this if both interfaces are
> connect to the same network (same subnet)?

Well, first of all, the BINDTODEVICE is not intended to regulate the source
of response IP Addresses. It only regulates which Incoming TCP Connections
are accepted. IP Communication still is processed by the IP FIB (Cache).

So if you have 2 Interfaces on the same network, you cant use destination
based routing tables. But if the two interfaces have differen (local) IP
Addresses you can use those to discremninate. This is also why I saied, just
bind to IP Addresses instead of named interfaces.

> Btw, the reason I used named bindings, is that often I want two
> connections to the same server. When I think of it, modifying libcurl and
> binding the IP of the network interface to the socket would probably work,
> but I would rather use an unmodied libcurl (for portability reasons).

Well most Software I know supports binding to ip and not to name, so I am
not sure why it is different with curl.

Note that TCP is smart enough to sent answers out with the IP Address of the
request. It is not smart enough to sent it over the named devices.

Gruss
Bernd
--
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html