在/etc/network/interfaces 中设置网络
auto eth0iface eth0 inet staticaddress 192.168.50.1gateway 192.168.50.1netmask 255.255.255.0auto eth1iface eth1 inet staticaddress 192.168.100.150gateway 192.168.100.1netmask 255.255.255.0dns-nameservers 114.114.114.114
结果启动之后默认网关为192.168.50.1
$route
显示如下
$default 192.168.50.1 。。。
真正需要的网关是192.168.100.1
将上述代码修改一下即可
auto eth0iface eth0 inet staticaddress 192.168.50.1#gateway 192.168.50.1netmask 255.255.255.0auto eth1iface eth1 inet staticaddress 192.168.100.150gateway 192.168.100.1netmask 255.255.255.0dns-nameservers 114.114.114.114
另外一种配置方式为:
auto eth0iface eth0 inet staticaddress 192.168.50.1#gateway 192.168.50.1netmask 255.255.255.0auto eth1iface eth1 inet staticaddress 192.168.100.150#gateway 192.168.100.1netmask 255.255.255.0#dns-nameservers 114.114.114.114up route add -net 192.168.50.0 netmask 255.255.255.0 gw 192.168.100.1 dev eth1up route add -net 192.168.100.0 netmask 255.255.255.0 gw 192.168.100.1 dev eth1