A-A+

CCNP知识:边界网关协议(BGP)改变权重影响路径选择

2015年11月19日 站长资讯 暂无评论

今天来介绍一个比较复杂的CCNP知识,以4个路由器组成一个环形网来做为实例。边界网关协议(BGP)选择最佳路径总共有11个步骤,平常我们用的最多的大概是AS PATH路径属性,在没有改变其他路径属性的情况下,经过的AS越少,其路径越优。11个步骤有一个前提就是下一跳可达。如果这个前提不满足后面的路径属性也无从谈起。

这11步如下:

1.wights(权重),越大越好。只影响本路由器。

2.本地优先级,越大越好。影响本as内路由器。

3.本地注入的路由,本地注入的路由优于通过IBGP/EBGP获悉的路由。

4.AS PATH越小越好。

5.ORIGIN(始发地),igp>egp>?

6.MED值,越小越好。

7.邻居类型。ebgp优于ibgp。

8.前往下一跳的igp度量值。越小越好。

9.最先知道的ebgp路由。

10.邻居的bgp rid最小

11.邻居的ip地址最小。

比较难记的东西,一般经过前8个步骤就可以选出最佳路由了。而今天这个实验正是通过改变第一路径属性-权重来改变最佳路径的选择。

拓扑图如下:

下面是4个路由器的具体的配置命令:

r1属于as1,r2属于as3,r3属于as2,r4属于as4.

  1. r1:  
  2. in e1/1  
  3. ip add 192.168.1.1 255.255.255.0  
  4. no sh  
  5. in e1/2  
  6. ip add 192.168.2.1 255.255.255.0  
  7. no sh  
  8. in loop 1  
  9. ip add 1.1.1.1 255.0.0.0  
  10. ip route 3.0.0.0 255.0.0.0 192.168.1.2  
  11. router bgp 1  
  12. nei 3.3.3.3 remote-as 2  
  13. nei 3.3.3.3 update-source loop 1  
  14. nei 3.3.3.3 ebgp-mutlihop 2  
  15. nei 3.3.3.3 route-map setweight in  
  16. nei 192.168.2.2 remote-as 3  
  17. ip prefix-list gor3 permit 10.0.0.0/8  
  18. http://www.xiaoxiongboke.com   
  19. route-map setweight permit 10  
  20. match ip add prefix-list gor3  
  21. set weight 200  
  22. route-map setweight permit 20  
  23. r2:  
  24. in e1/2  
  25. ip add 192.168.2.2 255.255.255.0  
  26. no sh  
  27. in e1/3  
  28. ip add 192.168.4.1 255.255.255.0  
  29. no sh  
  30. router bgp 3  
  31. nei 192.168.2.1 remote-as 1  
  32. nei 192.168.4.2 remote-as 4  
  33. r3:  
  34. in e1/1  
  35. ip add 192.168.1.2 255.255.255.0  
  36. no sh  
  37. in e1/0  
  38. ip add 192.168.3.1 255.255.255.0  
  39. no sh  
  40. in loop 1  
  41. ip add 3.3.3.3 255.0.0.0  
  42. ip route 1.0.0.0 255.0.0.0 192.168.1.1  
  43. router bgp 2  
  44. nei 1.1.1.1 remote-as 1  
  45. nei 1.1.1.1 update-source loop 1  
  46. nei 1.1.1.1 ebgp-mutlihop 2  
  47. nei 192.168.3.2 remote-as 4  
  48. r4:  
  49. in e1/1  
  50. ip add 192.168.3.2 255.255.255.0  
  51. no sh  
  52. in e1/2  
  53. ip add 192.168.4.2 255.255.255.0  
  54. in loop 1  
  55. ip add 10.143.132.1 255.0.0.0  
  56. router bgp 4  
  57. nei 192.168.3.1 remote-as 2  
  58. nei 192.168.4.1 remote-as 3   
  59. net 10.0.0.0  

记住想要使这种改变生效,必须得重置邻居关系,在这里我使用软重置。切忌在生产环境中使用硬重置,这会导致所有邻居关系中断并重新计算路由,这在有数十万条路由条目的路由器上绝对会是个灾难,没有一个小时以上的时间路由绝对不会收敛。

我们先看看在重置以前选择的最佳路由是经过哪里。

  1. R1#show ip bgp  
  2. BGP table version is 5, local router ID is 1.1.1.1  
  3. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,  
  4.               r RIB-failure, S Stale  
  5. Origin codes: i - IGP, e - EGP, ? - incomplete  
  6.   
  7.    Network          Next Hop            Metric LocPrf Weight Path  
  8. *  10.0.0.0         3.3.3.3                                0 2 4 i   
  9. *>                  192.168.2.2                            0 3 4 i  

有些东西我得解释一下,第一列的*>代表去往10.0.0.0网段选择的最佳路径是经过下一跳为192.168.2.2的r2路由器。我们看到weight都为0,并且as path经过的数量都一样,都为2个。而路由表也体现了这一点。

  1. R1#show ip ro  
  2. Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP  
  3.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area  
  4.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  5.        E1 - OSPF external type 1, E2 - OSPF external type 2  
  6.        i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2   
  7.        ia - IS-IS inter area, * - candidate default, U - per-user static route  
  8.        o - ODR, P - periodic downloaded static route  
  9.   
  10. Gateway of last resort is not set  
  11.   
  12. C    1.0.0.0/8 is directly connected, Loopback1  
  13. S    3.0.0.0/8 [1/0] via 192.168.1.2  
  14. B    10.0.0.0/8 [20/0] via 192.168.2.2, 00:00:49  
  15. C    192.168.1.0/24 is directly connected, Ethernet1/1  
  16. C    192.168.2.0/24 is directly connected, Ethernet1/2  

注意,我软重置邻居关系。这条命令是在特权模式下打的,而不是在配置模式下。

clear ip bgp * soft

现在再看看选择的最佳路由变了。

  1. R1#clear ip bgp * soft  
  2. R1#show ip bgp  
  3. BGP table version is 6, local router ID is 1.1.1.1  
  4. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,  
  5.               r RIB-failure, S Stale   
  6. Origin codes: i - IGP, e - EGP, ? - incomplete  
  7.   
  8.    Network          Next Hop            Metric LocPrf Weight Path  
  9. *> 10.0.0.0         3.3.3.3                              200 2 4 i  
  10. *                   192.168.2.2                            0 3 4 i  

现在选择的最佳路由为下一跳为3.3.3.3的r3路由器,而这条路由的weight值也变为我在路由映射表中设置的200了。

最后再看看路由表。

  1. R1#show ip ro  
  2. Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP   
  3.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area  
  4.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  5.        E1 - OSPF external type 1, E2 - OSPF external type 2  
  6.        i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2  
  7.        ia - IS-IS inter area, * - candidate default, U - per-user static route  
  8.        o - ODR, P - periodic downloaded static route  
  9.   
  10. Gateway of last resort is not set  
  11.   
  12. C    1.0.0.0/8 is directly connected, Loopback1  
  13. S    3.0.0.0/8 [1/0] via 192.168.1.2  
  14. B    10.0.0.0/8 [20/0] via 3.3.3.3, 00:02:55  
  15. C    192.168.1.0/24 is directly connected, Ethernet1/1  
  16. C    192.168.2.0/24 is directly connected, Ethernet1/2  

呵呵,可能有点晕。不过这些都是CCNP认证考试的必须熟悉和掌握的基础知识了,多花点时间和精力在上面,一定会有很多收获的。

标签:

给我留言