3、vm2添加路由
#route add -net 192.168.233.0/24 gw 172.16.1.6
[root@localhost root]#route add -net 192.168.233.0/24 gw 172.16.1.6
五、测试
1、vm1中
#ping 172.16.1.5
[root@localhost root]# ping 172.16.1.5
PING 172.16.1.5 (172.16.1.5) 56(84) bytes of data.
64 bytes from 172.16.1.5: icmp_seq=1 ttl=63 time=2.07 ms
64 bytes from 172.16.1.5: icmp_seq=2 ttl=63 time=1.21 ms
64 bytes from 172.16.1.5: icmp_seq=3 ttl=63 time=0.485 ms
64 bytes from 172.16.1.5: icmp_seq=4 ttl=63 time=0.649 ms
64 bytes from 172.16.1.5: icmp_seq=5 ttl=63 time=0.488 ms
通过
2、vm2中
#ping 192.168.233.5
通了吗?
[root@localhost root]# ping 192.168.233.5
PING 192.168.233.5 (192.168.233.5) 56(84) bytes of data.
64 bytes from 192.168.233.5: icmp_seq=1 ttl=63 time=1.59 ms
64 bytes from 192.168.233.5: icmp_seq=2 ttl=63 time=0.539 ms
64 bytes from 192.168.233.5: icmp_seq=3 ttl=63 time=0.498 ms
64 bytes from 192.168.233.5: icmp_seq=4 ttl=63 time=0.725 ms
64 bytes from 192.168.233.5: icmp_seq=5 ttl=63 time=0.514 ms
通过
六、显示路由表
1、vm1中
#route
[root@localhost root]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.1.0 192.168.233.6 255.255.255.0 UG 0 0 0 eth0
192.168.233.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
2、gate中
#route
[root@localhost network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.233.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo