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
*> 1.1.1.1/32 0.0.0.0 0 32768 i
* 22.22.22.0/24 192.168.13.3 0 2 i
*> 192.168.12.2 0 0 2 i
* 33.33.33.0/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
R1#
So to reach 22.22.22.0/24 and 33.33.33.0/24 R1 will use R2, it is sensible for R1 to reach 22.22.22.0/24 via R2 since this prefix is a directly connected network for R2.
33.33.33.0/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 22.22.22.0/24 via R2 and 33.33.33.0/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 33.33.33.0 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.
dear so can you please clear me the wight is well know mandatory or Discretionary?
and why is default 32768 any rules ? the value is 0 to 65535 but why choose 32768 any formula ?