↓ Skip to main content
  1. Network Articles/
  2. BGP Articles/

BGP WEIGHT Attribute

Table of Contents

What WEIGHT Is

WEIGHT is a Cisco-proprietary parameter that ranks paths inside a single router only. It is not a path attribute defined by any RFC: there is no place for it in an UPDATE, so it never reaches a neighbour (BGP Path Attributes and Best Path Selection).

ItemDescription
Type codeNone (it is not a BGP path attribute)
ClassificationA Cisco-proprietary local value
ValueA 16-bit unsigned integer (0-65535). Higher is preferred
Default0 for a received path, 32768 for a locally originated one
ScopeThe local router only. It is never advertised
DefinitionUnderstand the Importance of BGP Weight Path Attribute (Cisco)

Higher is preferred, the same direction as LOCAL_PREF. IOS XR shows it in the Weight column of show bgp.

It Is Never Advertised

It reaches neither iBGP nor eBGP peers, so WEIGHT is the tool for “change where this one router sends traffic, and only this router”. To line up the exit across the whole AS, use LOCAL_PREF.

The Default Is 0, and 32768 for Locally Originated Paths

PathDefault WEIGHT
Received from a BGP peer0
Locally originated (a network statement, redistribute, aggregation)32768

When the same prefix is both originated locally and received from a peer, the local one wins unless you do something about it. Best path selection also prefers a locally originated path at step 3, but WEIGHT at step 1 decides first.

Where WEIGHT Sits in Best Path Selection

WEIGHT is the first step of best path selection.

RankCondition
1Highest WEIGHT
2Highest LOCAL_PREF
3Locally originated
4Shortest AS_PATH
5Lowest ORIGIN (IGP < EGP < incomplete)
6Lowest MED
7eBGP over iBGP
……

Once you create a difference in WEIGHT, nothing below it is examined. That power is also the risk: scope it to the prefixes you mean.

WEIGHT Compared with LOCAL_PREF

WEIGHT and LOCAL_PREF both prefer the higher value and both decide the exit; the difference is how far they reach.

ItemWEIGHTLOCAL_PREF
A BGP path attribute?No (Cisco proprietary)Yes (well-known discretionary, Type 5)
Carried in advertisements?NoTo iBGP peers yes (to eBGP peers no)
ScopeThe single router it is set onThe whole AS
Best path selection rank1st2nd
Default0, or 32768 when locally originated100

Because WEIGHT does not reach the other routers in the AS, routers inside the AS can disagree about the best path and form a loop.

Configuration

IOS XR offers two ways to set it. Set per neighbour, it shows up as Default weight 200 in show bgp neighbor.

Per neighbor (the same value for every path received from that peer)

router bgp 65001
 neighbor 10.1.4.4
  address-family ipv4 unicast
   weight 200

Route policy (a different value for selected prefixes)

route-policy SET-WEIGHT
  if destination in (192.168.5.0/24) then
    set weight 200
  endif
  pass
end-policy
!
router bgp 65001
 neighbor 10.1.4.4
  address-family ipv4 unicast
   route-policy SET-WEIGHT in

Verification on Real Devices

Six XRd 26.1.1 routers, in eight STEPs.

The WEIGHT verification lab topology. R1 and R2 in AS 65001 peer eBGP with R4 in AS 65002, and R4 also peers with R5 in AS 65003. R5 peers with R6 in AS 65004, and R6 also peers with R1. R1 learns 192.168.5.0/24 over three paths: via R4, via R6, and via R2
ASRouterRole
65001R1, R2AS border routers. iBGP full mesh with R3 over Loopback0 (next-hop-self) plus OSPF area 0
65001R3Internal. No eBGP peers
65002R4eBGP with R1, R2 and R5
65003R5eBGP with R4 and R6. Advertises 192.168.5.0/24
65004R6eBGP with R5 and R1. Advertises 192.168.6.0/24

STEPs 0 to 3 watch 192.168.5.0/24 as seen from R1, which arrives from three directions with AS_PATH length 2.

  • From R4 (65002 65003)
  • From R6 (65004 65003)
  • From R2 over iBGP (65002 65003)

STEPs 4 to 7 switch to 192.168.6.0/24, which R1 starts originating itself alongside the copy from R6, to watch the locally originated 32768.

