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

BGP Path Attributes and Best Path Selection

Table of Contents

What Are Path Attributes?

Path attributes are the extra information BGP carries with a route. They live in the Path Attributes field of an UPDATE and apply to every NLRI that UPDATE carries (BGP Messages). The ASes traversed (AS_PATH), the next forwarding address (NEXT_HOP) and the preferences (LOCAL_PREF, MED) all go here: BGP evaluates routes by this set of attributes rather than by a metric. Each attribute consists of flags, a type code, a length and a value.

The Four Categories

The two high-order bits of Attribute Flags (Optional and Transitive) put every attribute into one of four categories (RFC 4271 section 5). They decide whether an implementation must support the attribute and whether an unknown attribute may be passed on.

CategoryOptionalTransitiveMeaning
Well-known mandatory01Every implementation must support it, and it must be present in the UPDATE.
Well-known discretionary01Every implementation must support it, but including it is optional.
Optional transitive11Support is optional. An unknown attribute is passed on with the Partial bit set.
Optional non-transitive10Support is optional. An unknown attribute is discarded and not passed on.

Well-known attributes always have the Transitive bit set. The Partial bit is used only for optional transitive attributes, set by a router that passes on an attribute it does not understand. The only attribute RFC 4271 explicitly calls well-known discretionary is ATOMIC_AGGREGATE (section 5.1.6). LOCAL_PREF is also a well-known attribute, but the attribute table in section 5 lists it as required towards iBGP (see LOCAL_PREF).

List of Path Attributes

The main path attributes (numbers from the IANA BGP Parameters registry).

Type codeAttributeCategorySummary
1ORIGINWell-known mandatoryHow the route entered BGP (IGP / EGP / Incomplete). Covered in ORIGIN.
2AS_PATHWell-known mandatoryThe sequence of ASes the route traversed, used for loop detection and path length. Covered in AS_PATH.
3NEXT_HOPWell-known mandatoryThe next-hop IP address of the route. See NEXT_HOP and next-hop-self.
4MULTI_EXIT_DISC (MED)Optional non-transitiveTells a neighboring AS which entry point into this AS to prefer. See MED.
5LOCAL_PREFWell-known (required towards iBGP peers, never sent to eBGP peers)Which exit to prefer inside the AS. See LOCAL_PREF.
6ATOMIC_AGGREGATEWell-known discretionaryMarks an aggregate that covers more specific routes. Covered in BGP route aggregation.
7AGGREGATOROptional transitiveThe AS number and Router ID of the router that aggregated the route. Covered in BGP route aggregation.
8COMMUNITYOptional transitiveTags routes so that policies can address them as a group. See COMMUNITY.
9ORIGINATOR_IDOptional non-transitiveThe Router ID of the router that brought the route into the AS, added by a route reflector. Covered in Route Reflector.
10CLUSTER_LISTOptional non-transitiveThe list of cluster IDs the route passed through. Covered in Route Reflector.
14MP_REACH_NLRIOptional non-transitiveCarries routes of address families other than IPv4 unicast (RFC 4760).
15MP_UNREACH_NLRIOptional non-transitiveThe withdrawal counterpart for the multiprotocol extensions.
16EXTENDED COMMUNITIESOptional transitiveCommunities extended to eight bytes (RFC 4360).
17AS4_PATHOptional transitiveComplements AS_PATH across routers that do not support four-octet AS numbers (RFC 6793).
18AS4_AGGREGATOROptional transitiveComplements AGGREGATOR in the same way.
32LARGE_COMMUNITYOptional transitiveTwelve-byte communities (RFC 8092).
IOS XR advertises even IPv4 unicast routes in the MP_REACH_NLRI attribute rather than in the NLRI field of the UPDATE itself (BGP Messages).

Handling Malformed Attributes (RFC 7606)

RFC 4271 said that an UPDATE with a missing mandatory attribute or an inconsistent length must be answered with a NOTIFICATION, tearing the session down. Because a single bad route then took every route with it, RFC 7606 revised this and assigns one of the following to each attribute.

HandlingWhat happens
Attribute discardOnly the attribute is dropped and the route is kept (optional attributes such as COMMUNITY)
Treat-as-withdrawThe NLRI the UPDATE carries is treated as withdrawn (AS_PATH, NEXT_HOP, LOCAL_PREF and others)
Session resetThe session is torn down (when the attribute lengths do not add up and the UPDATE boundary is unknown)

WEIGHT Is Not a Path Attribute

Cisco’s WEIGHT is evaluated first in best-path selection, but it is a Cisco-specific local value and never appears in an UPDATE.

ItemLOCAL_PREFWEIGHT
A path attribute?Yes (type code 5)No (a Cisco-specific local value)
ScopeAll iBGP peers (inside the AS)The configured router only
Default1000 (32768 for locally originated routes)
ComparisonHigher is preferredHigher is preferred

Best Path Selection Order

When several routes exist for the same prefix, BGP picks exactly one as the best path, installs it in the routing table and advertises it to peers. Routes whose NEXT_HOP is unreachable are excluded (next-hop-self). The remaining routes are compared in the following order, stopping as soon as one wins.

OrderCriterionPreferredSource
1WEIGHTHigherCisco-specific
2LOCAL_PREFHigherRFC 4271 9.1.1 (degree of preference)
3Locally originatedOriginated by network, redistribute or aggregationCisco-specific
4AS_PATH lengthShorterRFC 4271 9.1.2.2 a
5ORIGINIGP < EGP < IncompleteRFC 4271 9.1.2.2 b
6MULTI_EXIT_DISCLower (compared only between routes from the same neighboring AS)RFC 4271 9.1.2.2 c
7eBGP over iBGPThe route learned over eBGPRFC 4271 9.1.2.2 d
8IGP metric to the NEXT_HOPLowerRFC 4271 9.1.2.2 e
—Multipath decisionInstall several qualifying routesCisco-specific (multipath)
9Keep the existing best pathBetween eBGP routes tied through step 8, keep the path already chosen (disabled by bgp bestpath compare-routerid)Cisco-specific
10BGP Router IDLower (the ORIGINATOR_ID value if present)RFC 4271 9.1.2.2 f, RFC 4456 9
11CLUSTER_LIST lengthShorterRFC 4456 9
12Neighbor IP addressLowerRFC 4271 9.1.2.2 g

WEIGHT, the locally originated step and keeping the existing best path are Cisco-specific and are not in any RFC. IOS XE uses the same order; what differs is the name of the commands that change how the comparison works.

BehaviorIOS XRIOS XE
Compare MED even between different neighboring ASesbgp bestpath med alwaysbgp always-compare-med
Do not compare AS_PATH lengthbgp bestpath as-path ignorebgp bestpath as-path ignore
Always compare the Router ID on a tiebgp bestpath compare-routeridbgp bestpath compare-routerid

Verification on Real Devices

Seven XRd 26.1.1 routers, with R1 receiving the same prefix over two paths as the observation point.

RouterASRole
R165001Observation point. iBGP with both R2 and R3 (no session between R2 and R3)
R265001Border router with two eBGP sessions, to R4 and R5 in AS 65002
R365001Border router with eBGP to R6 in AS 65004
R465002Originates 192.168.100.0/24 with redistribute static (ORIGIN is ?)
R565002Originates the same 192.168.100.0/24 with network (ORIGIN is i); Loopback100 holds the prefix
R665004Transit. Receives from R5 and passes the prefix to R3, making the AS_PATH one AS longer as seen from R1
R765003Used to confirm that COMMUNITY crosses two ASes

AS 65001 runs OSPF area 0 and the iBGP sessions are between Loopback0s. The eBGP-facing links of R2 and R3 are advertised into OSPF as passive interfaces.

R1 receives 192.168.100.0/24 twice: via R2 (AS_PATH 65002) and via R3 (AS_PATH 65004 65002). Day 0 carries the higher-priority criteria, and each STEP levels one of them with the other path, so the deciding criterion moves one step down at a time.

The STEPs level values instead of removing them because on IOS XR 26.1.1 a WEIGHT already attached to a received route did not go away with no weight, with an inbound soft refresh or even with a hard clear. Changes that add a value take effect immediately.
STEPChangeDeciding criterion on R1 (or R2)
0none (initial state)(1) WEIGHT (only the path via R2 has 100)
1weight 100 on R1’s R3 neighbor as well(2) LOCAL_PREF (200 on the path via R3)
2set local-preference 200 in R1’s FROM-R2 as well(4) AS_PATH length (shorter via R2)
3bgp bestpath as-path ignore on R1(5) ORIGIN (IGP via R3, Incomplete via R2)
4R4 switches to network, levelling ORIGIN(8) IGP metric (MED is not compared on R1)
5OSPF cost 100 on R1 - R2 as well, levelling the metric(10) BGP Router ID
6weight 100 on R2’s R5 neighbor as well(on R2) (6) MED
7MED 100 in R5’s TO-R2 as well, levelling MED(on R2) down to steps (9) / (10)
8clear bgp ipv4 unicast 10.2.4.4 on R2rejected by the CLI, so it never ran
9bgp bestpath compare-routerid on R2no change
10send-community-ebgp on R4 (toward R7)COMMUNITY crosses two ASes
11remove send-community-ebgp from R2 (final state)sending is separate from transitivity

