Facts about BGP weight attribute
- Cisco proprietary. Only available for Cisco routers, this attribute is not included in BGP update message.
- Because it is not included in update message, this attribute is only locally significant to one router.
- Because it is locally significant and only the configured router knows the weight, it is only viable for a Cisco router with more than one link peering to different BGP neighbors.
- This attribute is used to influence OUTBOUND traffic from the configured Cisco router. Higher weight is preferred.
- Weight attribute is the first attribute for Cisco router to “consider” for best BGP paths.
- Weight is applied to the inbound BGP routing updates in order to influence the OUTBOUND traffic.
Original BGP before weight is configured
R1#sh ip bgp | b Net
Network Next Hop Metric LocPrf Weight Path
*> 184.108.40.206/32 0.0.0.0 0 32768 i
* 220.127.116.11/24 192.168.13.3 0 2 i
*> 192.168.12.2 0 0 2 i
* 18.104.22.168/24 192.168.13.3 0 0 2 i
*> 192.168.12.2 0 2 i
*> 192.168.12.0/27 0.0.0.0 0 32768 i
*> 192.168.13.0/27 0.0.0.0 0 32768 i
So to reach 22.214.171.124/24 and 126.96.36.199/24 R1 will use R2, it is sensible for R1 to reach 188.8.131.52/24 via R2 since this prefix is a directly connected network for R2.
184.108.40.206/24 however is best reach via R3; this prefix is a directly connected network of R3.
Influence outbound traffic using weight on a neighbor
R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.13.3 weight 500
So what happens?
-_-” duh…. this is not what I want… I want 220.127.116.11/24 via R2 and 18.104.22.168/24 via R3. So applying weight on neighbors is not viable in this requirement.
Use route-map for more granularity on selecting outbound path with weight
R1(config)#access-list 33 permit 22.214.171.124 0.0.0.255
R1(config)#route-map R1->33 permit 10
R1(config-route-map)#match ip address 33
R1(config-route-map)#set weight 500
R1(config-route-map)#route-map R1->33 permit 20
R1(config-route-map)#set weight 0
R1(config-route-map)#router bgp 1
R1(config-router)#neighbor 192.168.13.3 route-map R3->33 in
Using route-map is more granular, base on prefix i can choose which path to reach by using route-map with weight attribute.