STEPChangeWhat to look for
0No policyEvery path has Weight 0. Only the locally originated 192.168.1.0/24 has 32768
1weight 200 toward R4 on R1R1’s best path moves to R4. R3 is unaffected (router-local)
2LOCAL_PREF 200 inbound from R6 on R1WEIGHT still wins over the preferred LOCAL_PREF
3Remove weight 200Only now does LOCAL_PREF take effect
4Add a static plus network for 192.168.6.0/24 on R1The locally originated 32768 beats the received path
5Attach set weight 0 to the network statementLowering WEIGHT still leaves the local path as best
6weight 40000 toward R6 on R1The path via R6 wins, leaving the local path “floating”
7Shut down R6’s Loopback1 (final state)The local path surfaces and becomes best again

STEP 0: Initial State

The Weight column of R1’s BGP table.

R1: show bgp (STEP 0)
Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*> 192.168.1.0/24     0.0.0.0                  0         32768 i
*>i192.168.2.0/24     10.0.0.2                 0    100      0 i
*>i192.168.3.0/24     10.0.0.3                 0    100      0 i
* i192.168.4.0/24     10.0.0.2                 0    100      0 65002 i
*>                    10.1.4.4                 0             0 65002 i
*                     10.1.6.6                               0 65004 65003 65002 i
* i192.168.5.0/24     10.0.0.2                      100      0 65002 65003 i
*                     10.1.4.4                               0 65002 65003 i
*>                    10.1.6.6                               0 65004 65003 i
*> 192.168.6.0/24     10.1.6.6                 0             0 65004 i

Processed 6 prefixes, 10 paths

Only 192.168.1.0/24, which R1 originates, has 32768; every received path has 0. Of the three paths for 192.168.5.0/24 the one via R6 is best, on a lower-ranked condition.

STEP 1: Set weight 200 Toward R4 on R1

Give every path received from R4 (10.1.4.4) a WEIGHT of 200.

router bgp 65001
 neighbor 10.1.4.4
  address-family ipv4 unicast
   weight 200
R1: show bgp (STEP 1)
Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*> 192.168.1.0/24     0.0.0.0                  0         32768 i
*>i192.168.2.0/24     10.0.0.2                 0    100      0 i
*>i192.168.3.0/24     10.0.0.3                 0    100      0 i
* i192.168.4.0/24     10.0.0.2                 0    100      0 65002 i
*>                    10.1.4.4                 0           200 65002 i
*                     10.1.6.6                               0 65004 65003 65002 i
* i192.168.5.0/24     10.0.0.2                      100      0 65002 65003 i
*>                    10.1.4.4                             200 65002 65003 i
*                     10.1.6.6                               0 65004 65003 i
*> 192.168.6.0/24     10.1.6.6                 0             0 65004 i

Processed 6 prefixes, 10 paths

The two routes from R4 now carry 200, and the best path for 192.168.5.0/24 has moved to R4. Neither AS_PATH length nor LOCAL_PREF was touched. routes (after the inbound policy) next to received routes (before it) shows that WEIGHT is applied on receipt.

R1: show bgp neighbors 10.1.4.4 routes (after the policy)
Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*> 192.168.4.0/24     10.1.4.4                 0           200 65002 i
*> 192.168.5.0/24     10.1.4.4                             200 65002 65003 i

Processed 2 prefixes, 2 paths
R1: show bgp neighbors 10.1.4.4 received routes (before the policy)
Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*  192.168.4.0/24     10.1.4.4                 0             0 65002 i
*  192.168.5.0/24     10.1.4.4                               0 65002 65003 i

Processed 2 prefixes, 2 paths

Nothing Changed from R3’s Point of View

The BGP table on R3, in the same AS.

R3: show bgp (STEP 1)
Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*>i192.168.1.0/24     10.0.0.1                 0    100      0 i
*>i192.168.2.0/24     10.0.0.2                 0    100      0 i
*> 192.168.3.0/24     0.0.0.0                  0         32768 i
*>i192.168.4.0/24     10.0.0.1                 0    100      0 65002 i
* i                   10.0.0.2                 0    100      0 65002 i
*>i192.168.5.0/24     10.0.0.1                      100      0 65002 65003 i
* i                   10.0.0.2                      100      0 65002 65003 i
*>i192.168.6.0/24     10.0.0.1                 0    100      0 65004 i

Processed 6 prefixes, 8 paths

On R3, 192.168.5.0/24 still has a WEIGHT of 0; R1’s 200 never reached it.

