一台服务器的两个网卡,是只能配置一个网关的,如果两个网卡都配置网关的话 ,这时网络是会出现故障的,肯定至少有一个网卡的地址是不管用的。
网络需求:
eth0:addr:211.X.X.50 eth1(也就是机房分配的地址):
mask:255.255.255.252 addr:10.0.3.5 mask:255.255.255.0 geteway:211.X.X.49 gateway:10.0.3.253
原先的服务器:
addr:10.0.1.6
mask:255.255.255.0
给eth0设置过IP、网关之后是可以上公网的,这个是肯定的,除非网络有问题;但是给eth1设置过IP之后是不能和原先的服务器(10.0.1.6)通讯的。
复制代码代码示例:
[root@testServer etc]# ping 10.0.1.6
PING 10.0.1.6 (10.0.1.6) 56(84) bytes of data. From 10.0.3.253 icmp_seq=1 Destination Net Unreachable From 10.0.3.253 icmp_seq=2 Destination Net Unreachable From 10.0.3.253 icmp_seq=3 Destination Net Unreachable From 10.0.3.253 icmp_seq=4 Destination Net Unreachable
此时需要添加一个路由,让10.0.1.0网段和10.0.3.0网段互相识别。
复制代码代码示例:
[root@testServer etc]# route add -net 10.0.0.0/8 gw 10.0.3.253 eth1
[root@testServer etc]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.3.252 * 255.255.255.252 U 0 0 0 eth1 211.X.X.48 * 255.255.255.252 U 0 0 0 eth0 169.254.0.0 * 255.255.0.0 U 0 0 0 eth1 10.0.0.0 10.0.3.253 255.0.0.0 UG 0 0 0 eth1 default 211.X.X..49 0.0.0.0 UG 0 0 0 eth0
添加过这个路由之后再ping:
[root@testServer etc]# ping 10.0.1.6
PING 10.0.1.1 (10.0.1.1) 56(84) bytes of data. 64 bytes from 10.0.1.1: icmp_seq=1 ttl=255 time=3.11 ms 64 bytes from 10.0.1.1: icmp_seq=2 ttl=255 time=1.01 ms 64 bytes from 10.0.1.1: icmp_seq=3 ttl=255 time=0.808 ms 64 bytes from 10.0.1.1: icmp_seq=4 ttl=255 time=1.05 ms 64 bytes from 10.0.1.1: icmp_seq=5 ttl=255 time=0.902 ms
此时可以通讯了,但是这还没有完,因为只要一重启机器,刚才添加的那个路由就会消失,两台机器还是不能够通讯。 |