Use it when BGP picks an unexpected exit for a prefix, or when you need to know which attribute to change to make a path win.
Best Path
BGP compares the valid paths for a prefix in a fixed order and stops at the first difference. Cisco order: highest Weight, highest LOCAL_PREF, locally originated, shortest AS_PATH, lowest ORIGIN (IGP < EGP < incomplete), lowest MED, eBGP over iBGP, lowest IGP metric to NEXT_HOP, then tie-breakers (oldest eBGP path, lowest router ID, shortest CLUSTER_LIST, lowest neighbour address).
1. show ip bgp <prefix> — the path marked best.
2. Compare paths in order: weight, LOCAL_PREF, local origin, AS_PATH, origin, MED, eBGP over iBGP, IGP cost.
3. show ip route <prefix> — confirm it was installed.
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
show ip bgp 203.0.113.0 255.255.255.0Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 First 30 seconds Verify boundary
Immediate answer: Inspect all paths for one prefix and compare policy-modified attributes before changing global BGP settings.
Verification chain: received path → inbound policy → path attributes → best-path decision → RIB eligibility → FIB/next-hop → traffic
Stop condition: The BGP best path is only BGP's selected candidate; it can still lose RIB installation or fail next-hop forwarding.
Step 2 Operational verification and known-good state Verify boundary
Verify one exact prefix on the router that makes the decision:
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.0 255.255.255.0 detail
In the BGP output, read the paths side by side: Weight, localpref, AS_PATH, Origin (i/e/?), metric (= MED), external/internal and the IGP metric to the next hop. Walk the order and stop at the first value that differs — that is why the best path won. Then confirm that the routing table shows the prefix as BGP via the same next hop, and that CEF resolves that next hop to an outgoing interface and adjacency.
Known-good: one path is marked best, the first differing attribute is the one your design intended to decide, the RIB entry is source B via that path's NEXT_HOP, and CEF forwards out the expected interface.
Step 3 Verification and output interpretation Verify boundary
Compare all candidate paths for the exact prefix and read the best-path reason where available. Verify the decisive attribute rather than assuming the shortest AS_PATH wins. Then check whether the best path is installed in the RIB and whether its NEXT_HOP resolves. If policy was changed, compare before/after path attributes and advertisements to ensure the intended scope changed and unrelated prefixes did not.
Step 4 Verification & troubleshooting Narrow the fault
Compare all candidate paths for the same prefix in order. Stop at the first attribute that differs and is actually eligible for comparison, then verify the selected path reaches the RIB.
Step 5 Failure signatures and troubleshooting branches Narrow the fault
Typical surprises and where to look:
- The longer AS_PATH won. Compare Weight and LOCAL_PREF first — an inbound route-map or
neighbor … weightusually decides before AS_PATH is reached. - MED seems ignored. The paths come from different neighbouring ASes. MED is only compared within the same neighbouring AS unless
bgp always-compare-medis set consistently across the AS;bgp deterministic-medchanges how paths are grouped. - Path missing from the comparison. It is not a losing candidate but an invalid one: check
show ip route <next-hop>for NEXT_HOP reachability (common with iBGP withoutnext-hop-self), inbound filters and AS-loop rejection. - BGP best path is not in the routing table.
show ip bgp rib-failureshows a lower-AD route (connected, static, OSPF) for the same prefix. That is a RIB decision; changing BGP attributes will not fix it. - Different routers pick different exits. IGP metric to NEXT_HOP (step 9) differs per router, and route reflectors only reflect their own best path, so clients may not see every candidate.
- Result changes after a reload or flap. Step 11 (oldest eBGP path) depends on arrival order. Use
bgp bestpath compare-routeridif you need deterministic results.
Change the attribute whose scope matches the intent — LOCAL_PREF for AS-wide outbound preference, Weight only for one router — rather than stacking several.
Step 6 When the problem is really fixed Narrow the fault
A best-path change is done when, on the deciding router:
1. All expected candidate paths are present and valid.
2. The intended path carries the best marker, and the first differing attribute is the one your policy set.
3. show ip route lists that path's NEXT_HOP, and show ip bgp rib-failure is empty for the prefix.
4. show ip cef resolves the prefix to the expected interface, and a sourced ping or traceroute takes that exit.
5. Other prefixes covered by the same route-map did not change unexpectedly (compare before/after show ip bgp for a sample).
If the change was meant for failover, shut the preferred neighbour once, confirm the alternate path becomes best and installed, then restore it. Remember that outbound preference does not control the return path; check it separately.
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.
The first differing attribute decides — a higher LOCAL_PREF beats any AS_PATH length, and MED is only compared between paths from the same neighbouring AS. A BGP best path can still lose the routing table to a route with lower administrative distance (RIB-failure).
show ip bgp <prefix> → all paths and the best marker. show ip route <prefix> and show ip bgp rib-failure → did it reach the RIB. show ip cef <prefix> → forwarding.
ReferenceWhat it is2 sections · depth on demand
BGP scope — internal and external paths
BGP best-path selection compares eligible internal and external candidates using ordered attributes. First verify NEXT_HOP resolution and policy eligibility; then inspect Weight, LOCAL_PREF, local origination, AS_PATH length, ORIGIN, MED under its comparison rules, peer type and later tie breakers. Do not assume shortest AS_PATH always wins. RR best-path visibility and client-local IGP costs can differ, and a BGP best path need not win global RIB installation.
What it is
BGP best-path selection compares eligible paths using an ordered decision process. Cisco IOS / IOS XE includes Cisco-specific Weight before standard attributes such as LOCAL_PREF and AS_PATH.
ReferenceWhy it matters1 section · depth on demand
Why it matters
Use best-path analysis only after the peer is Established and the exact prefix is present with multiple usable candidates.
ReferenceHow it works1 section · depth on demand
Best path is an ordered decision
For one exact prefix, line up the candidate paths and compare them in the actual decision order. If Weight differs, later attributes are irrelevant for that decision. If Weight is equal but LOCAL_PREF differs, AS_PATH length still does not decide the winner. Continue only while earlier factors are equal.
ReferenceImportant terms & boundaries6 sections · depth on demand
Key points
Cisco IOS / IOS XE compares the valid paths for one prefix in this order and stops at the first difference:
higher Weight → higher LOCAL_PREF → locally originated (network/redistribute before aggregate) → AIGP (if enabled) → shorter AS_PATH → lower ORIGIN (IGP < EGP < incomplete) → lower MED (same neighbouring AS by default) → eBGP over iBGP → lower IGP metric to NEXT_HOP → multipath check → oldest eBGP path → lowest router ID → shortest CLUSTER_LIST → lowest neighbour address.
Two consequences matter in practice. First, a longer AS_PATH can win on purpose: LOCAL_PREF and Weight are checked before AS_PATH, so prepending can never override them. Second, MED is not a global metric — by default it is only compared between paths received from the same neighbouring AS.
In depth
How Cisco BGP picks one best path per prefix
Cisco's BGP best path selection document lists the order in which paths are compared. A path is only considered if its next hop is reachable. The first step that tells two paths apart decides.
| Step | Prefer | Scope |
|---|---|---|
| 1 | Highest weight | Cisco-specific, local to the router |
| 2 | Highest LOCAL_PREF | Whole AS (default 100) |
| 3 | Locally originated (network, aggregate-address, redistribution) | |
| 4 | Shortest AS_PATH | |
| 5 | Lowest origin: IGP < EGP < INCOMPLETE | |
| 6 | Lowest MED | Normally only between paths from the same neighbouring AS |
| 7 | eBGP over iBGP | |
| 8 | Lowest IGP metric to the next hop | |
| 9 | Multipath check (maximum-paths) | Installs several paths, but one is still the best |
| 10 | Oldest eBGP path | Avoids flapping |
| 11 | Lowest BGP router ID | |
| 12 | Shortest cluster list (route reflection) | |
| 13 | Lowest neighbour address |
R1# show ip bgp 203.0.113.0/24
BGP routing table entry for 203.0.113.0/24, version 412
Paths: (2 available, best #2, table default)
Advertised to update-groups:
1
Refresh Epoch 1
64510 64520
192.0.2.1 from 192.0.2.1 (198.51.100.1)
Origin IGP, metric 0, localpref 100, valid, external
Refresh Epoch 1
64511
192.0.2.5 from 192.0.2.5 (198.51.100.5)
Origin IGP, metric 0, localpref 100, valid, external, best
R1# show ip bgp 203.0.113.0/24 bestpath-reason
Path 2 wins on step 4: AS_PATH length 1 against 2. On recent IOS XE releases the bestpath-reason keyword shows the deciding step directly.
Practical rules
| Goal | Attribute to change |
|---|---|
| Choose the exit for traffic leaving the AS (outbound) | LOCAL_PREF (AS-wide) or weight (one router) |
| Influence how others send traffic in (inbound) | AS_PATH prepending, MED, or more-specific prefixes |
Common surprises
- A path that is "valid" but not "best" may lose on an attribute you didn't set, such as origin or the oldest-path rule.
- A next hop that isn't in the routing table makes the path unusable before the comparison even starts.
Documented example, not captured output.
Quick reference
BGP's best path is chosen by comparing attributes in order; the first difference decides. Only valid paths (reachable NEXT_HOP, not filtered) are compared.
show bgp ipv4 unicast 203.0.113.0/24
! Paths: (2 available, best #1)
! 64500 ... localpref 200, valid, external, best
! 64600 64500 ... localpref 100, valid, external
Documented example, not captured output.
| Common reason path #2 lost | Criterion |
|---|---|
| Lower Weight | Step 1 |
| Lower LOCAL_PREF | Step 2 |
| Longer AS_PATH | Step 5 |
| Higher MED (same neighbour AS) | Step 7 |
| iBGP vs eBGP | Step 8 |
| Higher IGP metric to NEXT_HOP | Step 9 |
Read the per-path lines side by side and walk the order; the first value that differs is the reason. Step numbers follow the table in Mechanics and state ownership.
Mechanics and state ownership
Best-path selection runs per prefix. BGP first discards paths that are not usable — unresolvable NEXT_HOP, denied by inbound policy or containing the local AS — and then compares the remaining candidates pairwise in a fixed order. The first criterion that differs decides; later criteria are never consulted for that pair.
| # | Criterion | Preferred | Note |
|---|---|---|---|
| 0 | Path valid | — | NEXT_HOP resolvable, not denied by inbound policy, no AS loop |
| 1 | Weight | Highest | Cisco-only, local to this router (default 0; 32768 for locally originated) |
| 2 | LOCAL_PREF | Highest | Shared inside the AS via iBGP (default 100) |
| 3 | Locally originated | Local | network/redistribute before aggregate-address |
| 4 | AIGP | Lowest | Only when AIGP is enabled |
| 5 | AS_PATH length | Shortest | AS_SET counts as 1; skipped with bgp bestpath as-path ignore |
| 6 | ORIGIN | IGP < EGP < incomplete | i / e / ? in the display |
| 7 | MED | Lowest | Only between paths from the same neighbouring AS unless bgp always-compare-med |
| 8 | Peer type | eBGP | Then confederation-external, then iBGP |
| 9 | IGP metric to NEXT_HOP | Lowest | Hot-potato exit |
| 10 | Multipath | — | With maximum-paths, equal paths are installed together; best path still chosen below |
| 11 | Oldest path | Oldest | eBGP paths only; skipped with bgp bestpath compare-routerid |
| 12 | Router ID | Lowest | ORIGINATOR_ID for reflected routes |
| 13 | CLUSTER_LIST length | Shortest | Route-reflector topologies |
| 14 | Neighbour address | Lowest | Final tie-breaker |
The criteria come in two groups. Steps 1–3 are policy: values you or a neighbour set on purpose (Weight, LOCAL_PREF, local origination). Steps 5–9 are topology: path length, origin, MED, peer type and internal distance to the exit. Steps 10–14 only make the result deterministic. When the chosen path surprises you, the explanation is almost always in the policy group.
The winner is BGP's best path, nothing more. It is then offered to the IP routing table, where a route from another source with a lower administrative distance can still win (r = RIB-failure), and CEF must resolve its NEXT_HOP recursively before packets follow it.
State model and selection mechanics
Cisco BGP commonly considers locally significant policy attributes before more topology-derived tiebreakers. Weight and LOCAL_PREF can dominate selection, then locally originated status, AS_PATH length, ORIGIN, MED under its comparison rules, eBGP versus iBGP, and IGP cost to NEXT_HOP before later deterministic tiebreakers. The exact decision sequence and optional knobs should be verified on the live release, but the core principle is stable: BGP compares attributes in order and usually stops at the first decisive difference.
Limits and common misconceptions
“Best” means best according to the local BGP decision process and current policy, not globally shortest, cheapest or most reliable. Attribute scope differs: some values are local to one router, some propagate inside the AS, and others are advertised externally. A best path can also be valid but operationally undesirable if policy intent was encoded incorrectly.
ReferenceConfiguration & state1 section · depth on demand
Policy and configuration model
Design path policy by choosing the attribute whose scope matches the requirement. LOCAL_PREF is appropriate for AS-wide outbound-exit preference; AS_PATH manipulation commonly influences inbound decisions seen by external networks; MED can signal a preferred entry point to a neighboring AS; Weight is local to one Cisco router. Avoid stacking unrelated attributes when one clear policy mechanism is enough.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Configuration & expected output
Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.
Configuration example
Assumptions: Lab addressing; both eBGP neighbours already Established; route-refresh supported.
ip prefix-list DST seq 10 permit 203.0.113.0/24
route-map FROM-ISP-A permit 10
match ip address prefix-list DST
set local-preference 200
route-map FROM-ISP-A permit 20
!
router bgp 65000
address-family ipv4 unicast
neighbor 192.0.2.2 route-map FROM-ISP-A in
!
! then: clear ip bgp 192.0.2.2 soft inExpected output
show ip bgp 203.0.113.0 255.255.255.0Expected state: One path marked best; the first attribute that differs between the paths is the one the design intends to decide (here LOCAL_PREF 200 vs 100).
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
! Illustrative output, not captured Evidence.Weight is equal (not shown = 0), so LOCAL_PREF decides before AS_PATH is reached. `metric` is MED. The address before `from` is NEXT_HOP; the parenthesised value is the peer's router ID.Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Routing → BGP → eBGP → Best Path. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc4271.html · confidence 94%Official Cisco vendor documentation reviewed for bounded reference claims: BGP path attributes and best-path selection scope. This is documentation-based technical verification, not lab or production-runtime proof. Deployment-specific applicability and runtime outcome remain separate evidence.
Basis: https://www.cisco.com/c/en/us/td/docs/routers/ios-xe/ip-routing/b-ip-routing/m_irg-overview-0.html · confidence 94%Quick lookup tables
Common Cisco BGP best-path order
Practical ordering for the source-taxonomy attributes
| Order | Factor | Preferred | Scope / note |
|---|---|---|---|
| 1 | Weight | Higher | Cisco local router only |
| 2 | LOCAL_PREF | Higher | intra-AS policy |
| 3 | Locally originated | Local | common Cisco factor |
| 4 | AS_PATH | Shorter | after earlier factors |
| 5 | Origin | IGP, EGP, incomplete | lower origin code |
| 6 | MED | Lower | comparison rules/context matter |
| 7 | eBGP vs iBGP | eBGP | later factor |
| 8 | IGP metric to NEXT_HOP | Lower | recursive reachability required |
Best Path · routing reference
Compact path-selection and evidence boundaries for fast lookup.
| Attribute / factor | General preference |
|---|---|
| Weight | Higher |
| LOCAL_PREF | Higher |
| AS_PATH length | Shorter |
| MED | Lower when comparable |
Best Path operational reference
Topic-specific bounded interpretation: known-good state, suspicious signatures and the next technical proof boundary.
| Boundary | Known-good for Best Path | Suspicious signature | Next proof |
|---|---|---|---|
| Intent | Matches ordered BGP path selection among eligible candidates rather than a single-attribute decision such as shortest AS_PATH design | Configuration differs from design/peer | Compare effective configuration |
| Control state | Stable expected region/role/topology/path state | operators focusing on AS_PATH while an earlier Weight/LOCAL_PREF difference already decides the path, MED compared outside the intended context, a best BGP path losing RIB selection to another protocol, or forwarding following unexpected recursion after selection | Inspect protocol detail and adjacent state |
| Forwarding | Expected VLAN/egress/RIB/FIB path | Control state exists but traffic path disagrees | MAC/FIB/CEF/adjacency proof |
| Closure | Original test passes for explained reason | Symptom moved, was bypassed or protection disabled | Regression test |