[iyunv@R1 network-scripts]# route add -net 192.168.1.0/24 gw 172.16.0.2 dev eth1
查看主机R1的路由条目:
1
2
3
4
5
6
[iyunv@R1 network-scripts]# ip route
192.168.96.0/24 dev eth2 proto kernel scope link src 192.168.96.137 metric 1
192.168.1.0/24 via 172.16.0.2 dev eth1
172.16.0.0/16 dev eth1 proto kernel scope link src 172.16.0.1 metric 1
169.254.0.0/16 dev eth0 scope link metric 1002
10.0.0.0/8 dev eth0 proto kernel scope link src 10.0.0.2
b>. 在R2主机上添加通往192.168.1.0网段的路由条目
1
[iyunv@R2 network-scripts]# route add -net 10.0.0.0/8 gw 172.16.0.1 dev eth1
查看主机R2的路由条目:
1
2
3
4
5
[iyunv@R2 network-scripts]# ip route
192.168.96.0/24 dev eth3 proto kernel scope link src 192.168.96.139 metric 1
192.168.1.0/24 dev eth2 proto kernel scope link src 192.168.1.1 metric 1
172.16.0.0/16 dev eth1 proto kernel scope link src 172.16.0.2 metric 1
10.0.0.0/8 via 172.16.0.1 dev eth1
[iyunv@centos7 sysconfig]# ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=62 time=16.2 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=62 time=1.02 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=62 time=1.39 ms
64 bytes from 192.168.1.2: icmp_seq=4 ttl=62 time=1.06 ms
....