I have a debian machine with two interfaces, configured by dhcp:
allow-hotplug eth0
iface eth0 inet dhcp
allow-hotplug eth1
iface eth1 inet dhcp
On boot, a default route is added to eth1:
0.0.0.0 10.200.10.253 0.0.0.0 UG 0 0 0 eth1
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.200.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
But I need the default route to be a gateway on eth0 instead. Deleting the default route and running dhclient after boot works:
$ sudo route del default
$ sudo dhclient -v eth0
I know I can put this on rc.local
, but is there a more "clean" way to do it?
I can't use a static address.
Answer
To me, it looks like both DHCP clients spawned -- each for its corresponfing iface -- get the default gateway and race. Things happen this way that the one on eth1
reliably wins (for whatever reason).
The solution does not appear to obvious because it depends on your setup. Getting the default GW using DHCP logically means you do not care about where it is.
Based on this and this, I'd try adding
interface eth1 {
supersede routers ""
}
to /etc/dhcp/dhclient.conf
and see what happens. The idea is to supersede
any routers
supplied by the DHCP server reached via eth1
with nothing.
No comments:
Post a Comment