Subject: Re: RFC: local address selection
To: None <itojun@iijlab.net>
From: Tom Ivar Helbekkmo <tih@eunetnorge.no>
List: tech-net
Date: 11/17/2004 08:18:13
Emmanuel Dreyfus wrote:

> route add default 10.0.12.1 -localaddr 10.0.12.7   

itojun wrote:

> in IPv4 code, rt_ifa is used for selecting source address for a
> particular routing entry.  route -ifa should be sufficient.

Actually, that doesn't work.  The -ifa option is there to select, for
a single interface, which of multiple addresses on the same net should
be used as the source address when originating traffic while binding
to INADDR_ANY locally.  Thus, it can only work to give the system a
default originating address for routes that go out the particular
interface that the address is on.  If you try to create, with -ifa, a
route that uses an originating address that resides on another
interface than the gateway is behind, traffic will end up being sent
out on the interface carrying the address, *not* the one where the
gateway can be found.  Thus, an I.J.K.L/32 on a loopback interface can
never be set, using -ifa, as the originating address for a system's
default route -- try it, and you'll see that packets using that route
will spin on the loopback interface until they run out of TTL.

Furthermore, as Miles Nordin wrote:

> Routes don't inherit from encompasing routes like nesting in a
> statically-scoped language---rather, only the most-specific route
> can be consulted.

Could we, perhaps, use sysctl to set a source address to use when
originating traffic while bound to INADDR_ANY -- and have it default
right back to 0.0.0.0, meaning to use what the routing table wants?
I'm presupposing that the point of this particular exercise is to
create a general, system-wide version of the "bindaddress" directive
found in a few applications that originate connections, e.g. ssh.

-tih
-- 
Tom Ivar Helbekkmo, Senior System Administrator, EUnet Norway Hosting
www.eunet.no  T +47-22092958 M +47-93013940 F +47-22092901 FWD 484145