The UPDATE Carries No WEIGHT

No.111 in the R1-R3 capture is the UPDATE R1 sent to R3 when its best path moved to R4.

No.111 R1 to R3 (iBGP), tshark -V
Border Gateway Protocol - UPDATE Message
    Marker: ffffffffffffffffffffffffffffffff
    Length: 64
    Type: UPDATE Message (2)
    Withdrawn Routes Length: 0
    Total Path Attribute Length: 41
    Path attributes
        Path Attribute - MP_REACH_NLRI
            Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
<snip>
            Type Code: MP_REACH_NLRI (14)
            Length: 13
            Address family identifier (AFI): IPv4 (1)
            Subsequent address family identifier (SAFI): Unicast (1)
            Next hop: 10.0.0.1
                IPv4 Address: 10.0.0.1
            Number of Subnetwork points of attachment (SNPA): 0
            Network Layer Reachability Information (NLRI)
                192.168.5.0/24
                    MP Reach NLRI prefix length: 24
                    MP Reach NLRI IPv4 prefix: 192.168.5.0
        Path Attribute - ORIGIN: IGP
            Flags: 0x40, Transitive, Well-known, Complete
<snip>
            Type Code: ORIGIN (1)
            Length: 1
            Origin: IGP (0)
        Path Attribute - AS_PATH: 65002 65003 
            Flags: 0x40, Transitive, Well-known, Complete
<snip>
            Type Code: AS_PATH (2)
            Length: 10
            AS Path segment: 65002 65003
                Segment type: AS_SEQUENCE (2)
                Segment length (number of ASN): 2
                AS4: 65002
                AS4: 65003
        Path Attribute - LOCAL_PREF: 100
            Flags: 0x40, Transitive, Well-known, Complete
<snip>
            Type Code: LOCAL_PREF (5)
            Length: 4
            Local preference: 100

The only attributes are MP_REACH_NLRI, ORIGIN, AS_PATH and LOCAL_PREF: nothing corresponds to WEIGHT.

Download the pcap of the packet in the tshark output above (No.111 UPDATE)

STEP 2: WEIGHT Beats a LOCAL_PREF of 200

Apply LOCAL_PREF 200 to the 192.168.5.0/24 received from R6 (10.1.6.6).

route-policy LP-200
  if destination in (192.168.5.0/24) then
    set local-preference 200
  endif
  pass
end-policy
!
router bgp 65001
 neighbor 10.1.6.6
  address-family ipv4 unicast
   route-policy LP-200 in
R1: show bgp 192.168.5.0/24 (STEP 2)
RP/0/RP0/CPU0:R1#show bgp 192.168.5.0/24

Tue Sep  8 10:24:35.554 UTC
BGP routing table entry for 192.168.5.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 11           11
Last Modified: Sep  8 10:24:08.774 for 00:00:26
Paths: (5 available, best #2)
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002 65003, (received & used)
    10.0.0.2 (metric 3) from 10.0.0.2 (10.0.0.2)
      Origin IGP, localpref 100, valid, internal
      Received Path ID 0, Local Path ID 0, version 0
  Path #2: Received by speaker 0
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  65002 65003
    10.1.4.4 from 10.1.4.4 (10.0.0.4)
      Origin IGP, localpref 100, weight 200, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 10
      Origin-AS validity: (disabled)
  Path #3: Received by speaker 0
  Not advertised to any peer
  65002 65003, (received-only)
    10.1.4.4 from 10.1.4.4 (10.0.0.4)
      Origin IGP, localpref 100, valid, external
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)
  Path #4: Received by speaker 0
  Not advertised to any peer
  65004 65003
    10.1.6.6 from 10.1.6.6 (10.0.0.6)
      Origin IGP, localpref 200, valid, external, group-best
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)
  Path #5: Received by speaker 0
  Not advertised to any peer
  65004 65003, (received-only)
    10.1.6.6 from 10.1.6.6 (10.0.0.6)
      Origin IGP, localpref 100, valid, external
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)

Path #4 (via R6) has localpref 200 and Path #2 (via R4) localpref 100, weight 200, and Path #2 is still best: step 1 decided, so step 2 was never examined. Paths #3 and #5, marked (received-only), are pre-policy copies that do not take part in selection.

STEP 3: Remove WEIGHT and LOCAL_PREF Takes Over

Remove only weight 200.

