实验设计与排错之一:静态路由的实现
先说一下基本的概念和原理:路由是指把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路由器上没有出去的路由,下面我们看看其路由表:
- R4#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
- 10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
- C 10.2.0.0/16 is directlyconnected, FastEthernet0/1
- S 10.5.0.0/16 [1/0] via 10.2.0.2
- S 10.6.0.0/16 [1/0] via 10.2.0.2
- C 10.13.0.0/22 is directly connected, FastEthernet0/0
如红色部分已有指向R2、R3的路由,同时也有一条直连到R1的LAN口的线路,也可以在R4上ping通过R1、R2、R3所有IP地址(如下ping测试)。
- R4#ping 10.2.0.2
- Type escape sequence to abort.
- Sending 5, 100-byte ICMP Echos to10.2.0.2, timeout is 2 seconds:
- !!!!!
- Success rate is 100 percent (5/5),round-trip min/avg/max = 0/0/1 ms
- R4#ping 10.6.0.2
- Type escape sequence to abort.
- Sending 5, 100-byte ICMP Echos to10.6.0.2, timeout is 2 seconds:
- !!!!!
- Success rate is 100 percent (5/5),round-trip min/avg/max = 1/1/2 ms
- R4#ping 10.5.0.2
- Type escape sequence to abort.
- Sending 5, 100-byte ICMP Echos to10.5.0.2, timeout is 2 seconds:
- !!!!!
- Success rate is 100 percent (5/5),round-trip min/avg/max = 1/5/20 ms
- R4#ping 10.2.0.100
- Type escape sequence to abort.
- Sending 5, 100-byte ICMP Echos to10.2.0.100, timeout is 2 seconds:
- !!!!!
- Success rate is 100 percent (5/5),round-trip min/avg/max = 0/3/15 ms
- R4#
按正常来说整个网络应该是正常才对,但这里有一个问题就是R1是否知道办事处的网段存在呢?那么我们先来看看它的路由表如下:
- R1#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 interarea
- * - candidate default, U - per-user static route, o - ODR
- P - periodic downloaded static route
- Gateway of last resort is not set
- 10.0.0.0/16is subnetted, 3 subnets
- C 10.2.0.0is directly connected, FastEthernet0/0
- S 10.5.0.0 [1/0] via 192.168.10.2
- S 10.6.0.0 [1/0] via 192.168.20.2
- 192.168.10.0/30is subnetted, 1 subnets
- C 192.168.10.0is directly connected, Serial0/0
- 192.168.20.0/30is subnetted, 1 subnets
- C 192.168.20.0is directly connected, Serial0/1
- R1#
从R1的路由表中我们不难看出其中同样有2条静态路由,分别指向东莞长安、印度,但的确没有指向R4的路由,也就是说R4根本就不知道办事处的存在,下面我们就来给它添加一条静态路由看看如何?
- R1(config)#iproute 10.13.0.0 255.255.0.0 10.2.0.3
- R1(config)#end
- R1#
- %SYS-5-CONFIG_I:Configured from console by console
- R1#show iproute
- 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 - OSPFexternal 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-userstatic route, o - ODR
- P - periodic downloaded static route
- Gateway oflast resort is not set
- 10.0.0.0/16 is subnetted, 4 subnets
- C 10.2.0.0 is directly connected,FastEthernet0/0
- S 10.5.0.0[1/0] via 192.168.10.2
- S 10.6.0.0[1/0] via 192.168.20.2
- S 10.13.0.0 [1/0] via 10.2.0.3
- 192.168.10.0/30 is subnetted, 1 subnets
- C 192.168.10.0 is directlyconnected, Serial0/0
- 192.168.20.0/30 is subnetted, 1 subnets
- C 192.168.20.0 is directlyconnected, Serial0/1
- R1#ping10.13.0.2
- Type escapesequence to abort.
- Sending 5,100-byte ICMP Echos to 10.13.0.2, timeout is 2 seconds:
- !!!!!
- Successrate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms
- R1#ping10.13.0.100
- Type escapesequence to abort.
- Sending 5,100-byte ICMP Echos to 10.13.0.100, timeout is 2 seconds:
- !!!!!
- Successrate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms
- R1#
5、总结
在此实例中应该想到两个问题,一是路由转发,若一个路由器不知道某个网段的存在,自然是不能为其转发任何数据包的。二是回路测试,如一条ping命令在发出后应该有一个出的条目和一个回来的条目才算完成。因此解决这两问题点后,自然可以解决其中的问题。