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).
| Item | Description |
|---|---|
| Type code | None (it is not a BGP path attribute) |
| Classification | A Cisco-proprietary local value |
| Value | A 16-bit unsigned integer (0-65535). Higher is preferred |
| Default | 0 for a received path, 32768 for a locally originated one |
| Scope | The local router only. It is never advertised |
| Definition | Understand 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
| Path | Default WEIGHT |
|---|---|
| Received from a BGP peer | 0 |
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.
| Rank | Condition |
|---|---|
| 1 | Highest WEIGHT |
| 2 | Highest LOCAL_PREF |
| 3 | Locally originated |
| 4 | Shortest AS_PATH |
| 5 | Lowest ORIGIN (IGP < EGP < incomplete) |
| 6 | Lowest MED |
| 7 | eBGP 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.
| Item | WEIGHT | LOCAL_PREF |
|---|---|---|
| A BGP path attribute? | No (Cisco proprietary) | Yes (well-known discretionary, Type 5) |
| Carried in advertisements? | No | To iBGP peers yes (to eBGP peers no) |
| Scope | The single router it is set on | The whole AS |
| Best path selection rank | 1st | 2nd |
| Default | 0, or 32768 when locally originated | 100 |
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 200Route 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 inVerification on Real Devices
Six XRd 26.1.1 routers, in eight STEPs.
| AS | Router | Role |
|---|---|---|
| 65001 | R1, R2 | AS border routers. iBGP full mesh with R3 over Loopback0 (next-hop-self) plus OSPF area 0 |
| 65001 | R3 | Internal. No eBGP peers |
| 65002 | R4 | eBGP with R1, R2 and R5 |
| 65003 | R5 | eBGP with R4 and R6. Advertises 192.168.5.0/24 |
| 65004 | R6 | eBGP 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.
| STEP | Change | What to look for |
|---|---|---|
| 0 | No policy | Every path has Weight 0. Only the locally originated 192.168.1.0/24 has 32768 |
| 1 | weight 200 toward R4 on R1 | R1’s best path moves to R4. R3 is unaffected (router-local) |
| 2 | LOCAL_PREF 200 inbound from R6 on R1 | WEIGHT still wins over the preferred LOCAL_PREF |
| 3 | Remove weight 200 | Only now does LOCAL_PREF take effect |
| 4 | Add a static plus network for 192.168.6.0/24 on R1 | The locally originated 32768 beats the received path |
| 5 | Attach set weight 0 to the network statement | Lowering WEIGHT still leaves the local path as best |
| 6 | weight 40000 toward R6 on R1 | The path via R6 wins, leaving the local path “floating” |
| 7 | Shut 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.
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 pathsOnly 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 200Status 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 pathsThe 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.
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 pathsStatus 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 pathsNothing Changed from R3’s Point of View
The BGP table on R3, in the same AS.
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 pathsOn 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.
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: 100The only attributes are MP_REACH_NLRI, ORIGIN, AS_PATH and LOCAL_PREF: nothing corresponds to WEIGHT.
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 inRP/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 200RP/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/24RP/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.
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 paths192.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.
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, Null0The 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-0RP/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 40000RP/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
shutdownRP/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 19The path from R6 is gone and the locally originated path surfaces as best.
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 pathsThe 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).
| File | Contents |
|---|---|
..._show.txt | show version / show interface description / show route / show bgp / show bgp neighbors <peer> advertised-routes, routes, received routes and so on |
..._log.txt | show 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.txt | show 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
| Router | show output | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 1: Set weight 200 toward R4 on R1
| Router | show output | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 2: Apply LOCAL_PREF 200 inbound from R6 on R1
| Router | show output | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 3: Remove weight 200
| Router | show output | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 4: Add a static plus network for 192.168.6.0/24 on R1
| Router | show output | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 5: Attach set weight 0 to the network statement
| Router | show output | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 6: Set weight 40000 toward R6 on R1
| Router | show output | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 7: Shut down R6’s Loopback1 (final state)
| Router | show output | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
The full capture on the R1-R3 link (iBGP).
Download the full capture (bgp-weight.pcap)References
| Source | Title | Summary |
|---|---|---|
| Cisco | Understand the Importance of BGP Weight Path Attribute | Explains that WEIGHT is Cisco proprietary and local to the router, defaults to 0, and becomes 32768 for locally originated paths. |
| Cisco | Select BGP Best-path Algorithm | The 13-step best path algorithm, where WEIGHT can be seen sitting first. |
| Cisco | Configure and Verify BGP Path Selection in IOS-XR | How to verify best path selection on IOS XR. |
Related Articles
- BGP (Border Gateway Protocol)
- BGP Messages
- BGP Neighbor States
- iBGP vs. eBGP
- BGP next-hop-self
- BGP Route Reflector
- BGP Path Attributes and Best Path Selection
- BGP ORIGIN Attribute
- BGP AS_PATH Attribute
- BGP NEXT_HOP Attribute
- BGP LOCAL_PREF Attribute
- BGP MED Attribute
- BGP WEIGHT Attribute
- BGP COMMUNITY Attribute
- BGP Route Aggregation (aggregate-address)
- MP-BGP (Multiprotocol Extensions)
- BGP Extended Community
- BGP Multipath (maximum-paths)
- BGP Four-Octet AS Numbers (RFC 6793)
- Removing Private AS Numbers in BGP (remove-private-AS)
- BGP ADD-PATH (RFC 7911)
- BGP PIC (Prefix Independent Convergence)
- BGP Best External (advertising a non-best external route)