Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

BGP Best-Path Reference

Direct answer

BGP selects one best path (plus extra multipath routes if configured) from the valid candidates for a prefix by comparing attributes in a fixed order, then offers it to the routing table, where administrative distance decides between route sources.

When to use this

Use it when multiple BGP paths exist but an unexpected path is selected or installed.

First 30 seconds

1. Confirm valid candidates. 2. Check next hop. 3. Read local policy. 4. Walk best-path criteria. 5. Verify RIB/FIB.

Operational verification

prefix received → path valid (NEXT_HOP, inbound policy) → best path → RIB (no rib-failure) → CEF/adjacency → traffic and return path

Context & applicabilityCommon mistakes · platform/version boundaries
Common mistakes
Interpretation traps: origin, local preference and distance

The trailing i in an AS_PATH display is ORIGIN IGP; it does not mean the route was learned through iBGP or that OSPF carried it. Incomplete origin (?) commonly results from redistribution and does not by itself make a path invalid.

LOCAL_PREF is compared before AS_PATH. A longer AS path can therefore win deliberately, and AS-path prepending cannot override a higher local preference. Weight is earlier still. The default LOCAL_PREF is normally 100; a missing value in a compact display is not evidence of a configured zero.

BGP's eBGP-over-iBGP criterion and IP administrative distance are separate. An iBGP path with a higher LOCAL_PREF can win inside BGP before that criterion is reached. Default IP distances of eBGP 20 and iBGP 200 do not mean the IP RIB independently chooses among every unselected BGP alternative.

Forwarding uses the longest matching installed prefix. A /25 from another source can take traffic even while the expected /24 remains BGP best. Check the actual destination lookup.

Platform / version applicability
Protocol standard + deployed implementation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformProtocol standard · Cisco IOS XE · IOS/IOS XE
Key commandshow ip cef [prefix]
Scope / prerequisiteUse it when multiple BGP paths exist but an unexpected path is selected or installed.
Show · 1
What next?3 suggested next steps
Catalog command links1
Evidence1
On this pageJump to a specific section
Verification

Show Commands

Read-only Cisco show commands for confirming state, narrowing a fault and interpreting the current boundary.

How to read the output

show ip cef [prefix]

Look first: prefix adjacency/next hop and egress interface

Healthy: CEF resolves the prefix to the intended adjacency.

Warning: Drop/punt/unresolved adjacency or unexpected egress.

Does not prove: A CEF entry does not prove downstream reachability or return path.

Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verify one exact prefix before comparing attributes Verify boundary

On the router making the decision, begin with:

show ip bgp summary
show ip bgp 203.0.113.0 255.255.255.0
show ip bgp neighbors 192.0.2.2
show ip bgp neighbors 192.0.2.6
show running-config | section router bgp
show route-map IMPORT-R2
show route-map IMPORT-R3

Fix the prefix length, router, address family and observation time. Confirm that both lab peers are Established and activated for IPv4, then inspect every accepted path for this /24. Record the peer address separately from NEXT_HOP, weight, local preference, AS_PATH, origin and MED.

Read the attached inbound policy rather than inferring it from a route-map's name. Inspect configured bgp bestpath, MED and multipath options before applying the baseline decision order. The first applicable attribute difference explains the selection; later tie-breaks do not overturn an earlier winner.

Step 2 Verify selection, reapply policy and prove forwarding Verify boundary

After convergence, inspect both accepted paths and the selected exit on R1:

show ip bgp 203.0.113.0 255.255.255.0
show ip route 203.0.113.0 255.255.255.0
show ip bgp rib-failure
show ip cef 203.0.113.1 detail
ping 203.0.113.1 source Loopback0

Expect LOCAL_PREF 200 through 192.0.2.2, BGP best via R2, the /24 in the IP RIB through R2, resolved CEF forwarding and a successful source-10.0.0.1 ping. Check both providers' RIB entries for 10.0.0.1/32 to establish the alternate return path too.

For an existing session whose inbound policy changes, first inspect show ip bgp neighbors 192.0.2.2 for negotiated route-refresh capability or retained inbound data. With route refresh supported, clear ip bgp 192.0.2.2 soft in requests reprocessing of that neighbor's inbound routes without a hard session reset. Then read the attributes for the exact /24 again. Do not assume a route-map edit has already changed accepted path attributes.

On each sender, inspect the appropriate show ip bgp neighbors <peer-address> advertised-routes; on the receiver inspect accepted routes. A sender-side advertisement view does not show the receiver accepted it. Route-map packet counters alone do not establish BGP-policy application.

Step 3 Missing candidate versus losing candidate Narrow the fault

If the peer is not Established, diagnose addressing, TCP/179, remote AS and session state first. If it is Established but the /24 is absent, inspect IPv4 activation, the sender's exact origination route and outbound policy, then local inbound filters.

