A-A+

思科路由器的静态路由和数据包传输的操作实例

2016年02月19日 站长资讯 暂无评论

网络结构如下图,这个实例是通过设置静态路由,使得数据包沿图中箭头所示的方向传输,最后再进行验证。

1、设置PC2的IP 地址:192.168.10.1,网关

2、设置PC3的IP地址:192.168.40.1,网关

3、设置route1接口的ip地址

  1. Router#  
  2. Router#conf t  
  3. Enter configuration commands, one per line.  End with CNTL/Z.  
  4. Router(config)#interface f1/0  
  5. Router(config-if)#ip address 192.168.10.2 255.255.255.0  
  6. Router(config-if)#no shutdown  
  7.    
  8. Router(config-if)#intface f0/0  
  9.                    ^  
  10. Router(config-if)#ip address 192.168.20.1 255.255.255.0  
  11. Router(config-if)#no shut  
  12. Router(config-if)#int f0/1  
  13. Router(config-if)#ip add 192.168.50.1 255.255.255.0  
  14. Router(config-if)#no shut  

4、设置router2接口的ip地址

  1. Router>en  
  2. Router#conf t  
  3. Enter configuration commands, one per line.  End with CNTL/Z.  
  4. Router(config)#int f0/0  
  5. Router(config-if)#ip add 192.168.20.2 255.255.255.0  
  6. Router(config-if)#int f0/1  
  7. Router(config-if)#ip add 192.168.30.1 255.255.255.0  
  8. Router(config-if)#no shut  
  9.    
  10. Router(config-if)#  
  11. Router(config-if)#int f0/0  
  12. Router(config-if)#no shut  

5、 设置router3接口的ip地址

  1. Router>en  
  2. Router#conf t  
  3. Enter configuration commands, one per line.  End with CNTL/Z.  
  4. Router(config)#int f0/0  
  5. Router(config-if)#ip add 192.168.30.2 255.255.255.0  
  6. Router(config-if)#no shut  
  7.    
  8. Router(config-if)#int f0/1  
  9. Router(config-if)#ip add 192.168.50.2 255.255.255.0  
  10. Router(config-if)#no shut  
  11.    
  12. Router(config-if)#int f1/0  
  13. Router(config-if)#ip add 192.168.40.2 255.255.255.0  
  14. Router(config-if)#no shut  
  15. 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

查看路由表

  1. Router#show ip route  
  2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP  
  3.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area  
  4.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  5.        E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP  
  6.        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area  
  7.        * - candidate default, U - per-user static route, o - ODR  
  8.        P - periodic downloaded static route  
  9.    
  10. Gateway of last resort is not set  
  11.    
  12. C    192.168.10.0/24 is directly connected, FastEthernet1/0  
  13. C    192.168.20.0/24 is directly connected, FastEthernet0/0  
  14. S    192.168.40.0/24 is directly connected, FastEthernet0/0  
  15. C    192.168.50.0/24 is directly connected, FastEthernet0/1  
  16. 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)#

查看路由表:

  1. Router#show ip route  
  2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP  
  3.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area  
  4.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  5.        E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP  
  6.        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area  
  7.        * - candidate default, U - per-user static route, o - ODR  
  8.        P - periodic downloaded static route  
  9.    
  10. Gateway of last resort is not set  
  11.    
  12. C    192.168.20.0/24 is directly connected, FastEthernet0/0  
  13. C    192.168.30.0/24 is directly connected, FastEthernet0/1  
  14. S    192.168.40.0/24 is directly connected, FastEthernet0/1  
  15. 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

查看路由表

  1. Router#show ip route  
  2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP  
  3.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area  
  4.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  5.        E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP  
  6.        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area  
  7.        * - candidate default, U - per-user static route, o - ODR  
  8.        P - periodic downloaded static route  
  9.    
  10. Gateway of last resort is not set  
  11.    
  12. S    192.168.10.0/24 is directly connected, FastEthernet0/1  
  13. C    192.168.30.0/24 is directly connected, FastEthernet0/0  
  14. C    192.168.40.0/24 is directly connected, FastEthernet1/0  
  15. C    192.168.50.0/24 is directly connected, FastEthernet0/1  
  16. Router#  

8、最后的测试和验证方法

  1. PC>ping 192.168.40.1  
  2.    
  3. Pinging 192.168.40.1 with 32 bytes of data:  
  4.    
  5. Reply from 192.168.40.1: bytes=32 time=94ms TTL=126  
  6. Reply from 192.168.40.1: bytes=32 time=109ms TTL=126  
  7. Reply from 192.168.40.1: bytes=32 time=109ms TTL=126  
  8. Reply from 192.168.40.1: bytes=32 time=109ms TTL=126  
  9.    
  10. Ping statistics for 192.168.40.1:  
  11.     Packets: Sent = 4Received = 4Lost = 0 (0% loss),  
  12. Approximate round trip times in milli-seconds:  
  13. Minimum = 94msMaximum = 109msAverage = 105ms  

抓包测试的结果如下图所示:

标签:

给我留言