利用浮动路由实现链路的冗余和备份
Router(config)#host R2
R2(config)#int lo0
R2(config-if)#ip addr 192.168.10.1 255.255.255.0
R2(config-if)#int s1/1
R2(config-if)#ip addr 202.110.100.1 255.255.255.0
R2(config-if)#encap hdlc
R2(config-if)#clock rate 56000
R2(config-if)#no shut
R2(config-if)#
*May 4 17:14:38.623: %LINK-3-UPDOWN: Interface Serial1/1, changed state to up
*May 4 17:14:39.627: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/1, changed state to up
R2(config-if)#eixt
^
% Invalid input detected at '^' marker.
R2(config-if)#exit
R2(config)#router rip
R2(config-router)#net 192.168.10.0
R2(config-router)#net 202.110.100.0
Router(config)#host R3
R3(config)#int s1/1
R3(config-if)#ip addr 202.110.100.2 255.255.255.0
R3(config-if)#encap hdlc
R3(config-if)#no shut
R3(config-if)#int s1/
*May 4 17:17:47.207: %LINK-3-UPDOWN: Interface Serial1/1, changed state to up0
R3(config-if)#
*May 4 17:17:48.211: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/1, changed state to up
R3(config-if)#int s1/0
R3(config-if)#ip addr 202.110.101.1 255.255.255.0
R3(config-if)#encap hdlc
R3(config-if)#clock rate 56000
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#
*May 4 17:18:24.639: %LINK-3-UPDOWN: Interface Serial1/0, changed state to up
*May 4 17:18:25.643: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to up
R3(config)#router rip
R3(config-router)#net 202.110.100.0
R3(config-router)#net 202.110.101.0
Router(config)#host R4
R4(config)#int s1/0
R4(config-if)#ip addr 202.110.101.2 255.255.255.0
R4(config-if)#encap hdlc
R4(config-if)#no shut
R4(config-if)#int s
*May 4 17:20:03.155: %LINK-3-UPDOWN: Interface Serial1/0, changed state to up1/1
*May 4 17:20:04.159: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to up
R4(config-if)#int s1/1
R4(config-if)#ip addr 202.110.103.1 255.255.255.0
R4(config-if)#encap hdlc
R4(config-if)#clock rate 56000
R4(config-if)#no shut
R4(config-if)#exit
R4(config)#
*May 4 17:20:35.643: %LINK-3-UPDOWN: Interface Serial1/1, changed state to up
*May 4 17:20:36.647: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/1, changed state to up
R4(config)#router rip
R4(config-router)#net 202.110.101.0
R4(config-router)#net 202.110.103.0
Router(config)#host R5
R5(config)#int s1/1
R5(config-if)#ip addr 202.110.103.2 255.255.255.0
R5(config-if)#encap hdlc
R5(config-if)#no shut
R5(config-if)#int s
*May 4 17:21:43.763: %LINK-3-UPDOWN: Interface Serial1/1, changed state to up
*May 4 17:21:44.767: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/1, changed state to up
% Incomplete command.
R5(config)#int lo1
R5(config-if)#ip addr 192.168.20.1 255.255.255.0
R5(config)#router rip
R5(config-router)#net 202.110.103.0
R5(config-router)#net 192.168.20.0
R5#show ip ro
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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
R 202.110.100.0/24 [120/2] via 202.110.103.1, 00:00:15, Serial1/1
R 202.110.101.0/24 [120/1] via 202.110.103.1, 00:00:15, Serial1/1
R 192.168.10.0/24 [120/3] via 202.110.103.1, 00:00:15, Serial1/1
C 202.110.103.0/24 is directly connected, Serial1/1
C 192.168.20.0/24 is directly connected, Loopback1
R5#
在R2上做一个数据包的跟踪。
2#
R2#traceroute 192.168.20.1
Type escape sequence to abort.
Tracing the route to 192.168.20.1
1 202.110.100.2 52 msec 56 msec 48 msec
2 202.110.101.2 120 msec 140 msec 96 msec
3 202.110.103.2 168 msec 212 msec *
R2#
很显然,路由是走了图种配置RIP的路径。
接下来,我们在R3,R4上分别做一条默认管理距离的静态路由。按照理论的分析,默认静态路由是1,那么毫无疑问,最好路由将是静态路由的路径。
R3(config)#int s1/2
R3(config-if)#ip addr 202.110.102.1 255.255.255.0
R3(config-if)#encap hdlc
R3(config-if)#clock rate 56000
R3(config-if)#no shut
R3(config-if)#
*May 4 17:34:45.071: %LINK-3-UPDOWN: Interface Serial1/2, changed state to up
*May 4 17:34:46.071: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/2, changed state to up
R3(config-if)#exit
R3(config)#ip route 192.168.20.0 255.255.255.0 202.110.102.2
R3(config)#
*May 4 17:35:11.687: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/2, changed state to down
刚配置完R3时,端口协议是down的状态,注意观察当R4上配置完之后,端口协议的状态。
R4#config t
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)#int s1/2
R4(config-if)#ip addr 202.110.102.2 255.255.255.0
R4(config-if)#encap hdlc
R4(config-if)#no shut
R4(config-if)#
*May 4 17:36:31.339: %LINK-3-UPDOWN: Interface Serial1/2, changed state to up
*May 4 17:36:32.343: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/2, changed state to up
R4(config-if)#exit
R4(config)#ip route 192.168.10.0 255.255.255.0 202.110.102.1
回头再看R3的变化。
*May 4 17:36:41.687: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/2, changed state to up
理论和试验是相吻合的。
此刻,再在R2上做数据包的跟踪,试验结果如下:
R2>
R2>en
R2#tracetroute 192.168.20.1
^
% Invalid input detected at '^' marker.
R2#traceroute 192.168.20.1
Type escape sequence to abort.
Tracing the route to 192.168.20.1
1 * * *
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * *
还会继续查询下去……
还可以在R2上ping 192.168.20.1
R2#ping 192.168.20.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R2#
显然路由是不通的。这要以前的试验路由再发布来解释了,静态路由默认是不发布的,RIP的路由不能通过中间的静态路由直接发布过来,这也是我为什么将浮动路由放在路由再发布之后的原因。
下面进入这篇博文的精华地方,那就是通过配置特定管理距离的静态路由实现链路的冗余和备份。
R3(config)# ip route 192.168.20.0 255.255.255.0 202.110.102.2 130
R3(config)#
R4(config)# ip route 192.168.10.0 255.255.255.0 202.110.102.1 130
那样的话,默认管理距离越小越好,所以默认的路由应该是走rip协议的路由。
R2#traceroute 192.168.20.1
Type escape sequence to abort.
Tracing the route to 192.168.20.1
1 202.110.100.2 40 msec 44 msec 72 msec
2 202.110.101.2 144 msec 92 msec 120 msec
3 202.110.103.2 168 msec 188 msec
这是很正常的,因为静态路由的管理是130,而RIP协议的默认管理距离是120,可想而知了,当然是走管理距离较小的那个路径了。
我们人为假设S1/0链路出现故障,那么也就是正常的RIP协议不能正常工作,看路由是否主动切换到配置的静态路由上。
R4#show ip ro
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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 [130/0] via 202.110.102.1
C 202.110.102.0/24 is directly connected, Serial1/2
C 202.110.103.0/24 is directly connected, Serial1/1
S 192.168.20.0/24 [130/0] via 202.110.103.2
R5#show ip ro
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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 202.110.103.0/24 is directly connected, Serial1/1
C 192.168.20.0/24 is directly connected, Loopback1
但是R5上的路由为什么不能通过静态路由学到192.168.10.1的路由呢?此处还有待深思考虑,总感觉这里有点问题的,时间原因,只能先留下了。