2.3浮动路由
实验目的:
1、掌握静态浮动路由的基本配置。
2、理解静态浮动路由的主备切换。
实验拓扑:
1、依据图中拓扑配置各设备的IP地址,并保证直连连通性;
在R1上做如下配置:
R1(config)#int f0/0
R1(config-if)#no shutdown
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#int f1/0
R1(config-if)#no shutdown
R1(config-if)#ip address 13.1.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#int loopback 1
R1(config-if)#ip address 1.1.1.1 255.255.255.255
R1(config-if)#exit
在R2上做如下配置:
R2(config)#int f0/0
R2(config-if)#no shutdown
R2(config-if)#ip address 12.1.1.2 255.255.255.0
R2(config-if)#exit
R2(config-if)#exit
R2(config)#int loopback 1
R2(config-if)#ip address 8.8.8.8 255.255.255.255
R2(config-if)#exit
在R3上做如下配置
R3(config)#int f0/0
R3(config-if)#no shutdown
R3(config-if)#ip address 13.1.1.3 255.255.255.0
R3(config-if)#exit
R3(config)#int loopback 1
R3(config-if)#ip address 8.8.8.8 255.255.255.255
R3(config-if)#exit
在其中一台路由器上进行连通性测试:
R1#ping 12.1.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 20/34/48 ms
R1#ping 13.1.1.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 13.1.1.3, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 16/31/48 ms
此时说明直连连接没有问题。
2.在R1上部署浮动静态路由,如下:
R1(config)#ip route 0.0.0.0 0.0.0.0 12.1.1.2
R1(config)#ip route 0.0.0.0 0.0.0.0 13.1.1.3 100[PL1]
查看R1的路由表:
R1#show 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 12.1.1.2 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
13.0.0.0/24 is subnetted, 1 subnets
C 13.1.1.0 is directly connected, FastEthernet1/0
S* 0.0.0.0/0 [1/0] via 12.1.1.2
由于管理距离的原因,备用路由被“隐藏”起来,只有最优的路由被放置进路由表。
3.此时进行浮动路由测试,如下:
在R2和R3上开启ICMP实时调试:
R2#debug ip icmp
ICMP packet debugging is on
R3#debug ip icmp
ICMP packet debugging is on
此时在R1上ping 互联网地址,如下:
R1#ping 8.8.8.8
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/36/48 ms
再到R2上查看:
R2#debug ip icmp
ICMP packet debugging is on
R2#
*Mar 1 11:42:30.189: ICMP: echo reply sent, src 8.8.8.8, dst 12.1.1.1
*Mar 1 11:42:30.237: ICMP: echo reply sent, src 8.8.8.8, dst 12.1.1.1
*Mar 1 11:42:30.269: ICMP: echo reply sent, src 8.8.8.8, dst 12.1.1.1
*Mar 1 11:42:30.317: ICMP: echo reply sent, src 8.8.8.8, dst 12.1.1.1
*Mar 1 11:42:30.345: ICMP: echo reply sent, src 8.8.8.8, dst 12.1.1.1
可以看到,R2进行ICMP回应,说明正常情况下通往互联网的数据包往主链路走。此时关闭R1的主链路,模拟主链路出现故障,并查看路由表:
R1(config)#int f0/0
R1(config-if)#shutdown
R1(config-if)#end
R1#show 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 13.1.1.3 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback1
13.0.0.0/24 is subnetted, 1 subnets
C 13.1.1.0 is directly connected, FastEthernet1/0
S* 0.0.0.0/0 [100/0] via 13.1.1.3
此时主链路路由消失,备用路由“浮出”路由表,再次在R1上Ping互联网地址,如下:
R1#ping 8.8.8.8
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 24/30/32 ms
切换到R3上:
R3#
*Mar 1 07:58:25.386: ICMP: echo reply sent, src 8.8.8.8, dst 13.1.1.1
*Mar 1 07:58:25.426: ICMP: echo reply sent, src 8.8.8.8, dst 13.1.1.1
*Mar 1 07:58:25.458: ICMP: echo reply sent, src 8.8.8.8, dst 13.1.1.1
*Mar 1 07:58:25.490: ICMP: echo reply sent, src 8.8.8.8, dst 13.1.1.1
整个过程可以看到,当主链路正常时,备用链路隐藏,流量往主链路走,当主链路故障时,备用链路“浮出”,流量往备链路走,实现了故障切换。此实验完成。
[PL1]默认情况下,默认路由的管理距离为0,管理距离越小越优先,范围从0到255;所以备用链路的管理距离要比主链路的管理距离大。
==========================================
PingingLab・高品质IT教育提供商
CCIE 实验室・IT项目实战・高端人才定制
深圳拼客信息科技有限公司・广州大学城外环西路站
新浪微博:@拼客科技PingingLab @PingingLab-陈鑫杰
PingingLab微信公众号:pinginglab
PingingLab技术交流群:240920680