实验目的:
1、掌握通过修改管理距离解决重分发选择次佳路由问题。
实验拓扑:
步骤1:接口配置
R1(config)#interface f0/0
R1(config-if)#ip address 12.12.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface f0/2
R1(config-if)#ip address 15.15.15.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R2(config)#interface f0/0
R2(config-if)#ip address 12.12.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config)#interface f0/1
R2(config-if)#ip address 23.23.23.2 255.255.255.0
R2(config-if)#no shutdown
R3(config)#interface f0/1
R3(config-if)#ip address 23.23.23.3 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface f0/0
R3(config-if)#ip address 34.34.34.3 255.255.255.0
R3(config-if)#no shutdown
R4(config)#interface f0/0
R4(config-if)#ip address 34.34.34.4 255.255.255.0
R4(config-if)#no shutdown
R4(config)#interface f0/1
R4(config-if)#ip address 45.45.45.4 255.255.255.0
R4(config-if)#no shutdown
R5(config)#interface f0/1
R5(config-if)#ip address 45.45.45.5 255.255.255.0
R5(config-if)#no shutdown
R5(config)#interface f0/2
R5(config-if)#ip address 15.15.15.5 255.255.255.0
R5(config-if)#no shutdown
步骤2:路由协议基础配置
R1(config)#router rip
R1(config-router)#no auto-summary
R1(config-router)#version 2
R1(config-router)#network 12.12.12.0
R1(config-router)#network 15.15.15.0
R1(config-router)#network 1.1.1.0
R2(config)#router rip
R2(config-router)#no auto-summary
R2(config-router)#version 2
R2(config-router)#network 12.12.12.0
R2(config)#router ospf 1
R2(config-router)#network 23.23.23.0 0.0.0.255 area 0
R3(config)#router ospf 1
R3(config-router)#network 23.23.23.0 0.0.0.255 area 0
R3(config-router)#network 34.34.34.0 0.0.0.255 area 0
R4(config)#router ospf 1
R4(config-router)#network 34.34.34.0 0.0.0.255 area 0
R4(config-router)#network 45.45.45.0 0.0.0.255 area 0
R5(config)#router ospf 1
R5(config-router)#network 45.45.45.0 0.0.0.255 area 0
R5(config-router)#router rip
R5(config-router)#no auto-summary
R5(config-router)#version 2
R5(config-router)#network 15.15.15.0
步骤 3:重分发
R2(config)#router ospf 1
R2(config-router)#redistribute rip metric 200 subnets
R2(config-router)#router rip
R2(config-router)#redistribute ospf 1 metric 10
R5(config)#router ospf 1
R5(config-router)#redistribute rip metric 200 subnets
R5(config-router)#router rip
R5(config-router)#redistribute ospf 1 metric 10
查看 R2、R5路由表
R2#show ip route
Gateway of last resort is not set
34.0.0.0/24 is subnetted, 1 subnets
O 34.34.34.0 [110/2] via 23.23.23.3, 00:00:35, FastEthernet0/1
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/1] via 12.12.12.1, 00:00:28, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
C 23.23.23.0 is directly connected, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.12.12.0 is directly connected, FastEthernet0/0
45.0.0.0/24 is subnetted, 1 subnets
O 45.45.45.0 [110/3] via 23.23.23.3, 00:00:37, FastEthernet0/1
15.0.0.0/24 is subnetted, 1 subnets
O E2 15.15.15.0 [110/200] via 23.23.23.3, 00:00:37, FastEthernet0/1
R5#show ip route
Gateway of last resort is not set
34.0.0.0/24 is subnetted, 1 subnets
O 34.34.34.0 [110/2] via 45.45.45.4, 00:01:02, FastEthernet0/1
1.0.0.0/24 is subnetted, 1 subnets
//到达1.1.1.1/24的网络通过45.45.45.4下一跳
O E2 1.1.1.0 [110/200] via 45.45.45.4, 00:01:02, FastEthernet0/1
23.0.0.0/24 is subnetted, 1 subnets
O 23.23.23.0 [110/3] via 45.45.45.4, 00:01:02, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
O E2 12.12.12.0 [110/200] via 45.45.45.4, 00:01:02, FastEthernet0/1
45.0.0.0/24 is subnetted, 1 subnets
C 45.45.45.0 is directly connected, FastEthernet0/1
15.0.0.0/24 is subnetted, 1 subnets
C 15.15.15.0 is directly connected, FastEthernet0/2
通过观察两台路由器的路表,可以看出R5路由器到达10.0.0.0/8的网络并不是直接通过R1路由器,而是通过R4-->R3-->R2-->R1-->10.0.0.0/8。通过拓扑可以看出,此条路由并不是最佳的路由。产生此问题的最主要的原因是:因为在R2路由器上配置路由重发布,R2将10.0.0.0/8网络通告给其它的路由器时,其重发布路由的管理距离是110,即OSPF的管理距离。当此条路由到达R5上时,R5会比较RIP与OSPF的管理距离后,再决定采用谁的路由。因此造成了R5认为到达10.0.0.0/8网络最佳路由是通过OSPF的区域。而不是直接选择从R1到达。是因为:管理距离决定路由器选择何种路由协议产生的路由。
步骤4:为了解决此问题,我们可以通过修改本地某条路由的管理距离来强制路由器选择最佳路由,配置如下:
R5(config)#access-list 1 permit 1.1.1.0 0.0.0.255
R5(config)#router rip
R5(config-router)#distance 80 15.15.15.1 0.0.0.1
再次查看R5路由表
R5#show ip route
Gateway of last resort is not set
34.0.0.0/24 is subnetted, 1 subnets
O 34.34.34.0 [110/2] via 45.45.45.4, 00:06:40, FastEthernet0/1
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [80/1] via 15.15.15.1, 00:00:17, FastEthernet0/2
//此时1.1.1.1/24网络路由的管理已经变为80。因此路由优先选择了RIP协议产生的路由。
23.0.0.0/24 is subnetted, 1 subnets
O 23.23.23.0 [110/3] via 45.45.45.4, 00:06:40, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
R 12.12.12.0 [80/1] via 15.15.15.1, 00:00:17, FastEthernet0/2
45.0.0.0/24 is subnetted, 1 subnets
C 45.45.45.0 is directly connected, FastEthernet0/1
15.0.0.0/24 is subnetted, 1 subnets
C 15.15.15.0 is directly connected, FastEthernet0/2
为了确保网络的稳定,因此建议在R2路由器上也采用相同的配置,进行管理距离值的设定。步骤如上