实验17:浮动静态路由
1.实验目的
通过本实验可以掌握浮动静态路由原理、配置以及备份应用。
2.拓扑结构
实验拓扑如图1 所示。
3.实验步骤
本实验通过修改静态路由的管理距离为130,使得路由器选路的时候优先选择RIP,而
静态路由作为备份。配置如下:
 
r0(config)#int s0/0
r0(config-if)#ip add 172.16.1.1 255.255.255.0
r0(config-if)#exit
r0(config)#int f1/0
r0(config-if)#ip add 192.168.1.1 255.255.255.0
r0(config-if)#do sh ip int b
Interface                  IP-Address      OK? Method Status                Protocol
Serial0/0                  172.16.1.1      YES manual administratively down down   
Serial0/1                  unassigned      YES unset  administratively down down   
Serial0/2                  unassigned      YES unset  administratively down down   
Serial0/3                  unassigned      YES unset  administratively down down   
FastEthernet1/0            192.168.1.1     YES manual administratively down down   
r0(config-if)#no sh
*Mar  1 00:09:46.735: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
*Mar  1 00:09:47.735: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to upe
r0(config)#exit
*Mar  1 00:09:51.655: %SYS-5-CONFIG_I: Configured from console by con   
r0#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
r0(config)#int s0/0
r0(config-if)#no sh
*Mar  1 00:10:07.551: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
*Mar  1 00:10:08.551: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
r0(config-if)#exit
r0(config)#int loo 1
*Mar  1 00:11:06.111: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to up       
r0(config-if)#ip add 1.1.1.1 255.255.255.0
r0(config-if)#exit
r0(config)#router rip
r0(config-router)#ve 2
r0(config-router)#net 1.0.0.0
r0(config-router)#net 192.168.1.0
r0(config-router)#exit
r0(config)#ip route 2.2.2.0  255.255.255.0 172.16.1.2 130//将静态路由的管理距离设置为130
 
r0(config)#do sh ip route
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
 
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback1
     2.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
S       2.2.2.0/24 [130/0] via 172.16.1.2
R       2.0.0.0/8 [120/1] via 192.168.1.2, 00:00:02, FastEthernet1/0
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, Serial0/0
C    192.168.1.0/24 is directly connected, FastEthernet1/0
从以上输出可以看出,路由器将RIP 的路由放入路由表中,因为RIP 的管理距离为120
小于在静态路由中设定的130,而静态路由处于备份的地位。
 
r0(config)#do sh ip route
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
 
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback1
     2.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
S       2.2.2.0/24 [130/0] via 172.16.1.2
R       2.0.0.0/8 [120/1] via 192.168.1.2, 00:00:20, FastEthernet1/0
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, Serial0/0
C    192.168.1.0/24 is directly connected, FastEthernet1/0
r0(config)#do sh ip route//DOWNR1f1/0
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
 
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback1
     2.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
S       2.2.2.0/24 [130/0] via 172.16.1.2
R       2.0.0.0/8 [120/1] via 192.168.1.2, 00:00:52, FastEthernet1/0
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, Serial0/0
C    192.168.1.0/24 is directly connected, FastEthernet1/0
r0(config)#int f1/0
r0(config-if)#sh down
                 ^
% Invalid input detected at '^' marker.
 
r0(config-if)#sh
r0(config-if)#do sh ip route
 
*Mar  1 00:36:26.419: %LINK-5-CHANGED: Interface FastEthernet1/0, changed state to administratively down
*Mar  1 00:36:27.419: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to downCodes: 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
 
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback1
     2.0.0.0/24 is subnetted, 1 subnets
S       2.2.2.0 [130/0] via 172.16.1.2
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, Serial0/0
以上输出说明,当主路由中断后,备份的静态路由被放入到路由表中,也很好地解释了
浮动静态路由作为备份的工作原理。
r0(config)#int f1/0
r0(config-if)#no sh
r0(config-if)#
*Mar  1 00:37:45.463: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
*Mar  1 00:37:46.463: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
r0(config-if)#do sh ip route
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
 
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback1
     2.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
S       2.2.2.0/24 [130/0] via 172.16.1.2
R       2.0.0.0/8 [120/1] via 192.168.1.2, 00:00:07, FastEthernet1/0
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, Serial0/0
C    192.168.1.0/24 is directly connected, FastEthernet1/0
以上输出表明当主路由恢复后,浮动静态路由又恢复到备份的地位。
 
r1(config)#int s0/0
r1(config-if)#ip add 172.16.1.2 255.255.255.0
r1(config-if)#no sh
*Mar  1 00:08:09.131: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
*Mar  1 00:08:10.131: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0,          
r1(config)#int f1/0
r1(config-if)#ip add 192.168.1.2 255.255.255.0
r1(config-if)#no sh
*Mar  1 00:08:39.223: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
*Mar  1 00:08:39.579: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
*Mar  1 00:08:40.579: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up  
r1(config-if)#do ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/32/72 ms
r1(config-if)#exit
r1(config-if)#int loo 1
r1(config-if)#ip add 2.2.2.2 255.255.255.0
r1(config-if)#exit
r1(config)#ip route 1.1.1.0 255.255.255.0 172.16.2.1 130
r1(config)#exit
*Mar  1 00:12:47.591: %SYS-5-CONFIG_I: Configured from console by consoleonf
r1(config)#router rip
r1(config-router)#ve 2
r1(config-router)#net 1.0.0.0
r1(config-router)#no net 1.0.0.0
r1(config-router)#net 2.0.0.0
r1(config-router)#net 192.168.1.0
r1(config-router)#exit
r1(config)#int f1/0
r1(config-if)#shutdown
r1(config-if)#
*Mar  1 00:24:25.207: %LINK-5-CHANGED: Interface FastEthernet1/0, changed state to administratively down
*Mar  1 00:24:26.207: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to down
r1(config)#