【CCNP】路由策略:管理距离控制路由走向(解决次优路径)
实验拓扑:如图,属于ospf中的双点双向重分发,上面方框表示运行的是ospf协议,下面方框表示运行的是RIP协议。
实验目的:1.将RIP和OSPF互相重分发,观察会发生什么问题
2.通过改变管理距离,解决次优路径问题
实验步骤:
首先完成基本配置
- R1
- R1#conf t
- Enter configuration commands, one per line. End with CNTL/Z.
- R1(config)#int f0/1
- R1(config-if)#ip add 10.1.12.1 255.255.255.0
- R1(config-if)#no sh
- R1(config-if)#int f0/0
- R1(config-if)#ip add 10.1.13.1 255.255.255.0
- R1(config-if)#no sh
- R1(config-if)#int l0
- R1(config-if)#ip add 1.1.1.1 255.255.255.255
- R1(config-if)#no sh
- R1(config-if)#ex
- R2
- R2#conf t
- Enter configuration commands, one per line. End with CNTL/Z.
- R2(config)#int f0/0
- R2(config-if)#ip add 10.1.12.2 255.255.255.0
- R2(config-if)#no sh
- R2(config-if)#int f0/1
- R2(config-if)#ip add 10.1.24.2 255.255.255.0
- R2(config-if)#no sh
- R2(config-if)#int l0
- R2(config-if)#ip add 2.2.2.2 255.255.255.255
- R2(config-if)#no sh
- R2(config-if)#ex
- R3
- R3#conf t
- Enter configuration commands, one per line. End with CNTL/Z.
- R3(config-if)#int f0/1
- R3(config-if)#ip add 10.1.13.3 255.255.255.0
- R3(config-if)#no sh
- R3(config-if)#int f0/0
- R3(config-if)#ip add 10.1.34.3 255.255.255.0
- R3(config-if)#no sh
- R3(config-if)#int l0
- R3(config-if)#ip add 3.3.3.3 255.255.255.255
- R3(config-if)#no sh
- R3(config-if)#ex
- R4
- R4#conf t
- Enter configuration commands, one per line. End with CNTL/Z.
- R4(config)#int l0
- R4(config-if)#ip add 4.4.4.4 255.255.255.255
- R4(config-if)#no sh
- R4(config-if)#int f0/0
- R4(config-if)#ip add 10.1.24.4 255.255.255.0
- R4(config-if)#no sh
- R4(config-if)#int f0/1
- R4(config-if)#ip add 10.1.34.4 255.255.255.0
- R4(config-if)#no sh
- R4(config-if)#ex
接着在R1,R2,R3上运行OSPF ,在R2,R3,R4上运行RIP,注意宣告网段时候不要重叠。
- R1(config)#router ospf 1
- R1(config-router)#router-id 1.1.1.1
- R1(config-router)#network 1.1.1.1 0.0.0.0 a 1
- R1(config-router)#network 10.1.12.0 0.0.0.255 a 1
- R1(config-router)#network 10.1.13.0 0.0.0.255 a 1
- R2(config)#router ospf 1
- R2(config-router)#router-id 2.2.2.2
- R2(config-router)#network 10.1.12.0 0.0.0.255 a 1
- R2(config-router)#network 10.1.12.0 0.0.0.255 a 1
- R2(config-router)#ex
- R3(config)#router ospf 1
- R3(config-router)#router-id 3.3.3.3
- R3(config-router)#network 10.1.13.0 0.0.0.255 a 1
- R3(config-router)#ex
- R3(config)#end
- R2(config)#router rip
- R2(config-router)#version 2
- R2(config-router)#no auto-summary
- R2(config-router)#network 10.0.0.0
- R3(config)#router rip
- R3(config-router)#version 2
- R3(config-router)#no auto-summary
- R3(config-router)#network 10.0.0.0
- R3(config-router)#ex
- R4(config)#router rip
- R4(config-router)#version 2
- R4(config-router)#no auto-summary
- R4(config-router)#network 4.4.4.4
- R4(config-router)#network 10.0.0.0
此时,在R3上show ip route,观察去往4.4.4.4的路由走向
- R3#show ip route
- .......
- 1.0.0.0/32 is subnetted, 1 subnets
- O 1.1.1.1 [110/11] via 10.1.13.1, 00:02:01, FastEthernet0/1
- 3.0.0.0/32 is subnetted, 1 subnets
- C 3.3.3.3 is directly connected, Loopback0
- 4.0.0.0/32 is subnetted, 1 subnets
- R 4.4.4.4 [120/1] via 10.1.34.4, 00:00:05, FastEthernet0/0
- 10.0.0.0/24 is subnetted, 4 subnets
- C 10.1.13.0 is directly connected, FastEthernet0/1
- O 10.1.12.0 [110/20] via 10.1.13.1, 00:02:01, FastEthernet0/1
- R 10.1.24.0 [120/1] via 10.1.34.4, 00:00:07, FastEthernet0/0
- C 10.1.34.0 is directly connected, FastEthernet0/0
发现是直接通过RIP从R4的f0/1走的,没问题。
2.路由重分发
这时候,在R2,R3上将ospf重分发入rip
- R2(config)#router rip
- R2(config-router)#redistribute ospf 1 metric 2
- R3(config)#router rip
- R3(config-router)#redistribute ospf 1 metric 2
注意:将ospf注入rip时,要加上度量值metric,否则默认不可达。
这时候,继续在R3上show ip route
- R3#show ip route
- ........
- 1.0.0.0/32 is subnetted, 1 subnets
- O 1.1.1.1 [110/11] via 10.1.13.1, 00:18:38, FastEthernet0/1
- 3.0.0.0/32 is subnetted, 1 subnets
- C 3.3.3.3 is directly connected, Loopback0
- 4.0.0.0/32 is subnetted, 1 subnets
- R 4.4.4.4 [120/1] via 10.1.34.4, 00:00:07, FastEthernet0/0
- 10.0.0.0/24 is subnetted, 4 subnets
- C 10.1.13.0 is directly connected, FastEthernet0/1
- O 10.1.12.0 [110/20] via 10.1.13.1, 00:18:38, FastEthernet0/1
- R 10.1.24.0 [120/1] via 10.1.34.4, 00:00:08, FastEthernet0/0
- C 10.1.34.0 is directly connected, FastEthernet0/0
依然是没问题的。
在R2上将RIP注入ospf
R2(config)#router ospf 1
R2(config-router)#redistribute rip subnets
这时候,在R3上查看路由表
- R3#show ip route
- .....
- 1.0.0.0/32 is subnetted, 1 subnets
- O 1.1.1.1 [110/11] via 10.1.13.1, 00:00:05, FastEthernet0/1
- 3.0.0.0/32 is subnetted, 1 subnets
- C 3.3.3.3 is directly connected, Loopback0
- 4.0.0.0/32 is subnetted, 1 subnets
- O E2 4.4.4.4 [110/20] via 10.1.13.1, 00:00:05, FastEthernet0/1
- 10.0.0.0/24 is subnetted, 4 subnets
- C 10.1.13.0 is directly connected, FastEthernet0/1
- O 10.1.12.0 [110/20] via 10.1.13.1, 00:00:05, FastEthernet0/1
- O E2 10.1.24.0 [110/20] via 10.1.13.1, 00:00:07, FastEthernet0/1
- C 10.1.34.0 is directly connected, FastEthernet0/0
因为ospf的AD值小于RIP,所以在R3上去往4.4.4.4会优先选择ospf的路径,就是R3—R1—R2—R4这条路,明明只需要走R3—R4这条路,却需要走一大圈,这就是所谓的次优路径,在现网中会造成大量的路由资源浪费。
并且,在R3上将RIP重分发入ospf也会失败,因为,在R3路由表中的RIP路由已经被ospf覆盖,重分发路由是要以路由表中存在路由作为前提。
那么如何解决这种问题?可以通过修改AD值来控制路由的走向。
3.修改AD值,解决次优路径
首先做一个ACL访问列表允许目标网段
R3(config)#access-list 1 permit 4.4.4.4
在RIP中修改RIP到达R4的AD值为100(小于ospf),并且应用ACL
- R3(config)#router rip
- R3(config-router)#distance 100 10.1.34.4 0.0.0.255 1
- R3(config-router)#end
- http://www.xiaoxiongboke.com
- R3#clear ip route * 清空下路由表
- R3#show ip route
- .......
- 1.0.0.0/32 is subnetted, 1 subnets
- O 1.1.1.1 [110/11] via 10.1.13.1, 00:00:01, FastEthernet0/1
- 3.0.0.0/32 is subnetted, 1 subnets
- C 3.3.3.3 is directly connected, Loopback0
- 4.0.0.0/32 is subnetted, 1 subnets
- R 4.4.4.4 [100/1] via 10.1.34.4, 00:00:01, FastEthernet0/0
- 10.0.0.0/24 is subnetted, 4 subnets
- C 10.1.13.0 is directly connected, FastEthernet0/1
- O 10.1.12.0 [110/20] via 10.1.13.1, 00:00:01, FastEthernet0/1
- O E2 10.1.24.0 [110/20] via 10.1.13.1, 00:00:02, FastEthernet0/1
- C 10.1.34.0 is directly connected, FastEthernet0/0
经过调整,发现路由已经正常了。
在R2上也要做一样的修改,否则R2去往4.4.4.4也会出现次优路径
- R2(config)#access-list 1 permit 4.4.4.4
- R2(config)#router rip
- R2(config-router)#distance 100 10.1.24.4 0.0.0.255 1
- R2(config-router)#end
在R3上也将RIP重分发入ospf
R3(config)#router rip
R3(config-router)#redistribute rip subnets
R3(config-router)#end
最后在R1上查看去往R4的环回口4.4.4.4是否正常
- R1#clear ip route *
- R1#show ip route
- ...... http://www.xiaoxiongboke.com/buffalo
- 1.0.0.0/32 is subnetted, 1 subnets
- C 1.1.1.1 is directly connected, Loopback0
- 4.0.0.0/32 is subnetted, 1 subnets
- O E2 4.4.4.4 [110/20] via 10.1.13.3, 00:00:01, FastEthernet0/0
- [110/20] via 10.1.12.2, 00:00:01, FastEthernet0/1
- 10.0.0.0/24 is subnetted, 4 subnets
- C 10.1.13.0 is directly connected, FastEthernet0/0
- C 10.1.12.0 is directly connected, FastEthernet0/1
- O E2 10.1.24.0 [110/20] via 10.1.12.2, 00:00:01, FastEthernet0/1
- O E2 10.1.34.0 [110/20] via 10.1.13.3, 00:00:02, FastEthernet0/0
负载均衡,没有问题,实验结束。