router bgp 65001
 neighbor 10.1.4.4
  address-family ipv4 unicast
   no weight 200
R1: show bgp 192.168.5.0/24 (STEP 3)
RP/0/RP0/CPU0:R1#show bgp 192.168.5.0/24

Tue Sep  8 10:28:08.555 UTC
BGP routing table entry for 192.168.5.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 13           13
Last Modified: Sep  8 10:27:04.774 for 00:01:03
Paths: (3 available, best #2)
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002 65003, (received & used)
    10.1.4.4 from 10.1.4.4 (10.0.0.4)
      Origin IGP, localpref 100, valid, external, group-best
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)
  Path #2: Received by speaker 0
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  65004 65003
    10.1.6.6 from 10.1.6.6 (10.0.0.6)
      Origin IGP, localpref 200, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 13
      Origin-AS validity: (disabled)
  Path #3: Received by speaker 0
  Not advertised to any peer
  65004 65003, (received-only)
    10.1.6.6 from 10.1.6.6 (10.0.0.6)
      Origin IGP, localpref 100, valid, external
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)

The best path moves to R6 (Path #2) on localpref 200.

STEP 4: Originate 192.168.6.0/24 on R1 as Well

R1 starts originating 192.168.6.0/24, the prefix R6 advertises, with a static route to Null0 plus a network statement: a common fallback for when R6 goes away.

router static
 address-family ipv4 unicast
  192.168.6.0/24 Null0
 !
!
router bgp 65001
 address-family ipv4 unicast
  network 192.168.6.0/24
R1: show bgp 192.168.6.0/24 (STEP 4)
RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24

Tue Sep  8 10:31:04.448 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 14           14
Last Modified: Sep  8 10:30:36.774 for 00:00:27
Paths: (2 available, best #1)
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  Path #1: Received by speaker 0
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  Local
    0.0.0.0 from 0.0.0.0 (10.0.0.1)
      Origin IGP, metric 0, localpref 100, weight 32768, valid, local, best, group-best
      Received Path ID 0, Local Path ID 1, version 14
  Path #2: Received by speaker 0
  Not advertised to any peer
  65004, (received & used)
    10.1.6.6 from 10.1.6.6 (10.0.0.6)
      Origin IGP, metric 0, localpref 100, valid, external, group-best
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)

The locally originated Path #1 is best with weight 32768; Path #2 from R6 loses at step 1. What R1 advertises changes as well.

R1: show bgp neighbors 10.1.4.4 advertised-routes (STEP 4)
RP/0/RP0/CPU0:R1#show bgp neighbors 10.1.4.4 advertised-routes

Tue Sep  8 10:31:07.589 UTC
Network            Next Hop        From            AS Path
192.168.1.0/24     10.1.4.1        Local           65001i
192.168.2.0/24     10.1.4.1        10.0.0.2        65001i
192.168.3.0/24     10.1.4.1        10.0.0.3        65001i
192.168.4.0/24     10.1.4.1        10.1.4.4        65001 65002i
192.168.5.0/24     10.1.4.1        10.1.6.6        65001 65004 65003i
192.168.6.0/24     10.1.4.1        Local           65001i

Processed 6 prefixes, 6 paths

192.168.6.0/24 now shows From Local with AS_PATH 65001 (through STEP 3 it was relayed as 65001 65004). The RIB needs a caveat.

R1: show route (STEP 4)
RP/0/RP0/CPU0:R1#show route

Tue Sep  8 10:31:02.368 UTC

Codes: C - connected, S - static, R - RIP, B - BGP, (>) - Diversion path
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - ISIS, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, su - IS-IS summary null, * - candidate default
       U - per-user static route, o - ODR, L - local, G  - DAGR, l - LISP
       A - access/subscriber, a - Application route
       M - mobile route, r - RPL, t - Traffic Engineering, (!) - FRR Backup path
       s - local SRv6 route, z - local IID route

Gateway of last resort is not set

L    10.0.0.1/32 is directly connected, 00:18:58, Loopback0
O    10.0.0.2/32 [110/3] via 10.1.3.3, 00:18:18, GigabitEthernet0/0/0/0
O    10.0.0.3/32 [110/2] via 10.1.3.3, 00:18:24, GigabitEthernet0/0/0/0
C    10.1.3.0/24 is directly connected, 00:18:52, GigabitEthernet0/0/0/0
L    10.1.3.1/32 is directly connected, 00:18:52, GigabitEthernet0/0/0/0
C    10.1.4.0/24 is directly connected, 00:18:52, GigabitEthernet0/0/0/1
L    10.1.4.1/32 is directly connected, 00:18:52, GigabitEthernet0/0/0/1
C    10.1.6.0/24 is directly connected, 00:18:52, GigabitEthernet0/0/0/2
L    10.1.6.1/32 is directly connected, 00:18:52, GigabitEthernet0/0/0/2
O    10.2.3.0/24 [110/2] via 10.1.3.3, 00:18:24, GigabitEthernet0/0/0/0
O    10.2.4.0/24 [110/3] via 10.1.3.3, 00:18:18, GigabitEthernet0/0/0/0
C    192.168.1.0/24 is directly connected, 00:18:58, Loopback1
L    192.168.1.1/32 is directly connected, 00:18:58, Loopback1
B    192.168.2.0/24 [200/0] via 10.0.0.2, 00:16:58
B    192.168.3.0/24 [200/0] via 10.0.0.3, 00:16:58
B    192.168.4.0/24 [20/0] via 10.1.4.4, 00:03:58
B    192.168.5.0/24 [20/0] via 10.1.6.6, 00:03:58
S    192.168.6.0/24 is directly connected, 00:00:27, Null0

The static’s administrative distance (1) beats eBGP (20), so the RIB keeps the static to Null0 and R1 itself cannot forward traffic for 192.168.6.0/24. What moves in the following STEPs is the BGP table and the advertisement.

STEP 5: Try Lowering the Locally Originated WEIGHT to 0

Attach a route policy with set weight 0 to the network statement, to weaken the local path.

route-policy SET-WEIGHT-0
  set weight 0
  pass
end-policy
!
router bgp 65001
 address-family ipv4 unicast
  network 192.168.6.0/24 route-policy SET-WEIGHT-0
R1: show bgp 192.168.6.0/24 (STEP 5)
RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24

Tue Sep  8 10:33:51.523 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 15           15
Last Modified: Sep  8 10:33:17.774 for 00:00:33
Paths: (2 available, best #1)
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  Path #1: Received by speaker 0
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  Local
    0.0.0.0 from 0.0.0.0 (10.0.0.1)
      Origin IGP, metric 0, localpref 100, valid, local, best, group-best
      Received Path ID 0, Local Path ID 1, version 15
  Path #2: Received by speaker 0
  Not advertised to any peer
  65004, (received & used)
    10.1.6.6 from 10.1.6.6 (10.0.0.6)
      Origin IGP, metric 0, localpref 100, valid, external, group-best
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)

The WEIGHT dropped, but Path #1 is still best: the next conditions (step 3, locally originated; step 4, AS_PATH length 0 against 1) both favour it. 0 is the floor for WEIGHT, so to have the received path chosen its WEIGHT has to be lifted above 32768.

STEP 6: Set weight 40000 Toward R6

Set a WEIGHT of 40000 on R1’s neighbour towards R6.

router bgp 65001
 neighbor 10.1.6.6
  address-family ipv4 unicast
   weight 40000
R1: show bgp 192.168.6.0/24 (STEP 6)
RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24

Tue Sep  8 10:37:03.692 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 18           18
Last Modified: Sep  8 10:36:36.774 for 00:00:27
Paths: (3 available, best #2)
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  Path #1: Received by speaker 0
  Not advertised to any peer
  Local
    0.0.0.0 from 0.0.0.0 (10.0.0.1)
      Origin IGP, metric 0, localpref 100, valid, local, group-best
      Received Path ID 0, Local Path ID 0, version 0
  Path #2: Received by speaker 0
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  65004
    10.1.6.6 from 10.1.6.6 (10.0.0.6)
      Origin IGP, metric 0, localpref 100, weight 40000, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 18
      Origin-AS validity: (disabled)
  Path #3: Received by speaker 0
  Not advertised to any peer
  65004, (received-only)
    10.1.6.6 from 10.1.6.6 (10.0.0.6)
      Origin IGP, metric 0, localpref 100, valid, external
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)

Path #2 from R6 is best with weight 40000, and the local Path #1 stays in the table without being best. The advertisement reverts to relaying 65001 65004.

A per-neighbour WEIGHT applies to every prefix from that peer, so 192.168.4.0/24 and 192.168.5.0/24 also move to the path via R6. To narrow it, use set weight in an inbound route policy.

STEP 7: Shut Down R6’s Loopback1 (Final State)

Shut down Loopback1 on R6.

interface Loopback1
 shutdown
R1: show bgp 192.168.6.0/24 (STEP 7)
RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24

Tue Sep  8 10:39:59.616 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 19           19
Last Modified: Sep  8 10:39:28.774 for 00:00:30
Paths: (1 available, best #1)
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  Path #1: Received by speaker 0
  Advertised IPv4 Unicast paths to update-groups (with more than one peer):
    0.3 0.4 
  Local
    0.0.0.0 from 0.0.0.0 (10.0.0.1)
      Origin IGP, metric 0, localpref 100, valid, local, best, group-best
      Received Path ID 0, Local Path ID 1, version 19

The path from R6 is gone and the locally originated path surfaces as best.

R1: show bgp neighbors 10.1.4.4 advertised-routes (STEP 7)
RP/0/RP0/CPU0:R1#show bgp neighbors 10.1.4.4 advertised-routes

Tue Sep  8 10:40:02.832 UTC
Network            Next Hop        From            AS Path
192.168.1.0/24     10.1.4.1        Local           65001i
192.168.2.0/24     10.1.4.1        10.0.0.2        65001i
192.168.3.0/24     10.1.4.1        10.0.0.3        65001i
192.168.4.0/24     10.1.4.1        10.1.6.6        65001 65004 65003 65002i
192.168.5.0/24     10.1.4.1        10.1.6.6        65001 65004 65003i
192.168.6.0/24     10.1.4.1        Local           65001i

Processed 6 prefixes, 6 paths

The advertisement is back to Local / 65001. The path via R6 is used normally and the local path appears only when R6 goes away, the floating-static idea built with WEIGHT. R1’s RIB stays on Null0, though, so R1 itself does not forward; this shape suits cases where issuing the advertisement is itself the goal, such as an anchor for an aggregate.

Verification Configs and show Output

Each STEP captures three kinds of file from all six routers. The verification config is the ..._run.txt (final state: STEP 7).

FileContents
..._show.txtshow version / show interface description / show route / show bgp / show bgp neighbors <peer> advertised-routes, routes, received routes and so on
..._log.txtshow logging narrowed to that STEP. A logmsg marker is written at the start of each STEP and its timestamp is passed to show logging start
..._run.txtshow running-config at that STEP (that is, the verification config for the STEP)

In the final state R1 carries the Null0 static for 192.168.6.0/24, network 192.168.6.0/24 route-policy SET-WEIGHT-0, weight 40000 toward R6, and the LP-200 policy that applies LOCAL_PREF 200 to 192.168.5.0/24. On R6, Loopback1 is shut down.

STEP 0: Initial state

Routershow outputsyslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun
R5showlogrun
R6showlogrun

STEP 1: Set weight 200 toward R4 on R1

Routershow outputsyslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun
R5showlogrun
R6showlogrun

STEP 2: Apply LOCAL_PREF 200 inbound from R6 on R1

Routershow outputsyslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun
R5showlogrun
R6showlogrun

STEP 3: Remove weight 200

Routershow outputsyslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun
R5showlogrun
R6showlogrun

STEP 4: Add a static plus network for 192.168.6.0/24 on R1

Routershow outputsyslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun
R5showlogrun
R6showlogrun

STEP 5: Attach set weight 0 to the network statement

Routershow outputsyslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun
R5showlogrun
R6showlogrun

STEP 6: Set weight 40000 toward R6 on R1

Routershow outputsyslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun
R5showlogrun
R6showlogrun

STEP 7: Shut down R6’s Loopback1 (final state)

Routershow outputsyslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun
R5showlogrun
R6showlogrun

The full capture on the R1-R3 link (iBGP).

Download the full capture (bgp-weight.pcap)

References

SourceTitleSummary
CiscoUnderstand the Importance of BGP Weight Path AttributeExplains that WEIGHT is Cisco proprietary and local to the router, defaults to 0, and becomes 32768 for locally originated paths.
CiscoSelect BGP Best-path AlgorithmThe 13-step best path algorithm, where WEIGHT can be seen sitting first.
CiscoConfigure and Verify BGP Path Selection in IOS-XRHow to verify best path selection on IOS XR.

Related Articles