Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've just installed an Ubuntu server 9.10 on an EEEBox. This is my /etc/network/interfaces

# The loopback network interface 
auto lo
iface lo inet loopback

auto wlan0 iface wlan0 inet static 
address 192.168.48.16 
netmask 255.255.248.0 
wireless-essid mynet

auto eth0
iface eth0 inet static
address xx.xx.xx.xx
netmask 255.255.255.224
gateway xx.xx.yy.yy

When I restart /etc/init.d/networking, I can access the eth0 ip address from the internet and I can ping the machines in my wifi network mynet. Everything works fine and I have one default gateway.

But after some time if I check again the route I just find two default gateways: one is correct and is the previous one, but the other is the one of the wifi network.

I have a quite low signal of mynet where my server is and sometimes the wifi just disconnect and then reconnect again. Then I think that this can be a problem and the dhcp of the wifi net, when reconnecting it also add a default gateway. Any idea on how to resolve this issue?

share|improve this question

3 Answers 3

From: http://www.linuxhorizon.ro/iproute2.html

You could try something like this:

echo "1 admin" >> /etc/iproute2/rt_tables
ip route add 192.168.48.16/24 dev wlan0 src 192.168.48.16 table admin
ip route add default via 192.168.48.16 dev wlan0 table admin
ip rule add from xx.xx.xx.xx/32 table admin
ip rule add to xx.xx.xx.xx/32 table admin

ip rule add from 192.168.48.16/32 table admin
ip rule add to xx.xx.xx.xx/32 table admin

warning, untested. But what it should do is to make sure that traffic comming in on interface X also leaves it.

share|improve this answer
    
Thanks, for the moment I have edited dhclient.conf with interface "wlan0" { supersede routers <ip of the eth0 gateway>; } For the moment it works, let see if it will last. E. –  Elena Jan 18 '10 at 16:48

What I believe is happening, is that a DHCP client is being spawned from somewhere - and getting a second default route.

Rather than shunning this second default route and consigning it to the depths of hell from whence it came - how about we keep it - but only if your wired network goes away?

To do this, we set the interface metric of the connections, so your cabled ethernet is preferred over wireless (when it's up).

Think of metric as a 'cost' - the operating system will use the network adapter with the lowest metric first.

The OS will only use this higher metric interface if there are no lower metric interfaces.

# The loopback network interface 
auto lo
iface lo inet loopback

auto wlan0 
iface wlan0 inet static 
address 192.168.48.16 
netmask 255.255.248.0 
wireless-essid mynet
metric 100

auto eth0
iface eth0 inet static
address xx.xx.xx.xx
netmask 255.255.255.224
gateway xx.xx.yy.yy
metric 50
share|improve this answer

Some out of the box answers:

  • Disable wifi when you aren't using it.

  • Set up your DHCP server so that it issues the default route with a higher metric (like 2) so that the wired default route will always be preferred if plugged in.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.