A-A+

【CCNP】路由策略:管理距离控制路由走向(解决次优路径)

2015年12月24日 站长资讯 暂无评论

实验拓扑:如图,属于ospf中的双点双向重分发,上面方框表示运行的是ospf协议,下面方框表示运行的是RIP协议。

实验目的:1.将RIP和OSPF互相重分发,观察会发生什么问题

2.通过改变管理距离,解决次优路径问题

实验步骤:

首先完成基本配置

  1. R1  
  2. R1#conf t  
  3. Enter configuration commands, one per line.  End with CNTL/Z.  
  4. R1(config)#int f0/1  
  5. R1(config-if)#ip add 10.1.12.1 255.255.255.0  
  6. R1(config-if)#no sh  
  7.   
  8. R1(config-if)#int f0/0  
  9. R1(config-if)#ip add 10.1.13.1 255.255.255.0  
  10. R1(config-if)#no sh  
  11.   
  12. R1(config-if)#int l0                          
  13. R1(config-if)#ip add 1.1.1.1 255.255.255.255  
  14. R1(config-if)#no sh  
  15. R1(config-if)#ex  
  16.   
  17. R2  
  18. R2#conf t  
  19. Enter configuration commands, one per line.  End with CNTL/Z.  
  20.   
  21. R2(config)#int f0/0  
  22. R2(config-if)#ip add 10.1.12.2 255.255.255.0  
  23. R2(config-if)#no sh  
  24.   
  25. R2(config-if)#int f0/1  
  26. R2(config-if)#ip add 10.1.24.2 255.255.255.0  
  27. R2(config-if)#no sh  
  28.   
  29. R2(config-if)#int l0  
  30. R2(config-if)#ip add 2.2.2.2 255.255.255.255  
  31. R2(config-if)#no sh  
  32. R2(config-if)#ex  
  33.   
  34. R3  
  35. R3#conf t  
  36. Enter configuration commands, one per line.  End with CNTL/Z.  
  37. R3(config-if)#int f0/1  
  38. R3(config-if)#ip add 10.1.13.3 255.255.255.0  
  39. R3(config-if)#no sh  
  40.   
  41. R3(config-if)#int f0/0  
  42. R3(config-if)#ip add 10.1.34.3 255.255.255.0  
  43. R3(config-if)#no sh  
  44.   
  45. R3(config-if)#int l0  
  46. R3(config-if)#ip add 3.3.3.3 255.255.255.255  
  47. R3(config-if)#no sh  
  48. R3(config-if)#ex  
  49.   
  50. R4  
  51. R4#conf t  
  52. Enter configuration commands, one per line.  End with CNTL/Z.  
  53. R4(config)#int l0  
  54. R4(config-if)#ip add 4.4.4.4 255.255.255.255  
  55. R4(config-if)#no sh  
  56.   
  57. R4(config-if)#int f0/0  
  58. R4(config-if)#ip add 10.1.24.4 255.255.255.0  
  59. R4(config-if)#no sh  
  60.   
  61. R4(config-if)#int f0/1  
  62. R4(config-if)#ip add 10.1.34.4 255.255.255.0  
  63. R4(config-if)#no sh  
  64. R4(config-if)#ex  

接着在R1,R2,R3上运行OSPF ,在R2,R3,R4上运行RIP,注意宣告网段时候不要重叠。

  1. R1(config)#router ospf 1  
  2. R1(config-router)#router-id 1.1.1.1  
  3. R1(config-router)#network 1.1.1.1 0.0.0.0 a 1   
  4. R1(config-router)#network 10.1.12.0 0.0.0.255 a 1  
  5. R1(config-router)#network 10.1.13.0 0.0.0.255 a 1  
  6.   
  7. R2(config)#router ospf 1  
  8. R2(config-router)#router-id 2.2.2.2  
  9. R2(config-router)#network 10.1.12.0 0.0.0.255 a 1  
  10. R2(config-router)#network 10.1.12.0 0.0.0.255 a 1  
  11. R2(config-router)#ex  
  12.   
  13. R3(config)#router ospf 1  
  14. R3(config-router)#router-id 3.3.3.3   
  15. R3(config-router)#network 10.1.13.0 0.0.0.255 a 1  
  16. R3(config-router)#ex  
  17. R3(config)#end  
  18.   
  19. R2(config)#router rip  
  20. R2(config-router)#version 2  
  21. R2(config-router)#no auto-summary   
  22. R2(config-router)#network 10.0.0.0  
  23.   
  24. R3(config)#router rip   
  25. R3(config-router)#version 2  
  26. R3(config-router)#no auto-summary   
  27. R3(config-router)#network 10.0.0.0  
  28. R3(config-router)#ex  
  29.   
  30. R4(config)#router rip  
  31. R4(config-router)#version 2  
  32. R4(config-router)#no auto-summary   
  33. R4(config-router)#network 4.4.4.4  
  34. R4(config-router)#network 10.0.0.0  

此时,在R3上show ip route,观察去往4.4.4.4的路由走向

  1. R3#show ip route  
  2. .......  
  3.      1.0.0.0/32 is subnetted, 1 subnets  
  4. O       1.1.1.1 [110/11] via 10.1.13.1, 00:02:01, FastEthernet0/1  
  5.      3.0.0.0/32 is subnetted, 1 subnets  
  6. C       3.3.3.3 is directly connected, Loopback0  
  7.      4.0.0.0/32 is subnetted, 1 subnets  
  8. R       4.4.4.4 [120/1] via 10.1.34.4, 00:00:05, FastEthernet0/0  
  9.      10.0.0.0/24 is subnetted, 4 subnets  
  10. C       10.1.13.0 is directly connected, FastEthernet0/1  
  11. O       10.1.12.0 [110/20] via 10.1.13.1, 00:02:01, FastEthernet0/1  
  12. R       10.1.24.0 [120/1] via 10.1.34.4, 00:00:07, FastEthernet0/0  
  13. C       10.1.34.0 is directly connected, FastEthernet0/0   

