BGP

BGP Weight: The Cisco-Only Path Attribute (and When to Use It)

BGP weight is the first tiebreaker in the path-selection algorithm, set locally and never propagated. The three ways to set it, how it compares to LOCAL_PREF, and worked examples.
BGP weight Cisco path attribute feature image, PingLabz
Table of Contents
In: BGP, Fundamentals

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.

Weight
Step1
PreferHigher
LOCAL_PREF
Step2
PreferHigher
Locally originated
Step3
Prefer
Yes (via network or redistribute)
AS_PATH length
Step4
PreferShorter
Origin code
Step5
Prefer
IGP < EGP < Incomplete
MED
Step6
PreferLower (within same AS)
eBGP over iBGP
Step7
PrefereBGP wins
IGP cost to BGP next-hop
Step8
PreferLower
Oldest path
Step9
PreferOlder for eBGP
Router ID of advertising peer
Step10
PreferLower
Cluster list length
Step11
PreferShorter
Neighbor IP address
Step12
PreferLower
Multipath
Step13
Prefer
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 network statement or redistribute

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 200

Every 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 in

This 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 in

Sets 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 100

Both 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, external

Two 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

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

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.

Written by
More from Ping Labz
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Ping Labz.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.