双默认网关的Ubuntu服务器

我刚刚在EEEBox上安装了Ubuntu 9.10服务器。 这是我的/ 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 

当我重新启动/etc/init.d/networking ,我可以从互联网上访问eth0的IP地址,我可以在我的无线networkingmynet ping机器。 一切工作正常,我有一个默认网关

但一段时间后,如果我再次检查路线,我只find两个默认网关:一个是正确的,是前一个,而另一个是无线networking的一个。

我有一个相当低的信号mynet我的服务器,有时wifi只是断开,然后再次重新连接。 那么我认为这可能是一个问题,并在WiFinetworking的DHCP,当重新连接它也添加一个默认网关。 任何想法如何解决这个问题?

来自: http : //www.linuxhorizo​​n.ro/iproute2.html

你可以尝试这样的事情:

 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 

警告,未经testing。 但是它应该做的是确保接口X上的stream量也离开它。

相信正在发生的事情是,DHCP客户端正在从某个地方产生,并获得第二条默认路由。

而不是回避这第二个默认的路线,并把它从它到来的地狱深处 – 我们如何保持它 – 但只有当你的有线networking消失?

要做到这一点,我们设置了连接的接口指标,所以你的有线以太网优于无线(当它已经启动了)。

将度量看作“成本” – 操作系统将首先使用具有最低度量的networking适配器。

如果没有较低的度量接口,操作系统将只使用这个更高的度量接口。

 # 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 

一些现成的答案:

  • 禁用wifi时,不使用它。

  • 设置您的DHCP服务器,以便它发布具有更高度量的默认路由(如2),以便有线默认路由将永远是首选的,如果插入。