Ubuntu系统配置双网卡方法


公司DELL R610服务器有2块网卡,一块连内网,开发部门做测试用,现在有需求要接双网卡,另一块要连接外网IP;分配外网ip地址后,一直无法ping通外网ip地址;ip地址直连到笔记本可以正常上网,网线也没问题。

后来找到解决方法如下:

Linux环境:Ubuntu 14.04.1系统

内网IP为:192.168.4.213,内网网关:192.168.4.1

外网IP为:58.200.200.15 子网掩码为:255.255.255.128 网关为:58.200.200.1

1.当配置服务器为外网IP和内网IP的方式时,只设置外网IP的网关,不要设置内网IP的网关.

操作如下:

vi /etc/network/interfaces    修改里面的内容如下
auto eth0
iface eth0 inet static
address 192.168.4.213
netmask 255.255.255.0
 
auto eth1
iface eth1 inet static
address 58.200.200.15
netmask 255.255.255.128
gateway 58.200.200.1

注意: 我们没有为 eth0(内部网络) 设置 gateway,保存退出;

2.重启网卡,Ubuntu 重启网卡的命令是: /etc/init.d/networking restart

3.手动设置服务器的路由

route add -net 192.168.4.0/24 gw 192.168.4.1 dev eth0

注意:手动添加的路由,服务器重启后不生效;可以把上面的语句添加到开机自启动文件中;

添加之后,可以ping通外网IP地址;问题解决!

相关内容

    暂无相关文章