PacketLab
BGP · Attributes and Path Selection

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.

Lab topologyIllustrative network
.1 / .2 · eBGP.5 / .6 · eBGP.9 / .10 · iBGPR1AS 65010R2AS 65020R3AS 65020
Solid lines: physical links. Link labels use the last octet of 192.0.2.x; every link is a separate /30. AS labels identify the protocol relationship. Loopback0 is 10.255.0.N/32 for router RN. Exact interfaces and subnets are listed below.
LinkFirst endpointSecond endpoint
R1–R2R1 GigabitEthernet1: 192.0.2.1/30R2 GigabitEthernet1: 192.0.2.2/30
R1–R3R1 GigabitEthernet2: 192.0.2.5/30R3 GigabitEthernet1: 192.0.2.6/30
R2–R3R2 GigabitEthernet2: 192.0.2.9/30R3 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
end

R2

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
end

R3

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
end
Outputs are illustrative, not recorded router results. Each lesson is a separate lab. Allow updates to converge after changes; the selected baseline path is an example when all earlier criteria tie.

Weight 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 i

The 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-family
R1# clear ip bgp 192.0.2.6 soft in
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           500 65020 i
R1# 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 GigabitEthernet2

This 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
exit
router bgp 65010
 address-family ipv4 unicast
  neighbor 192.0.2.2 route-map WEIGHT-TARGET in
 exit-address-family
R1# clear ip bgp 192.0.2.2 soft in
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           700 65020 i
*                     192.0.2.6            0           500 65020 i

R2’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-family
R1# clear ip bgp 192.0.2.2 soft in
R1# clear ip bgp 192.0.2.6 soft in
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 i

Both 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.

Weight Quiz

Six questions · four options each · select one answer per question. Submit all answers to see your score and explanations.

1. R2’s path has weight 700; R3’s has 500. Which does R1 prefer?
2. Where does a weight change take effect?
3. Which policy direction sets weight on paths received from a peer?
4. What is the normal received-path weight in these examples?
5. Why include a final permit clause in the prefix-specific neighbor route map?
6. Can a lower AS-path length override a decisive higher weight here?
Protocol and command references

Best-path comparison rules · BGP path attributes · Router-symbol attribution.