A route rejected by import policy or AS-loop checks is not an accepted candidate waiting to lose on local preference. A visible path with an inaccessible NEXT_HOP is not rescued by setting a larger preference. Check show ip route for that next-hop address and the path's validity flags.

show ip bgp neighbors 192.0.2.2 routes shows accepted neighbor routes. received-routes is a separate pre-policy view whose availability depends on retained inbound data, commonly soft-reconfiguration inbound. An unavailable received-routes view does not establish that the peer sent nothing. Compare the sender's advertised-routes and the receiver's accepted prefix state.

Step 4 The selected exit is unexpected: locate the first difference Narrow the fault

1. Does the exact /24 have two accepted, valid paths? If not, stop at session, origination, filtering or next-hop resolution.

2. Does one path have higher weight? A neighbor-wide weight or route-map can override the local-preference lab result on this router.

3. Are weights equal but local preferences different? In the lab, 200 through R2 beats 100 through R3 before AS_PATH, MED or path age matters.

4. If preferences tie, compare the remaining applicable selection criteria and their configured exceptions. Do not compare MED across different neighboring ASes by default.

5. If BGP selects the intended exit, compare show ip route 203.0.113.0 255.255.255.0 and show ip bgp rib-failure. An unexpected IP RIB source is a separate decision.

6. If RIB and CEF agree, check the actual test destination, more-specific routes, policy-based routing, resolved adjacency and the return path. An outbound policy on an unrelated peer cannot directly change the imported local preference.

Step 5 RIB failure, failover and rollback Narrow the fault

If BGP has a best path but show ip bgp rib-failure reports a higher administrative distance, inspect the exact IP prefix for a connected, static or other preferred source. Do not alter LOCAL_PREF to fix that different decision. Also inspect recursive NEXT_HOP reachability; a usable session address is not necessarily a usable advertised next hop. RIB failure does not by itself show that the path cannot be advertised to another peer; outbound behavior and settings such as bgp suppress-inactive require separate inspection.

In the isolated lab, administratively shut only R1's R2 neighbor using neighbor 192.0.2.2 shutdown under router bgp 65000. After convergence, require the /24's BGP best, RIB and CEF to move to 192.0.2.6 with LOCAL_PREF 100. Repeat the loopback-sourced ping. Restore with no neighbor 192.0.2.2 shutdown; after the peer returns, preference 200 should select R2 again. Record observed transition times rather than asserting a fixed failover time.

Check the negative boundary: neither provider should receive the other provider's /24 from R1. An unlisted test prefix must fail the import/export allowlist in a disposable lab; retain the intended return /32. Do not widen the filters to obtain a successful ping.

For an existing deployment, save router configuration and policy definitions before a change, then restore the exact previous attachment and values for rollback. In a clean lab, lowering IMPORT-R2's local preference from 200 to 100 and reapplying inbound policy restores equal preference, not a guaranteed winner; later criteria then apply. Remove lab objects only after their references are detached.

Sources: Cisco IOS XE provider-policy configuration, Cisco soft reconfiguration, and RFC 4271 sections 5.1.5 and 9.1. Configuration and expected output remain reference guidance; historical Evidence, review and verification dates are unchanged.

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Command lookup Jump straight to Cisco syntax
Key checks

show bgp <prefix> → candidate/best path reason. show ip route <prefix> → RIB. show ip cef <prefix> → forwarding.

ReferenceWhat it is1 section · depth on demand

BGP best path, RIB selection and forwarding are separate decisions

BGP compares eligible paths to the same prefix and mask after import policy has acted. It chooses a best path, and may nominate additional paths for multipath installation. The IP routing table then selects among route sources for that exact prefix; CEF resolves the installed route into forwarding state.

For one destination, trace received advertisement → accepted/usable BGP path → BGP best → IP RIB → CEF/adjacency → packet and return path. Established shows a session, not receipt of this prefix. A best marker does not guarantee RIB installation, and a route entry does not establish that its next hop forwards packets.

Scope: Cisco IOS XE, IPv4 unicast in the global table. The baseline below assumes no confederation, AIGP, cost-community policy or best-path overrides. VPN address families and other vendors require their own selection rules. The lab is authored reference material; no device execution or captured Evidence is claimed.

ReferenceWhy it matters1 section · depth on demand

Express an exit policy that survives a session change

A dual-homed router may receive the same destination from two providers. Decide whether the intended preference is local to one router or shared within the AS before choosing a policy tool. Weight is Cisco-local to one router; LOCAL_PREF expresses an AS-internal preference and is normally propagated through iBGP, not ordinary eBGP.

