网络结构如下图。这个实例是通过设置静态路由,使得数据包沿图中箭头所示的方向传输,最后再进行验证。
1、 设置PC2的IP 地址:192.168.10.1,网关
2、 设置PC3的IP地址:192.168.40.1,网关
3、 设置route1接口的ip地址
Router#
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface f1/0
Router(config-if)#ip address 192.168.10.2 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#intface f0/0
^
Router(config-if)#ip address 192.168.20.1 255.255.255.0
Router(config-if)#no shut
Router(config-if)#int f0/1
Router(config-if)#ip add 192.168.50.1 255.255.255.0
Router(config-if)#no shut
4、 设置router2接口的ip地址
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int f0/0
Router(config-if)#ip add 192.168.20.2 255.255.255.0
Router(config-if)#int f0/1
Router(config-if)#ip add 192.168.30.1 255.255.255.0
Router(config-if)#no shut
Router(config-if)#
Router(config-if)#int f0/0
Router(config-if)#no shut
5、 设置router3接口的ip地址
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int f0/0
Router(config-if)#ip add 192.168.30.2 255.255.255.0
Router(config-if)#no shut
Router(config-if)#int f0/1
Router(config-if)#ip add 192.168.50.2 255.255.255.0
Router(config-if)#no shut
Router(config-if)#int f1/0
Router(config-if)#ip add 192.168.40.2 255.255.255.0
Router(config-if)#no shut
Router(config-if)#
6、在router1上设置静态路由,192.168.40.0网段从f0/0端口出去。
Router(config)#ip route 192.168.40.0 255.255.255.0 f0/0
查看路由表
Router#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.10.0/24 is directly connected, FastEthernet1/0
C 192.168.20.0/24 is directly connected, FastEthernet0/0
S 192.168.40.0/24 is directly connected, FastEthernet0/0
C 192.168.50.0/24 is directly connected, FastEthernet0/1
Router#
6、 在router2上设置静态路由, 192.168.40.0网段从f0/1端口出去。
Router(config)#ip route 192.168.40.0 255.255.255.0 f0/1
Router(config)#
查看路由表:
Router#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.20.0/24 is directly connected, FastEthernet0/0
C 192.168.30.0/24 is directly connected, FastEthernet0/1
S 192.168.40.0/24 is directly connected, FastEthernet0/1
Router#
7、 在router3上设置静态路由, 192.168.10.0网段从f0/1端口出去。
Router(config)#ip route 192.168.10.0 255.255.255.0 f0/1
Router(config)#exit
查看路由表
Router#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
S 192.168.10.0/24 is directly connected, FastEthernet0/1
C 192.168.30.0/24 is directly connected, FastEthernet0/0
C 192.168.40.0/24 is directly connected, FastEthernet1/0
C 192.168.50.0/24 is directly connected, FastEthernet0/1
Router#
8、最后的测试和验证方法
PC>ping 192.168.40.1
Pinging 192.168.40.1 with 32 bytes of data:
Reply from 192.168.40.1: bytes=32 time=94ms TTL=126
Reply from 192.168.40.1: bytes=32 time=109ms TTL=126
Reply from 192.168.40.1: bytes=32 time=109ms TTL=126
Reply from 192.168.40.1: bytes=32 time=109ms TTL=126
Ping statistics for 192.168.40.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 94ms, Maximum = 109ms, Average = 105ms
抓包测试的结果如下图所示:
|
不良信息举报Q:2000617|Archiver|ROS软路由论坛 ROSABC.com 网络方案网络工程交流
GMT+8, 2024-5-15 01:06 , Processed in 0.653677 second(s), 15 queries .
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.