BGP选路策略——Weight
 
BGP选路策略——Weight
 
 
BGP选路原则如下:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

CISCO所定义的选路原则标准是11条,这里加了两条(中文的两条),共13条。所加的两条算不上标准的选路原则,只是做一个补充而已。(切记,要熟记。。。)

 

·                     Prefer highest weight (local to router).

·                     Prefer highest local preference (global within AS).

·                     Prefer route originated by the local router (next hop = <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />0.0.0.0).

·                     Prefer shortest AS path.

·                     Prefer lowest origin code (IGP < EGP < incomplete).

·                     Prefer lowest MED (exchanged between autonomous systems).

·                     Prefer EBGP path over IBGP path.

·                     Prefer the path through the closest IGP neighbor.

·                     如果配置了maximum-path[ibgp]n如果存在多条等价的路径会插入多条路径。

·                     Prefer oldest route for EBGP paths.

·                     Prefer the path with the lowest neighbor BGP router ID.

·                     多跳路径的始发路由器ID相同那么选择CLUSTER_LIST长度短的

·                     Prefer the path with the lowest neighbor IP address.

 

 

 

 

实验目的:通过修改BGP选路属性Weight(权重)来控制数据流向。
 
实验需求:R3发给192.168.1.0网段的数据走R4,发给172.16.1.0网段的数据走R1

 

这里先简单介绍下Weight的特性:

 

·本地有效。只在这一台路由器上起作用,人为设置的邻居的权重

·默认值32768本地产生/ 0收到的路由

·在进行比较时,weight值越大越好

 

    当一个路由器分别从两个不同的邻居处学到同一条路由,它可以根据WEIGHT值决定从哪个邻居走。
 
实验步骤:
R3(config)#access-list 1 permit 172.16.1.0 0.0.0.0  

//利用ACL抓取某条路由时,建议反掩码写成0.0.0.0

R3(config)#route-map R1-172

R3(config-route-map)#match ip address 1

R3(config-route-map)#set weight 100        

//修改ACL1中路由的weihgt

R3(config)#route-map R1-172 20           

//route-map中隐含条目最后一条是deny any,所以这里一定要补充这么一句

R3(config-route-map)#exit

R3(config)#router bgp 1

R3(config-router)#neighbor 13.1.1.1 route-map R1-172 in  

//从邻居13.1.1.1发进来的ACL1中定义的路由,应用route-map R1-172

R3(config)#access-list 2 permit 192.168.1.0

R3(config)#route-map R4-192

R3(config-route-map)#match ip add 2

R3(config-route-map)#set weight 200

R3(config-route-map)#exit

R3(config)#route-map R4-192 20

R3(config-route-map)#exit

R3(config)#router bgp 1

R3(config-router)#neighbor 34.1.1.4 route-map R4-192 in
 
R3#clear ip bgp * soft     
//刚才忘了,呵呵。要使修改生效,一定要手动软启一下BGP

 

=====================验证=======================

R3#sh ip bgp

BGP table version is 5, local router ID is 3.3.3.3

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path

* i172.16.1.0/24    34.1.1.4                 0    100      0 2 i

*>i                 13.1.1.1                 0    100    100 2 i

*>i192.168.1.0      34.1.1.4                 0    100    200 2 i

* i                 13.1.1.1                 0    100      0 2 i

 

 

R3#traceroute 192.168.1.1 source 10.1.1.1    

//我在R3loopback 0上建了一个10.1.1.1的端口,并宣告进BGP中用来测试

Type escape sequence to abort.

Tracing the route to 192.168.1.1

 

  1 34.1.1.4 48 msec 64 msec 112 msec

  2 24.1.1.2 116 msec 136 msec *

 

R3#traceroute 172.16.1.1 source 10.1.1.1

 

Type escape sequence to abort.

Tracing the route to 172.16.1.1

 

  1 13.1.1.1 44 msec 80 msec 76 msec

  2 12.1.1.2 152 msec 128 msec *