In every STEP R1 sends 50 pings and a traceroute to 192.168.100.1 (R5’s Loopback100), which also shows that forwarding follows the best path.

The Four Categories in an UPDATE

The same UPDATE for 192.168.100.0/24 on the R1 - R2 link (iBGP) and on the R2 - R4 link (eBGP), captured when R4 changed how it originates the prefix in STEP 4.

STEP 4 R1 - R2 No.9 UPDATE (R2 to R1) tshark -V (excerpt)
Border Gateway Protocol - UPDATE Message
<snip>
        Path Attribute - MP_REACH_NLRI
            Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
<snip>
            Next hop: 10.2.4.4
<snip>
                192.168.100.0/24
<snip>
        Path Attribute - ORIGIN: IGP
            Flags: 0x40, Transitive, Well-known, Complete
<snip>
            Origin: IGP (0)
        Path Attribute - AS_PATH: 65002 
            Flags: 0x40, Transitive, Well-known, Complete
<snip>
                AS4: 65002
        Path Attribute - MULTI_EXIT_DISC: 100
            Flags: 0x80, Optional, Non-transitive, Complete
<snip>
            Multiple exit discriminator: 100
        Path Attribute - LOCAL_PREF: 100
            Flags: 0x40, Transitive, Well-known, Complete
<snip>
            Local preference: 100
STEP 4 R2 - R4 No.3 UPDATE (R4 to R2) tshark -V (excerpt)
Border Gateway Protocol - UPDATE Message
<snip>
        Path Attribute - MP_REACH_NLRI
            Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
<snip>
            Next hop: 10.2.4.4
<snip>
                192.168.100.0/24
<snip>
        Path Attribute - ORIGIN: IGP
            Flags: 0x40, Transitive, Well-known, Complete
<snip>
            Origin: IGP (0)
        Path Attribute - AS_PATH: 65002 
            Flags: 0x40, Transitive, Well-known, Complete
<snip>
                AS4: 65002
        Path Attribute - MULTI_EXIT_DISC: 100
            Flags: 0x80, Optional, Non-transitive, Complete
<snip>
            Multiple exit discriminator: 100

Download the pcap of the packet in the tshark output above (STEP 4, the iBGP UPDATE)

Download the pcap of the packet in the tshark output above (STEP 4, the eBGP UPDATE)

Well-known attributes carry 0x40 and optional non-transitive ones 0x80. LOCAL_PREF (well-known; required towards iBGP peers and never sent to eBGP peers) appears only on the iBGP side, not on the eBGP side.

Optional transitive (0xc0) shows up with COMMUNITY, in the UPDATE R4 sent to R7 in AS 65003 (STEP 10).

STEP 10 R4 - R7 No.1 UPDATE (R4 to R7, with COMMUNITY) tshark -V (excerpt)
Border Gateway Protocol - UPDATE Message
<snip>
        Path Attribute - MP_REACH_NLRI
            Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
<snip>
            Next hop: 10.4.7.4
<snip>
        Path Attribute - ORIGIN: IGP
            Flags: 0x40, Transitive, Well-known, Complete
<snip>
            Origin: IGP (0)
        Path Attribute - AS_PATH: 65002 65001 
            Flags: 0x40, Transitive, Well-known, Complete
<snip>
                AS4: 65002
                AS4: 65001
        Path Attribute - COMMUNITIES: 65001:100 
            Flags: 0xc0, Optional, Transitive, Complete
<snip>
            Communities: 65001:100 
Download the pcap of the packet in the tshark output above (STEP 10, the UPDATE with COMMUNITY)
CategoryFlagsAttributes observed here
Well-known mandatory0x40ORIGIN, AS_PATH
Well-known (required towards iBGP)0x40LOCAL_PREF (iBGP only)
Optional transitive0xc0COMMUNITIES
Optional non-transitive0x80MULTI_EXIT_DISC, MP_REACH_NLRI
The 0x90 of MP_REACH_NLRI is 0x80 plus 0x10 (Extended Length, a two-byte length field). ORIGINATOR_ID and CLUSTER_LIST, both optional non-transitive, are added by a route reflector; there is none in this verification, so they were not observed here (the captures in Route Reflector show them).

