Re: Looking for a way to obtain offered gateway(s) from a link's DHCP but not apply them.
Roy Marples
Thu Mar 12 14:51:07 2015
Hi Malcom
On 11/03/2015 23:17, Malcolm Bofors wrote:
> I've been using multi-homed uplink connections at home for many years,
> but up to this point, they've involved statically configured routes that
> are easily managed.
>
> I lost one of those and am trying on "Time Warner Business Cable", for
> better or for worse, but they only seem to offer DHCP. I didn't think
> too much about it until I went to adapt my scripts, which consist of
> some shell scripts string and duct tape to obtain interface information
> and then configuring the kernel routing and packet marking rules
> according via iproute2.
You maybe interested in a recent discussion about multi-homed uplinks
and source address routing, archived here:
http://roy.marples.name/archives/dhcpcd-discuss/2015/0960.html
And the final patch for testing (but as yet no replies!) here:
http://roy.marples.name/archives/dhcpcd-discuss/2015/0982.html
> It worked very well, and allowed me to do some things that seem well out
> of reach of most home users (load balancing to use different uplinks on
> a socket-by-socket basis, auto-failover, binding certain services to use
> a preferred uplink if it's available, etc).
>
> One of the vital bits of information my scripts need is a given link's
> gateway to provide to iproute2's route. When I use DHCP, it seems
> there's no way I can obtain that information when an already-existing
> default gateway is configured outside of dhcpcd.
This is true.
If dhcpcd is instructed to set a gateway, then set a gateway it shall.
However, on Linux at least, each gateway is set to a metric which allows >1.
If you add your own static gateway, dhcpcd should preserve it.
Actually that may not be entirely true in some dhcpcd versions (you
neglected to say which version you are using). Certainly in the fossil
trunk there is improved code for this.
> I've dumped the lease file and enabled DEBUG logging, to no avail. All
> I see is a "dummy" localhost gateway and the assigned host IP#.
>
> Is it possible to obtain the details of the offered gateway from the
> exchange, or do I need to look into a patch to provide this? I'm happy
> to write it, but initial efforts by hammering on nc_route() in ipv4.c
> proved unfruitful. I suspect there's some "editing" of the obtained
> routes in get_routes() in ipv4.c. I'll look into that logic next, but
> it looks a bit messy and that part of the kernel's structures are
> unfamiliar to me, so it's slower-going than usual.
dhcpcd -U4 eth0
should provide the IPv4 dhcp lease.
You want to look for either classless_static_routes= and find the
0.0.0.0/0 entry (router IP after it) or look at the routers=
If classless_static_routes is set, then routers is ignored.
Roy
Archive administrator: postmaster@marples.name