首页 > 系统服务 > 详细

ubuntu配置多网,网关不起作用的问题

时间:2015-10-08 14:28:29      阅读:344      评论:0      收藏:0      [点我收藏+]

在/etc/network/interfaces 中设置网络

 

auto eth0
iface eth0 inet static
address 192.168.50.1
gateway 192.168.50.1
netmask 255.255.255.0


auto eth1
iface eth1 inet static
address 192.168.100.150
gateway 192.168.100.1
netmask 255.255.255.0
dns-nameservers 114.114.114.114

 

结果启动之后默认网关为192.168.50.1

$route

显示如下

$default 192.168.50.1 。。。

真正需要的网关是192.168.100.1

将上述代码修改一下即可

auto eth0
iface eth0 inet static
address 192.168.50.1
#gateway 192.168.50.1
netmask 255.255.255.0


auto eth1
iface eth1 inet static
address 192.168.100.150
gateway 192.168.100.1
netmask 255.255.255.0
dns-nameservers 114.114.114.114

 

另外一种配置方式为:

auto eth0
iface eth0 inet static
address 192.168.50.1
#gateway 192.168.50.1
netmask 255.255.255.0


auto eth1
iface eth1 inet static
address 192.168.100.150
#gateway 192.168.100.1
netmask 255.255.255.0
#dns-nameservers 114.114.114.114

up route add -net 192.168.50.0 netmask 255.255.255.0 gw 192.168.100.1 dev eth1
up route add -net 192.168.100.0 netmask 255.255.255.0 gw 192.168.100.1 dev eth1

 

ubuntu配置多网,网关不起作用的问题

原文:http://www.cnblogs.com/yasmi/p/4860758.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!