The Deciding Criterion Moves Down One Step at a Time

show bgp 192.168.100.0/24 on R1. The (received-only) entries are the pre-policy copies kept by soft-reconfiguration inbound always.

R1 show bgp 192.168.100.0/24 (STEP 0)
RP/0/RP0/CPU0:R1#show bgp 192.168.100.0/24
Wed Sep 23 12:10:27.708 UTC
BGP routing table entry for 192.168.100.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 34           34
Last Modified: Sep 23 12:00:35.023 for 00:09:52
Paths: (3 available, best #1)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002, (received & used)
    10.2.4.4 (metric 2) from 10.0.0.2 (10.0.0.2)
      Origin incomplete, metric 100, localpref 100, weight 100, valid, internal, best, group-best
      Received Path ID 0, Local Path ID 1, version 34
  Path #2: Received by speaker 0
  Not advertised to any peer
  65004 65002
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 200, valid, internal, group-best
      Received Path ID 0, Local Path ID 0, version 0
  Path #3: Received by speaker 0
  Not advertised to any peer
  65004 65002, (received-only)
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 100, valid, internal
      Received Path ID 0, Local Path ID 0, version 0
R1 show bgp 192.168.100.0/24 (STEP 1)
RP/0/RP0/CPU0:R1#show bgp 192.168.100.0/24
Wed Sep 23 12:17:25.011 UTC
BGP routing table entry for 192.168.100.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 39           39
Last Modified: Sep 23 12:15:13.023 for 00:02:12
Paths: (3 available, best #2)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002, (received & used)
    10.2.4.4 (metric 2) from 10.0.0.2 (10.0.0.2)
      Origin incomplete, metric 100, localpref 100, weight 100, valid, internal, group-best
      Received Path ID 0, Local Path ID 0, version 0
  Path #2: Received by speaker 0
  Not advertised to any peer
  65004 65002
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 200, weight 100, valid, internal, best, group-best
      Received Path ID 0, Local Path ID 1, version 39
  Path #3: Received by speaker 0
  Not advertised to any peer
  65004 65002, (received-only)
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 100, valid, internal
      Received Path ID 0, Local Path ID 0, version 0
R1 show bgp 192.168.100.0/24 (STEP 2)
RP/0/RP0/CPU0:R1#show bgp 192.168.100.0/24
Wed Sep 23 12:24:25.916 UTC
BGP routing table entry for 192.168.100.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 45           45
Last Modified: Sep 23 12:22:13.023 for 00:02:13
Paths: (4 available, best #1)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002
    10.2.4.4 (metric 2) from 10.0.0.2 (10.0.0.2)
      Origin incomplete, metric 100, localpref 200, weight 100, valid, internal, best, group-best
      Received Path ID 0, Local Path ID 1, version 45
  Path #2: Received by speaker 0
  Not advertised to any peer
  65002, (received-only)
    10.2.4.4 (metric 2) from 10.0.0.2 (10.0.0.2)
      Origin incomplete, metric 100, localpref 100, weight 100, valid, internal
      Received Path ID 0, Local Path ID 0, version 0
  Path #3: Received by speaker 0
  Not advertised to any peer
  65004 65002
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 200, weight 100, valid, internal, group-best
      Received Path ID 0, Local Path ID 0, version 0
  Path #4: Received by speaker 0
  Not advertised to any peer
  65004 65002, (received-only)
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 100, valid, internal
      Received Path ID 0, Local Path ID 0, version 0
R1 show bgp 192.168.100.0/24 (STEP 3)
RP/0/RP0/CPU0:R1#show bgp 192.168.100.0/24
Wed Sep 23 12:31:27.860 UTC
BGP routing table entry for 192.168.100.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 47           47
Last Modified: Sep 23 12:29:15.023 for 00:02:12
Paths: (4 available, best #3)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002
    10.2.4.4 (metric 2) from 10.0.0.2 (10.0.0.2)
      Origin incomplete, metric 100, localpref 200, weight 100, valid, internal, group-best
      Received Path ID 0, Local Path ID 0, version 0
  Path #2: Received by speaker 0
  Not advertised to any peer
  65002, (received-only)
    10.2.4.4 (metric 2) from 10.0.0.2 (10.0.0.2)
      Origin incomplete, metric 100, localpref 100, weight 100, valid, internal
      Received Path ID 0, Local Path ID 0, version 0
  Path #3: Received by speaker 0
  Not advertised to any peer
  65004 65002
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 200, weight 100, valid, internal, best, group-best
      Received Path ID 0, Local Path ID 1, version 47
  Path #4: Received by speaker 0
  Not advertised to any peer
  65004 65002, (received-only)
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 100, valid, internal
      Received Path ID 0, Local Path ID 0, version 0
R1 show bgp 192.168.100.0/24 (STEP 4)
RP/0/RP0/CPU0:R1#show bgp 192.168.100.0/24
Wed Sep 23 12:38:29.238 UTC
BGP routing table entry for 192.168.100.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 48           48
Last Modified: Sep 23 12:36:36.023 for 00:01:53
Paths: (4 available, best #1)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002
    10.2.4.4 (metric 2) from 10.0.0.2 (10.0.0.2)
      Origin IGP, metric 100, localpref 200, weight 100, valid, internal, best, group-best
      Received Path ID 0, Local Path ID 1, version 48
  Path #2: Received by speaker 0
  Not advertised to any peer
  65002, (received-only)
    10.2.4.4 (metric 2) from 10.0.0.2 (10.0.0.2)
      Origin IGP, metric 100, localpref 100, weight 100, valid, internal
      Received Path ID 0, Local Path ID 0, version 0
  Path #3: Received by speaker 0
  Not advertised to any peer
  65004 65002
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 200, weight 100, valid, internal, group-best
      Received Path ID 0, Local Path ID 0, version 0
  Path #4: Received by speaker 0
  Not advertised to any peer
  65004 65002, (received-only)
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 100, valid, internal
      Received Path ID 0, Local Path ID 0, version 0
R1 show bgp 192.168.100.0/24 (STEP 5)
RP/0/RP0/CPU0:R1#show bgp 192.168.100.0/24
Wed Sep 23 12:45:27.510 UTC
BGP routing table entry for 192.168.100.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 48           48
Last Modified: Sep 23 12:36:36.023 for 00:08:51
Paths: (4 available, best #1)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002
    10.2.4.4 (metric 101) from 10.0.0.2 (10.0.0.2)
      Origin IGP, metric 100, localpref 200, weight 100, valid, internal, best, group-best
      Received Path ID 0, Local Path ID 1, version 48
  Path #2: Received by speaker 0
  Not advertised to any peer
  65002, (received-only)
    10.2.4.4 (metric 101) from 10.0.0.2 (10.0.0.2)
      Origin IGP, metric 100, localpref 100, weight 100, valid, internal
      Received Path ID 0, Local Path ID 0, version 0
  Path #3: Received by speaker 0
  Not advertised to any peer
  65004 65002
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 200, weight 100, valid, internal, group-best
      Received Path ID 0, Local Path ID 0, version 0
  Path #4: Received by speaker 0
  Not advertised to any peer
  65004 65002, (received-only)
    10.3.6.6 (metric 101) from 10.0.0.3 (10.0.0.3)
      Origin IGP, localpref 100, valid, internal
      Received Path ID 0, Local Path ID 0, version 0

Step by step:

STEPDifference between the two pathsBestWhy it was decided there
0Only the path via R2 has weight 100via R2WEIGHT is compared first, so the LOCAL_PREF of 200 on the path via R3 is never looked at
1Both have weight 100, the path via R3 has localpref 200via R3WEIGHT is now equal, so LOCAL_PREF decides
2Both have localpref 200via R2AS_PATH is 65002 (one AS) against 65004 65002 (two)
3as-path ignore stops the length comparisonvia R3ORIGIN is IGP (R5 originates with network) against Incomplete (R4 with redistribute static)
4R4 also switches to network, levelling ORIGINvia R2MED is not compared on R1: the neighboring AS is 65002 via R2 but 65004 via R3. The next step, the IGP metric, is (metric 2) against (metric 101)
5OSPF cost 100 on R1 - R2 as well, so both are (metric 101)via R2The Router ID 10.0.0.2 is lower than 10.0.0.3

Forwarding follows the best path: in STEP 0 the traffic leaves through R2, in STEP 1 through R3.

R1 ping / traceroute (STEP 0)
RP/0/RP0/CPU0:R1#ping 192.168.100.1 source 192.168.1.1 count 50 timeout 1
Wed Sep 23 12:10:17.621 UTC
Type escape sequence to abort.
Sending 50, 100-byte ICMP Echos to 192.168.100.1 timeout is 1 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Success rate is 100 percent (50/50), round-trip min/avg/max = 8/14/75 ms
RP/0/RP0/CPU0:R1#traceroute 192.168.100.1 source 192.168.1.1 probe 3 timeout 1 maxttl 6
Wed Sep 23 12:10:19.958 UTC

Type escape sequence to abort.
Tracing the route to 192.168.100.1

 1  10.1.2.2 7 msec  5 msec  5 msec 
 2  10.2.4.4 24 msec  10 msec  9 msec 
 3  10.4.5.5 11 msec  *  11 msec 
R1 ping / traceroute (STEP 1)
RP/0/RP0/CPU0:R1#ping 192.168.100.1 source 192.168.1.1 count 50 timeout 1
Wed Sep 23 12:17:14.977 UTC
Type escape sequence to abort.
Sending 50, 100-byte ICMP Echos to 192.168.100.1 timeout is 1 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Success rate is 100 percent (50/50), round-trip min/avg/max = 7/10/23 ms
RP/0/RP0/CPU0:R1#traceroute 192.168.100.1 source 192.168.1.1 probe 3 timeout 1 maxttl 6
Wed Sep 23 12:17:16.475 UTC

Type escape sequence to abort.
Tracing the route to 192.168.100.1

 1  10.1.3.3 10 msec  4 msec  4 msec 
 2  10.3.6.6 11 msec  47 msec  8 msec 
 3  10.5.6.5 12 msec  *  18 msec 

On R2, Which Receives Two Paths From the Same Neighboring AS, MED Applies

R2 receives the same prefix from R4 and R5 in AS 65002. Because the neighboring AS is the same, MED is compared.

R2 show bgp 192.168.100.0/24 (STEP 0)
RP/0/RP0/CPU0:R2#show bgp 192.168.100.0/24
Wed Sep 23 12:11:09.060 UTC
BGP routing table entry for 192.168.100.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                  7            7
Last Modified: Sep 23 11:33:33.023 for 00:37:36
Paths: (2 available, best #1)
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.1        
  Path #1: Received by speaker 0
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.1        
  65002, (received & used)
    10.2.4.4 from 10.2.4.4 (10.0.0.4)
      Origin incomplete, metric 100, localpref 100, weight 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 7
      Origin-AS validity: (disabled)
  Path #2: Received by speaker 0
  Not advertised to any peer
  65002, (received & used)
    10.2.5.5 from 10.2.5.5 (10.0.0.5)
      Origin IGP, metric 200, localpref 100, valid, external
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)
R2 show bgp 192.168.100.0/24 (STEP 6)
RP/0/RP0/CPU0:R2#show bgp 192.168.100.0/24
Wed Sep 23 12:53:08.026 UTC
BGP routing table entry for 192.168.100.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 16           16
Last Modified: Sep 23 12:50:16.023 for 00:02:52
Paths: (3 available, best #1)
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.1        
  Path #1: Received by speaker 0
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.1        
  65002, (received & used)
    10.2.4.4 from 10.2.4.4 (10.0.0.4)
      Origin IGP, metric 100, localpref 100, weight 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 12
      Origin-AS validity: (disabled)
  Path #2: Received by speaker 0
  Not advertised to any peer
  65002
    10.2.5.5 from 10.2.5.5 (10.0.0.5)
      Origin IGP, metric 200, localpref 100, weight 100, valid, external
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)
  Path #3: Received by speaker 0
  Not advertised to any peer
  65002, (received-only)
    10.2.5.5 from 10.2.5.5 (10.0.0.5)
      Origin IGP, metric 200, localpref 100, valid, external
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)
R2 show bgp 192.168.100.0/24 (STEP 7)
RP/0/RP0/CPU0:R2#show bgp 192.168.100.0/24
Wed Sep 23 13:00:01.970 UTC
BGP routing table entry for 192.168.100.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 16           16
Last Modified: Sep 23 12:50:16.023 for 00:09:46
Paths: (2 available, best #1)
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.1        
  Path #1: Received by speaker 0
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.1        
  65002, (received & used)
    10.2.4.4 from 10.2.4.4 (10.0.0.4)
      Origin IGP, metric 100, localpref 100, weight 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 12
      Origin-AS validity: (disabled)
  Path #2: Received by speaker 0
  Not advertised to any peer
  65002, (received & used)
    10.2.5.5 from 10.2.5.5 (10.0.0.5)
      Origin IGP, metric 100, localpref 100, weight 100, valid, external
      Received Path ID 0, Local Path ID 0, version 0
      Origin-AS validity: (disabled)

In STEP 0 the weight 100 toward R4 decides and the MED values (100 and 200) are never looked at. Levelling WEIGHT in STEP 6 makes MED the deciding criterion, and levelling MED in STEP 7 leaves only step (9) onward.

Steps (9) keep the existing best path, (11) CLUSTER_LIST length and (12) neighbor IP address were not observed in this verification. STEP 8 was meant to reset R2’s session to see (9), but clear bgp ipv4 unicast 10.2.4.4 returned % Incomplete command. on IOS XR 26.1.1 and never ran. Even if it had, R4’s Router ID (10.0.0.4) is lower than R5’s (10.0.0.5) in this topology, so (9) and (10) could not be told apart. Step (9) is observed on real devices in BGP AS_PATH Attribute, which follows STEP by STEP how the best path does not return after an AS_PATH prepend is added and then removed.

COMMUNITY Crosses Two ASes

COMMUNITY is optional transitive, so a router that supports it passes it on across AS boundaries. Only R2 in AS 65001 attaches it.

R7 show bgp 192.168.2.0/24 (STEP 9)
RP/0/RP0/CPU0:R7#show bgp 192.168.2.0/24
Wed Sep 23 13:17:17.693 UTC
BGP routing table entry for 192.168.2.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                  6            6
Last Modified: Sep 23 11:33:33.023 for 01:43:44
Paths: (1 available, best #1)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002 65001, (received & used)
    10.4.7.4 from 10.4.7.4 (10.0.0.4)
      Origin IGP, localpref 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 6
      Origin-AS validity: (disabled)
R7 show bgp 192.168.2.0/24 (STEP 10)
RP/0/RP0/CPU0:R7#show bgp 192.168.2.0/24
Wed Sep 23 13:24:19.299 UTC
BGP routing table entry for 192.168.2.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 10           10
Last Modified: Sep 23 13:17:56.023 for 00:06:23
Paths: (1 available, best #1)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002 65001, (received & used)
    10.4.7.4 from 10.4.7.4 (10.0.0.4)
      Origin IGP, localpref 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 10
      Community: 65001:100
      Origin-AS validity: (disabled)
R7 show bgp 192.168.2.0/24 (STEP 11)
RP/0/RP0/CPU0:R7#show bgp 192.168.2.0/24
Wed Sep 23 13:31:14.786 UTC
BGP routing table entry for 192.168.2.0/24
Versions:
  Process           bRIB/RIB   SendTblVer
  Speaker                 13           13
Last Modified: Sep 23 13:24:56.023 for 00:06:18
Paths: (1 available, best #1)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002 65001, (received & used)
    10.4.7.4 from 10.4.7.4 (10.0.0.4)
      Origin IGP, localpref 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 13
      Origin-AS validity: (disabled)

It does not arrive until STEP 9 because R4 has no send-community-ebgp toward R7. Adding it in STEP 10 carries the value all the way to R7, and when R2 stops sending in STEP 11 it disappears. Whether an attribute is transitive and whether an implementation sends it are two different things. IOS XR and IOS XE suppress sending COMMUNITY to eBGP peers by default (send-community-ebgp on IOS XR, send-community on IOS XE).

Verification Configs and show Output

Each STEP captures the following files from all seven routers, one file per router and kind. The verification config is the ..._run.txt (final state: STEP 11).

FileContents
..._show.txtshow version / show interface description / show route / show bgp / show bgp summary / show route bgp / show bgp for 192.168.100.0/24, 192.168.1.0/24 and 192.168.2.0/24 / show bgp neighbors / per-peer advertised-routes, routes and received routes / show bgp update-group / show bgp process / show rpl route-policy. R1 to R3 also include show ospf neighbor / show route ospf; R1 also includes show route 192.168.100.0/24 / show cef 192.168.100.0/24
..._log.txtshow logging limited to that STEP
..._run.txtshow running-config at that STEP (the verification config for that STEP)
..._ping.txt50 pings and a traceroute from R1 to 192.168.100.1, and pings from R7 to 192.168.1.1
..._trace.txtshow bgp trace neighbor and show bgp trace error
..._commit.cfgThe configuration actually committed in that STEP (only the routers that were changed)
..._exec.txtThe clear command and its time in that STEP (R2 in STEP 8)

STEP 0: none (initial state)

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtrace—
R2showlogrun—trace—
R3showlogrun—trace—
R4showlogrun—trace—
R5showlogrun—trace—
R6showlogrun—trace—
R7showlogrunpingtrace—

STEP 1: weight 100 on R1’s R3 neighbor as well

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtracecommit
R2showlogrun—trace—
R3showlogrun—trace—
R4showlogrun—trace—
R5showlogrun—trace—
R6showlogrun—trace—
R7showlogrunpingtrace—

STEP 2: set local-preference 200 in R1’s FROM-R2 as well

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtracecommit
R2showlogrun—trace—
R3showlogrun—trace—
R4showlogrun—trace—
R5showlogrun—trace—
R6showlogrun—trace—
R7showlogrunpingtrace—

STEP 3: bgp bestpath as-path ignore on R1

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtracecommit
R2showlogrun—trace—
R3showlogrun—trace—
R4showlogrun—trace—
R5showlogrun—trace—
R6showlogrun—trace—
R7showlogrunpingtrace—

STEP 4: R4 switches to network, levelling ORIGIN

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtrace—
R2showlogrun—trace—
R3showlogrun—trace—
R4showlogrun—tracecommit
R5showlogrun—trace—
R6showlogrun—trace—
R7showlogrunpingtrace—

STEP 5: OSPF cost 100 on R1 - R2 as well, levelling the metric

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtracecommit
R2showlogrun—trace—
R3showlogrun—trace—
R4showlogrun—trace—
R5showlogrun—trace—
R6showlogrun—trace—
R7showlogrunpingtrace—

STEP 6: weight 100 on R2’s R5 neighbor as well

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtrace—
R2showlogrun—tracecommit
R3showlogrun—trace—
R4showlogrun—trace—
R5showlogrun—trace—
R6showlogrun—trace—
R7showlogrunpingtrace—

STEP 7: MED 100 in R5’s TO-R2 as well, levelling MED

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtrace—
R2showlogrun—trace—
R3showlogrun—trace—
R4showlogrun—trace—
R5showlogrun—tracecommit
R6showlogrun—trace—
R7showlogrunpingtrace—

STEP 8: clear bgp ipv4 unicast 10.2.4.4 on R2

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtrace—
R2showlogrun—traceexec
R3showlogrun—trace—
R4showlogrun—trace—
R5showlogrun—trace—
R6showlogrun—trace—
R7showlogrunpingtrace—

STEP 9: bgp bestpath compare-routerid on R2

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtrace—
R2showlogrun—tracecommit
R3showlogrun—trace—
R4showlogrun—trace—
R5showlogrun—trace—
R6showlogrun—trace—
R7showlogrunpingtrace—

STEP 10: send-community-ebgp on R4 (toward R7)

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtrace—
R2showlogrun—trace—
R3showlogrun—trace—
R4showlogrun—tracecommit
R5showlogrun—trace—
R6showlogrun—trace—
R7showlogrunpingtrace—

STEP 11: remove send-community-ebgp from R2 (final state)

Routershow outputsyslogrunning-configpingtraceCommitted config
R1showlogrunpingtrace—
R2showlogrun—tracecommit
R3showlogrun—trace—
R4showlogrun—trace—
R5showlogrun—trace—
R6showlogrun—trace—
R7showlogrunpingtrace—

Packet captures were taken per STEP.

STEPR1 - R2 (iBGP)R2 - R4 (eBGP)R4 - R7 (eBGP)
0pcappcappcap
1pcappcappcap
2pcappcappcap
3pcappcappcap
4pcappcappcap
5pcappcappcap
6pcappcappcap
7pcappcappcap
8pcappcappcap
9pcappcappcap
10pcappcappcap
11pcappcappcap

References

SourceTitleSummary
RFC 4271A Border Gateway Protocol 4 (BGP-4)Defines the four categories of path attributes (section 5), the degree of preference from LOCAL_PREF (9.1.1) and the tie-breaking procedure (9.1.2.2).
RFC 7606Revised Error Handling for BGP UPDATE MessagesAssigns per-attribute handling for malformed attributes (attribute discard / treat-as-withdraw / session reset).
RFC 1997BGP Communities AttributeDefines the COMMUNITY attribute.
RFC 4360BGP Extended Communities AttributeDefines the EXTENDED COMMUNITIES attribute.
RFC 4456BGP Route ReflectionDefines ORIGINATOR_ID and CLUSTER_LIST and their impact on route selection (section 9).
RFC 4760Multiprotocol Extensions for BGP-4Defines MP_REACH_NLRI and MP_UNREACH_NLRI.
RFC 6793BGP Support for Four-Octet AS Number SpaceDefines AS4_PATH and AS4_AGGREGATOR.
RFC 8092BGP Large Communities AttributeDefines the LARGE_COMMUNITY attribute.
IANABorder Gateway Protocol (BGP) ParametersRegistry of numbers used in BGP, including path attribute type codes.

Related Articles