4
1
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.
Was very useful for me to find this so quickly. Fedora network service uses a different approach and it uses environment variables to drive its own dhclient-script. It is possible to say whether to commit routers per-connection via the
DEFROUTE
variable in the connection configuration. – Pavel Šimerda – 2014-10-03T21:43:28.340Thank you, that sent me in the right direction! I guess this wouldn't work if you needed the routes from DHCP (other than the default) - fortunately, I don't – goncalopp – 2014-03-07T13:38:42.370
1Note that the option is
routers
, notstatic-routes
. I'd say in most setupsrouters
sends just a single host -- the default gateway for the managed network. – kostix – 2014-03-07T15:24:35.0871@goncalopp, from the manual page -- section on
static-routes
: "The default route (0.0.0.0) is an illegal destination for a static route. To specify the default route, use the routers option.". (It then goes on to suggest usingclassless-static-routes
instead ofstatic-routes
but this has nothing to do with our case.) – kostix – 2014-03-07T15:27:00.707