BGP weight is the first tiebreaker in BGP's best-path selection algorithm. It is also the only attribute on the list that is Cisco-specific and never leaves the local router. Weight is the most powerful way to make a single router pick one path over another, and the most surgical because no other router in your network or in the rest of the internet knows or cares what you set it to.
For the cluster overview, see the BGP complete guide. For where weight sits in the broader path-influence toolset (LOCAL_PREF, MED, AS_PATH prepending), see the SD-WAN pillar for how SD-WAN solves similar problems differently.
The 13-step path selection refresher
BGP picks the best path by walking through a series of tiebreakers in order. The first tie that one path wins terminates the walk.
| Step | Attribute | Prefer |
|---|---|---|
| 1 | Weight | Higher |
| 2 | LOCAL_PREF | Higher |
| 3 | Locally originated | Yes (via network or redistribute) |
| 4 | AS_PATH length | Shorter |
| 5 | Origin code | IGP < EGP < Incomplete |
| 6 | MED | Lower (within same AS) |
| 7 | eBGP over iBGP | eBGP wins |
| 8 | IGP cost to BGP next-hop | Lower |
| 9 | Oldest path | Older for eBGP |
| 10 | Router ID of advertising peer | Lower |
| 11 | Cluster list length | Shorter |
| 12 | Neighbor IP address | Lower |
| 13 | Multipath | Install multiple if eligible |
Weight is step 1. It wins over everything below it. This is exactly the power of weight, and exactly the danger of weight.
What weight is
Weight is a 16-bit integer (0 to 65535) attached to each path in a local router's BGP table. It is set locally and never advertised to BGP peers. Other routers do not see it, do not act on it, and have no way to know it exists. The default weight is:
- 0 for routes learned from any BGP peer (eBGP or iBGP)
- 32768 for routes the local router originated via
networkstatement orredistribute
Locally originated routes win over learned routes by default because 32768 beats 0 at step 1 of the path selection algorithm. This is rarely the source of operational problems; it just confirms locally-known routes take precedence.
When to use weight
Weight is the right tool when:
- You want to make a single router prefer one path over another
- The decision should not propagate to any other BGP router in your network
- You need the decision to override every other attribute (including LOCAL_PREF)
The canonical example: a dual-homed branch with two ISPs. The local router has two paths to every internet prefix. You want primary ISP to win. You set weight 200 on routes learned from primary ISP (anything > 0 works). All routes learned from primary ISP now have weight 200 and beat the weight-0 routes from the backup. Traffic uses primary unless primary's session drops, at which point the only remaining paths are weight-0 from backup.
If you wanted this preference to apply to your whole network (not just the local router), you would use LOCAL_PREF instead. LOCAL_PREF propagates inside the AS via iBGP; weight does not.
Setting weight: three ways
Method 1: per-neighbor (blanket)
router bgp 65001
neighbor 203.0.113.1 remote-as 65100
neighbor 203.0.113.1 weight 200Every route learned from this neighbor gets weight 200. Simple, blunt instrument. Useful when "everything from this peer is preferred" is what you mean.
Method 2: route-map (per-prefix or per-pattern)
ip prefix-list CUSTOMER-NETS seq 10 permit 10.50.0.0/16 le 24
!
route-map FROM-PRIMARY permit 10
match ip address prefix-list CUSTOMER-NETS
set weight 200
!
route-map FROM-PRIMARY permit 20 ! Catch-all: everything else gets weight 100
set weight 100
!
router bgp 65001
neighbor 203.0.113.1 remote-as 65100
neighbor 203.0.113.1 route-map FROM-PRIMARY inThis sets different weights for different prefixes from the same neighbor. Surgical control. Useful when "I want this peer for these prefixes specifically" rather than "this peer for everything."
Method 3: based on AS_PATH
ip as-path access-list 10 permit ^65100_ ! Routes originating in AS 65100
!
route-map PREFER-PEER permit 10
match as-path 10
set weight 200
!
router bgp 65001
neighbor 203.0.113.1 remote-as 65100
neighbor 203.0.113.1 route-map PREFER-PEER inSets weight based on the AS_PATH of the route. Useful for "prefer paths that originate in a specific AS" or "deprioritize paths that traverse a specific AS."
A worked example
A branch router has two upstream ISP sessions: ISP-A on 203.0.113.1 (primary), ISP-B on 198.51.100.1 (backup). Both ISPs advertise a full BGP table. You want all internet-bound traffic to use ISP-A unless ISP-A is down.
router bgp 65001
neighbor 203.0.113.1 remote-as 65100
neighbor 203.0.113.1 weight 200
neighbor 198.51.100.1 remote-as 65200
neighbor 198.51.100.1 weight 100Both sessions are up. Every prefix has two paths in the BGP table: weight 200 via ISP-A, weight 100 via ISP-B. Weight 200 wins step 1 of best-path. All traffic exits via ISP-A.
ISP-A's session drops. Every prefix now has only the weight-100 path via ISP-B in the BGP table. Traffic shifts to ISP-B. No reconfiguration needed.
ISP-A comes back. Both paths are again in the table. Weight 200 wins. Traffic shifts back to ISP-A.
Verifying weight
R1# show ip bgp 8.8.8.0
BGP routing table entry for 8.8.8.0/24, version 1452
Paths: (2 available, best #1, table default)
65100 15169
203.0.113.1 from 203.0.113.1 (203.0.113.1)
Origin IGP, metric 0, localpref 100, weight 200, valid, external, best
65200 15169
198.51.100.1 from 198.51.100.1 (198.51.100.1)
Origin IGP, metric 0, localpref 100, weight 100, valid, externalTwo paths, weights 200 and 100. The 200-weighted path is marked best. This is the BGP table view; show ip route will show the FIB entry derived from the chosen path.
Weight vs LOCAL_PREF: when to choose which
| Question | Use |
|---|---|
| I want this single router to prefer a path | Weight |
| I want my whole AS to prefer a path | LOCAL_PREF |
| I want the preference to survive router reboots and propagate through iBGP | LOCAL_PREF |
| I want fast, local-only control over a specific router's exit decision | Weight |
| I am working in a multi-vendor environment that includes non-Cisco routers | LOCAL_PREF (weight is Cisco-only) |
| I want the decision to be invisible to other devices on the network | Weight |
Common gotchas
| Symptom | Cause |
|---|---|
| Set weight but path selection unchanged | Weight was set on the wrong neighbor direction (need it on inbound route-map, not outbound). Check neighbor X route-map Y in vs out. |
| Weight set via route-map applies but only to some prefixes | Prefix-list match is too narrow. Add a catch-all permit clause at the end of the route-map to set a default weight for everything else. |
| Weight works on this router but other routers in my AS still take the wrong path | That is the point. Weight is local-only. Use LOCAL_PREF to influence AS-wide decisions. |
| Inherited a network where weight is set everywhere and behavior is confusing | Weight is invisible to neighbors but locally powerful. Audit every router's show ip bgp output to map who is setting what. |
Key takeaways
Weight is BGP's first tiebreaker, set locally, never propagated, Cisco-only, and the most powerful single-router path control available. Use it for dual-homed exits where you want a clean primary/backup pattern on one router. Use LOCAL_PREF when you want the same preference to apply across your whole AS. Higher weight wins. Default is 0 for learned routes, 32768 for locally originated. Verify with show ip bgp X.X.X.X and look for the weight column in the path output.
For broader BGP coverage, see the BGP pillar.