A-A+

实验设计与排错之一:静态路由的实现

2016年01月27日 站长资讯 暂无评论

先说一下基本的概念和原理:路由是指把1个数据包从1个设备发送到不同网络里的另1个设备上去,这些工作依靠路由器来完成。路由器并不关心主机,它们只关心网络的状态和决定网络中的最佳路径。

路由器可以路由数据包,必须至少知道以下状况:

目标地址(Destination Address)

可以学习到远端网络状态的邻居路由器

到达远端网络的所有路线

到达远端网络的最佳路径

如何保持和验证路由信息

静态路由(Static Routing)

静态路由是指在提供到不与路由器直接相连的远程网络的连接性,要在不使用路由选择协议的情况下提供端到端连接性,必须在两个方向上都配置静态路由,静态路由是由管理员手动添加到路由器的路由表中的。

其优点是没有额外的路由器的CPU负担;节约带宽;增加安全性。缺点是网络管理员必须了解网络的整个拓扑结构;如果网络拓扑发生变化,管理员要在所有的路由器上手动修改路由表;不适合在大型网络中使用。

二、静态路由的配置命令

ip route network [mask] [address|interface][distance] [permanent]

network:是目标网络或目标子网。

mask:子网掩码。

address:下一跳的路由器IP地址。

interface:是用于到达目标网络的接口的名称。

distance:是一个可选参数,用于指定管理距离;

permanent:是一个可选参数,指定路由不会被删除,即使接口关闭了。

1、静态路由拓扑

2、实例

例如某公司原有3个子公司,分别为东莞沙田、东莞长安、印度,其中东莞沙田为总部,所有网络连通并可以正常通信。现因业务需要又收购一间小公司做办事处并接入总部网络,现在问题是办事处与总部及以外的子公司都无法通信(如上网络拓扑图)。

3、拓扑表

4、分析与排错

由于是新增网络结点,新增之前网络均无问题,而新增之后出现问题。则可以初步判断是R4路由器上没有出去的路由,下面我们看看其路由表:

  1. R4#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.     10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks  
  13. C      10.2.0.0/16 is directlyconnected, FastEthernet0/1  
  14. S       10.5.0.0/16 [1/0] via 10.2.0.2  
  15. S       10.6.0.0/16 [1/0] via 10.2.0.2  
  16. C      10.13.0.0/22 is directly connected, FastEthernet0/0  

如红色部分已有指向R2、R3的路由,同时也有一条直连到R1的LAN口的线路,也可以在R4上ping通过R1、R2、R3所有IP地址(如下ping测试)。

  1. R4#ping 10.2.0.2  
  2.    
  3. Type escape sequence to abort.  
  4. Sending 5, 100-byte ICMP Echos to10.2.0.2, timeout is 2 seconds:  
  5. !!!!!  
  6. Success rate is 100 percent (5/5),round-trip min/avg/max = 0/0/1 ms  
  7.    
  8. R4#ping 10.6.0.2  
  9.    
  10. Type escape sequence to abort.  
  11. Sending 5, 100-byte ICMP Echos to10.6.0.2, timeout is 2 seconds:  
  12. !!!!!  
  13. Success rate is 100 percent (5/5),round-trip min/avg/max = 1/1/2 ms  
  14.    
  15. R4#ping 10.5.0.2  
  16.    
  17. Type escape sequence to abort.  
  18. Sending 5, 100-byte ICMP Echos to10.5.0.2, timeout is 2 seconds:  
  19. !!!!!  
  20. Success rate is 100 percent (5/5),round-trip min/avg/max = 1/5/20 ms  
  21.    
  22. R4#ping 10.2.0.100  
  23.    
  24. Type escape sequence to abort.  
  25. Sending 5, 100-byte ICMP Echos to10.2.0.100, timeout is 2 seconds:  
  26. !!!!!  
  27. Success rate is 100 percent (5/5),round-trip min/avg/max = 0/3/15 ms  
  28. R4#  

按正常来说整个网络应该是正常才对,但这里有一个问题就是R1是否知道办事处的网段存在呢?那么我们先来看看它的路由表如下:

  1. R1#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 interarea  
  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. 10.0.0.0/16is subnetted, 3 subnets  
  13. C               10.2.0.0is directly connected, FastEthernet0/0  
  14. S               10.5.0.0 [1/0] via 192.168.10.2  
  15. S               10.6.0.0 [1/0] via 192.168.20.2  
  16. 192.168.10.0/30is subnetted, 1 subnets  
  17. C               192.168.10.0is directly connected, Serial0/0  
  18. 192.168.20.0/30is subnetted, 1 subnets  
  19. C               192.168.20.0is directly connected, Serial0/1  
  20. R1#  

从R1的路由表中我们不难看出其中同样有2条静态路由,分别指向东莞长安、印度,但的确没有指向R4的路由,也就是说R4根本就不知道办事处的存在,下面我们就来给它添加一条静态路由看看如何?

  1. R1(config)#iproute 10.13.0.0 255.255.0.0 10.2.0.3  
  2. R1(config)#end  
  3. R1#  
  4. %SYS-5-CONFIG_I:Configured from console by console  
  5.    
  6. R1#show iproute  
  7. Codes: C -connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP  
  8. D - EIGRP, EX - EIGRP external, O -OSPF, IA - OSPF inter area  
  9. N1 - OSPF NSSA external type 1, N2 -OSPF NSSA external type 2  
  10. E1 - OSPF external type 1, E2 - OSPFexternal type 2, E - EGP  
  11. i - IS-IS, L1 - IS-IS level-1, L2 -IS-IS level-2, ia - IS-IS inter area  
  12. * - candidate default, U - per-userstatic route, o - ODR  
  13. P - periodic downloaded static route  
  14.    
  15. Gateway oflast resort is not set  
  16.    
  17. 10.0.0.0/16 is subnetted, 4 subnets  
  18. C               10.2.0.0 is directly connected,FastEthernet0/0  
  19. S               10.5.0.0[1/0] via 192.168.10.2  
  20. S               10.6.0.0[1/0] via 192.168.20.2  
  21. S              10.13.0.0 [1/0] via 10.2.0.3  
  22. 192.168.10.0/30 is subnetted, 1 subnets  
  23. C               192.168.10.0 is directlyconnected, Serial0/0  
  24. 192.168.20.0/30 is subnetted, 1 subnets  
  25. C               192.168.20.0 is directlyconnected, Serial0/1  
  26. R1#ping10.13.0.2  
  27.    
  28. Type escapesequence to abort.  
  29. Sending 5,100-byte ICMP Echos to 10.13.0.2, timeout is 2 seconds:  
  30. !!!!!  
  31. Successrate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms  
  32.    
  33. R1#ping10.13.0.100  
  34.    
  35. Type escapesequence to abort.  
  36. Sending 5,100-byte ICMP Echos to 10.13.0.100, timeout is 2 seconds:  
  37. !!!!!  
  38. Successrate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms  
  39. R1#  

5、总结

在此实例中应该想到两个问题,一是路由转发,若一个路由器不知道某个网段的存在,自然是不能为其转发任何数据包的。二是回路测试,如一条ping命令在发出后应该有一个出的条目和一个回来的条目才算完成。因此解决这两问题点后,自然可以解决其中的问题。

标签:

给我留言