This lab uses LOCAL_PREF to make R2 the primary exit and R3 the alternate for one /24. It also filters exports so R1 does not become transit between the two lab providers. The expected outcome is a predictable selected exit and working failover, with return routing tested explicitly. Egress preference alone does not control how a remote AS sends traffic back.

ReferenceHow it works1 section · depth on demand

Baseline selection order for eligible IOS XE paths

For the stated baseline, compare in order and stop at the first applicable difference:

1. Higher weight.

2. Higher LOCAL_PREF.

3. Local origination; among local sources, network/redistribution precedes aggregation.

4. Shorter AS_PATH.

5. Lower ORIGIN: IGP, then EGP, then incomplete.

6. Lower MED when comparable.

7. eBGP before iBGP.

8. Lower IGP cost to NEXT_HOP.

9. Evaluate configured multipath eligibility.

10. For tied external paths, older path, subject to exceptions such as compare-routerid.

11. Lower router ID; reflected paths use ORIGINATOR_ID where applicable.

12. Shorter CLUSTER_LIST when relevant.

13. Lower neighbor address.

AIGP can be considered before AS_PATH when enabled. This is a scoped IOS XE reference, not a universal RFC ordering. Consult Cisco's selection algorithm for detailed conditions. In a comparison, distinguish an inapplicable criterion from two equal values.

ReferenceImportant terms & boundaries3 sections · depth on demand

Lab topology, inputs and expected selection

Use three isolated IOS XE routers and documentation addresses. R1, AS 65000, connects to R2, AS 65010, over 192.0.2.0/30 and R3, AS 65020, over 192.0.2.4/30. R1 uses .1 toward R2 (.2), and .5 toward R3 (.6).

R1 owns Loopback0 10.0.0.1/32 and exports only that return-test prefix. Both R2 and R3 independently own Loopback0 203.0.113.1/24 and originate 203.0.113.0/24. The duplicated loopback address is intentional in this isolated selection lab: either exit can answer the same destination. Do not deploy duplicate ownership as a production addressing plan.

R1 imports only the test /24, assigning LOCAL_PREF 200 from R2 and 100 from R3. Both paths should be valid with weight 0; R2 wins by local preference. Each provider imports only R1's /32 and exports only its own /24. No default, IGP or broad redistribution is required. Confirm IP forwarding and unfiltered lab links first.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

In depth

BGP best-path selection runs per prefix whenever paths change: BGP collects all valid candidate paths, compares them pairwise with the ordered attribute list, marks one as best, and offers it to the RIB, where administrative distance may still prefer another source. With multipath configured, equal paths after the comparison are installed together.

StageWhat can stop a path
ValidityUnreachable NEXT_HOP, AS loop, inbound policy deny
ComparisonLower weight/LOCAL_PREF, longer AS_PATH, etc.
RIB installationLower-AD route for the same prefix (RIB-failure)
AdvertisementOutbound policy, iBGP split-horizon

When a path is not used, find which of these four stages removed it before changing attributes.

MED, multipath and algorithm overrides

MED is conditional: by default compare it for paths whose first neighboring AS is the same. The lab peers are in AS 65010 and AS 65020, so their MED values do not normally select the winner. IOS XE ordinarily treats absent MED as 0; bgp bestpath med missing-as-worst changes that treatment. bgp always-compare-med changes comparison scope, while bgp deterministic-med groups comparisons by neighboring AS. These settings are different controls and should be evaluated consistently across the AS.

maximum-paths does not make unequal paths equal. BGP multipath has attribute and path-eligibility requirements, and eBGP/iBGP settings differ. AS-path multipath relaxation changes eligibility rather than granting every learned route a forwarding share. Verify actual next-hop installation in both RIB and CEF; the normal best-path marker still exists.

AIGP, cost communities and bgp bestpath overrides can change the baseline. Route-reflector originator/cluster attributes also affect loop prevention and late tie-breaking. Read effective configuration and the platform's documented algorithm before explaining a production exception.

ReferenceConfiguration & state1 section · depth on demand

Configure the three-router LOCAL_PREF lab

Start with clean lab devices and unused policy names. Enter from global configuration mode. no bgp default ipv4-unicast makes address-family activation explicit.

R1:

ip prefix-list LAB-DST seq 10 permit 203.0.113.0/24
ip prefix-list LAB-RETURN seq 10 permit 10.0.0.1/32
route-map IMPORT-R2 permit 10
 match ip address prefix-list LAB-DST
 set local-preference 200
route-map IMPORT-R3 permit 10
 match ip address prefix-list LAB-DST
 set local-preference 100
!
interface GigabitEthernet0/0
 ip address 192.0.2.1 255.255.255.252
 no shutdown
interface GigabitEthernet0/1
 ip address 192.0.2.5 255.255.255.252
 no shutdown
interface Loopback0
 ip address 10.0.0.1 255.255.255.255
