Ubuntu – Double default gateway ubuntu server

dhcpgatewayUbuntuubuntu-9.10

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?

Best Answer

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.