Two DHCP interfaces asigned to two default gateways to OS

Posted by user140600 on Super User See other posts from Super User or by user140600
Published on 2012-06-16T20:46:45Z Indexed on 2012/06/16 21:18 UTC
Read the original article Hit count: 267

Filed under:
|
|
|

I have a Ubuntu box that has two networking interfaces (eth0 and wlan0). They are both configured for DHCP in /etc/network/interfaces, but they both assign a default gateway:

/etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp
wireless-essid test

Result of route -n

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.1.1 0.0.0.0 UG 100 0 0 wlan0
0.0.0.0 10.0.0.1 0.0.0.0 UG 100 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.16.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0

How can I set up /etc/network/interfaces to have only one default gateway, on the interface I want?

Worst case scenario, how can I at least control which one gets on top on the route -n command, each boot?

Note:

  • This box will travel a lot, and will be connected to different networks, so I don´t know in advance the IP addresses/ranges it will have.

  • Sometimes the default gw interface will be eth0. Sometimes it will be wlan0 ... So, this needs to be kind of automatic ...

© Super User or respective owner

Related posts about ubuntu

Related posts about networking