本实验通过修改静态路由的管理距离为130,使得路由器在选中时优先选择RIP,而静态路由作为备份。 路由器R1配置如下: R1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. R1(config)#ip route 2.2.2.0 255.255.255.0 192.168.12.2 130 //在启用静态路由的同时将静态路由的管理距离设置为130 R1(config)#router rip R1(config-router)#version 2 R1(config-router)#no auto-summary R1(config-router)#network 1.1.1.0 R1(config-router)#network 192.168.21.0 R1(config-router)#
路由器R2的配置如下: R2#configure terminal Enter configuration commands, one per line. End with CNTL/Z. R2(config)#ip route 1.1.1.0 255.255.255.0 192.168.12.1 130 R2(config)#router rip R2(config-router)#version 2 R2(config-router)#no auto-summary R2(config-router)#network 192.168.21.0 R2(config-router)#network 2.2.2.0 R2(config-router)#
在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 inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets C 1.1.1.0 is directly connected, Loopback0 2.0.0.0/24 is subnetted, 1 subnets R 2.2.2.0 [120/1] via 192.168.21.2, 00:00:21, FastEthernet0/0 C 192.168.12.0/24 is directly connected, Serial0/3/0 C 192.168.21.0/24 is directly connected, FastEthernet0/0 R1# 以上R1路由表的输出可以看出:路由器将RIP放入路由表中,因为RIP的管理距离是120,小于我们刚才设置的静态路由的130,所以RIP变成这个网络连接的首选项、而静态路由处于备份状态。
我们在R1上将“f0/0”接口关闭然后查看路由表看是什么样的状态: R1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. R1(config)#inter f0/0 //进入“f0/0”接口、 R1(config-if)#shutdown //关闭接口
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to administratively down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to down
R1(config-if)#exit //退回到上一模式 R1(config)#exit //退回到上一模式 R1# %SYS-5-CONFIG_I: Configured from console by console
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 inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets C 1.1.1.0 is directly connected, Loopback0 2.0.0.0/24 is subnetted, 1 subnets S 2.2.2.0 [130/0] via 192.168.12.2 C 192.168.12.0/24 is directly connected, Serial0/3/0 R1# 以上R的路由表输出表示:当接口“f0/0”down掉的时候我们设置的静态路由显示出来了。这个网络的连接还是没有问题的。很好的解释了浮动静态路由做为备份的工作原理。以及他的优点。
在R1上我们再把“f0/0”开启然后查看路由表: R1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. R1(config)#inter f0/0 R1(config-if)#no shutdown
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#end //不管在哪一模式下都能退回到特权模式 R1# %SYS-5-CONFIG_I: Configured from console by console
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 inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets C 1.1.1.0 is directly connected, Loopback0 2.0.0.0/24 is subnetted, 1 subnets R 2.2.2.0 [120/1] via 192.168.21.2, 00:00:06, FastEthernet0/0 C 192.168.12.0/24 is directly connected, Serial0/3/0 C 192.168.21.0/24 is directly connected, FastEthernet0/0 R1# *以上输出表明:当路由器R1上的接口“f0/0”恢复工作后,浮动静态路由也恢复到了备份的地位。