BGP Weight
Choose a preferred exit on one router without transmitting that local preference to its neighbors.
Lab network
R1 in AS 65010 connects to R2 and R3 in AS 65020. R2 and R3 originate the same /24 from separate test loopbacks and have an internal peering. Unique Loopback0 router IDs avoid identity collisions.
| Link | First endpoint | Second endpoint |
|---|---|---|
| R1–R2 | R1 GigabitEthernet1: 192.0.2.1/30 | R2 GigabitEthernet1: 192.0.2.2/30 |
| R1–R3 | R1 GigabitEthernet2: 192.0.2.5/30 | R3 GigabitEthernet1: 192.0.2.6/30 |
| R2–R3 | R2 GigabitEthernet2: 192.0.2.9/30 | R3 GigabitEthernet2: 192.0.2.10/30 |
Complete baseline configurations
R1
hostname R1
ip cef
interface Loopback0
ip address 10.255.0.1 255.255.255.255
exit
interface GigabitEthernet1
ip address 192.0.2.1 255.255.255.252
no shutdown
exit
interface GigabitEthernet2
ip address 192.0.2.5 255.255.255.252
no shutdown
exit
router bgp 65010
bgp router-id 10.255.0.1
no bgp default ipv4-unicast
neighbor 192.0.2.2 remote-as 65020
neighbor 192.0.2.6 remote-as 65020
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.2 activate
neighbor 192.0.2.6 activate
exit-address-family
endR2
hostname R2
ip cef
interface Loopback0
ip address 10.255.0.2 255.255.255.255
exit
interface Loopback10
ip address 203.0.113.2 255.255.255.0
exit
interface GigabitEthernet1
ip address 192.0.2.2 255.255.255.252
no shutdown
exit
interface GigabitEthernet2
ip address 192.0.2.9 255.255.255.252
no shutdown
exit
router bgp 65020
bgp router-id 10.255.0.2
no bgp default ipv4-unicast
neighbor 192.0.2.1 remote-as 65010
neighbor 192.0.2.10 remote-as 65020
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.1 activate
neighbor 192.0.2.10 activate
network 203.0.113.0 mask 255.255.255.0
exit-address-family
endR3
hostname R3
ip cef
interface Loopback0
ip address 10.255.0.3 255.255.255.255
exit
interface Loopback10
ip address 203.0.113.3 255.255.255.0
exit
interface GigabitEthernet1
ip address 192.0.2.6 255.255.255.252
no shutdown
exit
interface GigabitEthernet2
ip address 192.0.2.10 255.255.255.252
no shutdown
exit
router bgp 65020
bgp router-id 10.255.0.3
no bgp default ipv4-unicast
neighbor 192.0.2.5 remote-as 65010
neighbor 192.0.2.9 remote-as 65020
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.5 activate
neighbor 192.0.2.9 activate
network 203.0.113.0 mask 255.255.255.0
exit-address-family
endWeight is a local implementation parameter available in this command family, not a standard attribute carried in UPDATEs. Higher wins. Received paths normally start at 0; locally originated paths normally start at 32768.
Inspect equal weights
R1# show ip bgp 203.0.113.0/24
Network Next Hop Metric LocPrf Weight Path
*> 203.0.113.0/24 192.0.2.2 0 0 65020 i
* 192.0.2.6 0 0 65020 iThe illustrated baseline chooses R2 after the earlier criteria tie. Do not infer that neighbor configuration order always selects the winner; detailed tie-break evidence matters.
Set neighbor weight
On R1, assign weight 500 to paths received from R3. Re-evaluate inbound routes using the negotiated route-refresh capability.
router bgp 65010
address-family ipv4 unicast
neighbor 192.0.2.6 weight 500
exit-address-familyR1# clear ip bgp 192.0.2.6 soft inR1# show ip bgp 203.0.113.0/24
Network Next Hop Metric LocPrf Weight Path
* 203.0.113.0/24 192.0.2.2 0 0 65020 i
*> 192.0.2.6 0 500 65020 iR1# show ip route 203.0.113.0
Routing entry for 203.0.113.0/24
Known via "bgp 65010", distance 20, metric 0
* 192.0.2.6, via GigabitEthernet2This applies to received paths from that neighbor. It changes R1’s exit selection; it does not set a weight on R2, R3 or another router in the AS.
Set weight for one prefix
Keep the R3 neighbor weight at 500. On R1, give only the target prefix from R2 weight 700 with an inbound route map. The final permit clause preserves unrelated routes.
ip prefix-list TARGET seq 5 permit 203.0.113.0/24
route-map WEIGHT-TARGET permit 10
match ip address prefix-list TARGET
set weight 700
exit
route-map WEIGHT-TARGET permit 20
exitrouter bgp 65010
address-family ipv4 unicast
neighbor 192.0.2.2 route-map WEIGHT-TARGET in
exit-address-familyR1# clear ip bgp 192.0.2.2 soft inR1# show ip bgp 203.0.113.0/24
Network Next Hop Metric LocPrf Weight Path
*> 203.0.113.0/24 192.0.2.2 0 700 65020 i
* 192.0.2.6 0 500 65020 iR2’s candidate wins for this prefix because 700 exceeds 500. The router stops here; a shorter path or a different MED would not override that weight difference.
Restore the baseline
Remove both experiments on R1 and refresh the two peers. The complete configurations above are the baseline to return to.
router bgp 65010
address-family ipv4 unicast
no neighbor 192.0.2.2 route-map WEIGHT-TARGET in
neighbor 192.0.2.6 weight 0
exit-address-familyR1# clear ip bgp 192.0.2.2 soft in
R1# clear ip bgp 192.0.2.6 soft inR1# show ip bgp 203.0.113.0/24
Network Next Hop Metric LocPrf Weight Path
*> 203.0.113.0/24 192.0.2.2 0 0 65020 i
* 192.0.2.6 0 0 65020 iBoth paths return to weight 0; the illustrated later tie-break again chooses R2. Soft inbound processing needs route refresh or previously stored inbound routes.
Key Takeaways
- Higher weight wins on the local selecting router.
- Weight is not transmitted to neighboring routers.
- Neighbor weight affects received paths from that peer; a route map can target a prefix.
- Received paths normally begin at 0, while local origination normally starts at 32768.
- Refresh or reprocess inbound paths before interpreting a changed policy.
Protocol and command references
Best-path comparison rules · BGP path attributes · Router-symbol attribution.