!
router bgp 65000
 bgp router-id 1.1.1.1
 no bgp default ipv4-unicast
 neighbor 192.0.2.2 remote-as 65010
 neighbor 192.0.2.6 remote-as 65020
 address-family ipv4 unicast
  network 10.0.0.1 mask 255.255.255.255
  neighbor 192.0.2.2 activate
  neighbor 192.0.2.2 route-map IMPORT-R2 in
  neighbor 192.0.2.2 prefix-list LAB-RETURN out
  neighbor 192.0.2.6 activate
  neighbor 192.0.2.6 route-map IMPORT-R3 in
  neighbor 192.0.2.6 prefix-list LAB-RETURN out
 exit-address-family

R2:

ip prefix-list LAB-DST seq 10 permit 203.0.113.0/24
ip prefix-list LAB-RETURN seq 10 permit 10.0.0.1/32
interface GigabitEthernet0/0
 ip address 192.0.2.2 255.255.255.252
 no shutdown
interface Loopback0
 ip address 203.0.113.1 255.255.255.0
!
router bgp 65010
 bgp router-id 2.2.2.2
 no bgp default ipv4-unicast
 neighbor 192.0.2.1 remote-as 65000
 address-family ipv4 unicast
  network 203.0.113.0 mask 255.255.255.0
  neighbor 192.0.2.1 activate
  neighbor 192.0.2.1 prefix-list LAB-RETURN in
  neighbor 192.0.2.1 prefix-list LAB-DST out
 exit-address-family

R3:

ip prefix-list LAB-DST seq 10 permit 203.0.113.0/24
ip prefix-list LAB-RETURN seq 10 permit 10.0.0.1/32
interface GigabitEthernet0/0
 ip address 192.0.2.6 255.255.255.252
 no shutdown
interface Loopback0
 ip address 203.0.113.1 255.255.255.0
!
router bgp 65020
 bgp router-id 3.3.3.3
 no bgp default ipv4-unicast
 neighbor 192.0.2.5 remote-as 65000
 address-family ipv4 unicast
  network 203.0.113.0 mask 255.255.255.0
  neighbor 192.0.2.5 activate
  neighbor 192.0.2.5 prefix-list LAB-RETURN in
  neighbor 192.0.2.5 prefix-list LAB-DST out
 exit-address-family

The network statements require exact RIB prefix/mask matches. Prefix-lists without ge/le permit only the listed lengths; both route-maps implicitly reject unmatched prefixes. R1's outbound list prevents provider-to-provider transit. On a routed switch, enable IP routing and use routed ports as required. Existing production policies need a deliberate integration plan rather than replacement with these lab snippets.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docProtocol standard + deployed implementation RFC 4271

Authoritative/upstream documentation reviewed for bounded claims in Network & Protocols → BGP Best-Path Reference. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.rfc-editor.org/rfc/rfc4271.html · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
bgp best pathbestpathbgp path selectionwhy bgp route
Embedded quick reference

Operational notes

Former standalone Cheat Sheet content now lives directly inside the Topic where it belongs.

BGP Best-Path Fast Check

Candidate → best → RIB → FIB.

1. show bgp <prefix> → list candidates.

2. Verify NEXT_HOP reachability.

3. Check policy-modified attributes.

4. Read best-path reason.

5. show ip route <prefix> → did RIB install it?

6. show ip cef <prefix> → forwarding.

BGP-best ≠ necessarily RIB-installed.

Depth when you need it

Deep reference

Healthy vs suspicious evidence

Read the best-path and RIB output

Illustrative excerpts only, not captured lab or production Evidence. On R1 after the lab policy is applied:

BGP routing table entry for 203.0.113.0/24
Paths: (2 available, best #1, table default)
  65010
    192.0.2.2 from 192.0.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 200, valid, external, best
  65020
    192.0.2.6 from 192.0.2.6 (3.3.3.3)
      Origin IGP, metric 0, localpref 100, valid, external

Both paths are valid; only the first is best because LOCAL_PREF differs before later criteria. metric 0 here is MED, not administrative distance or IGP cost. from identifies the advertising peer, the preceding address is NEXT_HOP, and the parenthesized value is the peer's BGP router ID. They coincide with directly connected peers in this lab but need not in iBGP/RR designs. Path numbers and output formatting can vary.

A compact table's * means valid and > means best. An r flag indicates RIB failure: inspect show ip bgp rib-failure and the actual IP route. If the lab BGP route wins the RIB, a compact IP route can resemble:

B 203.0.113.0/24 [20/0] via 192.0.2.2

[20/0] is administrative distance/BGP route metric, not LOCAL_PREF 20 or zero AS hops. The AS_PATH contains 65010 even though the IP route metric is 0. Confirm CEF separately.

Confirmation

Confirm action

Continue?