ubuntu 两张网卡时网络设置

auto eth0
iface eth0 inet static
address 114.212.191.22
netmask 255.255.254.0
gateway 114.212.190.1

auto eth1
iface eth1 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1

 上面是原来的网卡设置,每个网卡都设置了gateway,这样设置后重启网卡时会出现如下错误:

rtnetlink answers file exists fail to bring up eth1

去网上搜了一下,发现不能同时设置两个网关会导致路由表中出现两个默认路由,如果你有两个默认路由,在路由表中就会有两个0.0.0.0条目,系统不能处理这种情况,就会出现上面的错误

A gateway is an IP you send ALL traffic to. If you would have two, your routing table would have a double entry for dest 0.0.0.0 and the system can't handle this. The double route is what causes the RTNETLINK answer "File exists", meaning there is already a route for 0.0.0.0.

http://serverfault.com/questions/368349/can-only-bring-up-one-of-two-interfaces

原文地址:https://www.cnblogs.com/feiling/p/2948817.html