方法一
内网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