发现是直接通过RIP从R4的f0/1走的,没问题。

2.路由重分发

这时候,在R2,R3上将ospf重分发入rip

  1. R2(config)#router rip   
  2. R2(config-router)#redistribute ospf 1 metric 2  
  3.   
  4. R3(config)#router rip   
  5. R3(config-router)#redistribute ospf 1 metric 2  

注意:将ospf注入rip时,要加上度量值metric,否则默认不可达。

这时候,继续在R3上show ip route

  1. R3#show ip route  
  2. ........  
  3.   
  4.      1.0.0.0/32 is subnetted, 1 subnets  
  5. O       1.1.1.1 [110/11] via 10.1.13.1, 00:18:38, FastEthernet0/1  
  6.      3.0.0.0/32 is subnetted, 1 subnets  
  7. C       3.3.3.3 is directly connected, Loopback0  
  8.      4.0.0.0/32 is subnetted, 1 subnets  
  9. R       4.4.4.4 [120/1] via 10.1.34.4, 00:00:07, FastEthernet0/0  
  10.      10.0.0.0/24 is subnetted, 4 subnets  
  11. C       10.1.13.0 is directly connected, FastEthernet0/1  
  12. O       10.1.12.0 [110/20] via 10.1.13.1, 00:18:38, FastEthernet0/1  
  13. R       10.1.24.0 [120/1] via 10.1.34.4, 00:00:08, FastEthernet0/0  
  14. 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上查看路由表

  1. R3#show ip route  
  2. .....  
  3.      1.0.0.0/32 is subnetted, 1 subnets  
  4. O       1.1.1.1 [110/11] via 10.1.13.1, 00:00:05, FastEthernet0/1  
  5.      3.0.0.0/32 is subnetted, 1 subnets  
  6. C       3.3.3.3 is directly connected, Loopback0  
  7.      4.0.0.0/32 is subnetted, 1 subnets  
  8. O E2    4.4.4.4 [110/20] via 10.1.13.1, 00:00:05, FastEthernet0/1  
  9.      10.0.0.0/24 is subnetted, 4 subnets  
  10. C       10.1.13.0 is directly connected, FastEthernet0/1  
  11. O       10.1.12.0 [110/20] via 10.1.13.1, 00:00:05, FastEthernet0/1  
  12. O E2    10.1.24.0 [110/20] via 10.1.13.1, 00:00:07, FastEthernet0/1  
  13. 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

  1. R3(config)#router rip  
  2. R3(config-router)#distance 100 10.1.34.4 0.0.0.255 1  
  3. R3(config-router)#end  
  4. http://www.xiaoxiongboke.com  
  5. R3#clear ip route *         清空下路由表  
  6.   
  7. R3#show ip route     
  8. .......  
  9.   
  10.      1.0.0.0/32 is subnetted, 1 subnets  
  11. O       1.1.1.1 [110/11] via 10.1.13.1, 00:00:01, FastEthernet0/1  
  12.      3.0.0.0/32 is subnetted, 1 subnets  
  13. C       3.3.3.3 is directly connected, Loopback0  
  14.      4.0.0.0/32 is subnetted, 1 subnets  
  15. R       4.4.4.4 [100/1] via 10.1.34.4, 00:00:01, FastEthernet0/0  
  16.      10.0.0.0/24 is subnetted, 4 subnets  
  17. C       10.1.13.0 is directly connected, FastEthernet0/1  
  18. O       10.1.12.0 [110/20] via 10.1.13.1, 00:00:01, FastEthernet0/1  
  19. O E2    10.1.24.0 [110/20] via 10.1.13.1, 00:00:02, FastEthernet0/1  
  20. C       10.1.34.0 is directly connected, FastEthernet0/0  

经过调整,发现路由已经正常了。

在R2上也要做一样的修改,否则R2去往4.4.4.4也会出现次优路径

  1. R2(config)#access-list 1 permit 4.4.4.4  
  2. R2(config)#router rip  
  3. R2(config-router)#distance 100 10.1.24.4 0.0.0.255 1  
  4. 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是否正常

  1. R1#clear ip route *  
  2. R1#show ip route     
  3. ...... http://www.xiaoxiongboke.com/buffalo  
  4.      1.0.0.0/32 is subnetted, 1 subnets  
  5. C       1.1.1.1 is directly connected, Loopback0  
  6.      4.0.0.0/32 is subnetted, 1 subnets  
  7. O E2    4.4.4.4 [110/20] via 10.1.13.3, 00:00:01, FastEthernet0/0  
  8.                 [110/20] via 10.1.12.2, 00:00:01, FastEthernet0/1  
  9.      10.0.0.0/24 is subnetted, 4 subnets  
  10. C       10.1.13.0 is directly connected, FastEthernet0/0  
  11. C       10.1.12.0 is directly connected, FastEthernet0/1  
  12. O E2    10.1.24.0 [110/20] via 10.1.12.2, 00:00:01, FastEthernet0/1  
  13. O E2    10.1.34.0 [110/20] via 10.1.13.3, 00:00:02, FastEthernet0/0  

负载均衡,没有问题,实验结束。

标签:

给我留言