Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

Best Path

Direct answer

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).

When to use this

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.

First 30 seconds

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.

Operational verification

valid candidates (NEXT_HOP reachable, policy permits) → first differing attribute in decision order → best marker → RIB (no rib-failure) → CEF/next hop → traffic and return path

Context & applicabilityCommon mistakes · platform/version boundaries
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 · IOS/IOS XE · Cisco IOS XE
Key commandshow ip bgp 203.0.113.0 255.255.255.0
Scope / prerequisiteUse it when BGP picks an unexpected exit for a prefix, or when you need to know which attribute to change to make a pat…
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

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

6 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 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 … weight usually 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-med is set consistently across the AS; bgp deterministic-med changes 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 without next-hop-self), inbound filters and AS-loop rejection.
  • BGP best path is not in the routing table. show ip bgp rib-failure shows 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-routerid if 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 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 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.

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

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.

StepPreferScope
1Highest weightCisco-specific, local to the router
2Highest LOCAL_PREFWhole AS (default 100)
3Locally originated (network, aggregate-address, redistribution)
4Shortest AS_PATH
5Lowest origin: IGP < EGP < INCOMPLETE
6Lowest MEDNormally only between paths from the same neighbouring AS
7eBGP over iBGP
8Lowest IGP metric to the next hop
9Multipath check (maximum-paths)Installs several paths, but one is still the best
10Oldest eBGP pathAvoids flapping
11Lowest BGP router ID
12Shortest cluster list (route reflection)
13Lowest 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

GoalAttribute 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 lostCriterion
Lower WeightStep 1
Lower LOCAL_PREFStep 2
Longer AS_PATHStep 5
Higher MED (same neighbour AS)Step 7
iBGP vs eBGPStep 8
Higher IGP metric to NEXT_HOPStep 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.

#CriterionPreferredNote
0Path valid—NEXT_HOP resolvable, not denied by inbound policy, no AS loop
1WeightHighestCisco-only, local to this router (default 0; 32768 for locally originated)
2LOCAL_PREFHighestShared inside the AS via iBGP (default 100)
3Locally originatedLocalnetwork/redistribute before aggregate-address
4AIGPLowestOnly when AIGP is enabled
5AS_PATH lengthShortestAS_SET counts as 1; skipped with bgp bestpath as-path ignore
6ORIGINIGP < EGP < incompletei / e / ? in the display
7MEDLowestOnly between paths from the same neighbouring AS unless bgp always-compare-med
8Peer typeeBGPThen confederation-external, then iBGP
9IGP metric to NEXT_HOPLowestHot-potato exit
10Multipath—With maximum-paths, equal paths are installed together; best path still chosen below
11Oldest pathOldesteBGP paths only; skipped with bgp bestpath compare-routerid
12Router IDLowestORIGINATOR_ID for reflected routes
13CLUSTER_LIST lengthShortestRoute-reflector topologies
14Neighbour addressLowestFinal 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
Technical examples

Configuration & expected output

Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.

Configuration example

Cisco IOS / IOS XE RFC 4271Prefer the exit via 192.0.2.2 for one prefix across the AS using LOCAL_PREF

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 in

Expected output

Cisco IOS / IOS XE RFC 4271show ip bgp 203.0.113.0 255.255.255.0

Expected 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.
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 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%
2026-09-13 · vendor docCisco IOS XE current

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%
Embedded reference data

Quick lookup tables

Common Cisco BGP best-path order

Practical ordering for the source-taxonomy attributes

OrderFactorPreferredScope / note
1WeightHigherCisco local router only
2LOCAL_PREFHigherintra-AS policy
3Locally originatedLocalcommon Cisco factor
4AS_PATHShorterafter earlier factors
5OriginIGP, EGP, incompletelower origin code
6MEDLowercomparison rules/context matter
7eBGP vs iBGPeBGPlater factor
8IGP metric to NEXT_HOPLowerrecursive reachability required

Best Path · routing reference

Compact path-selection and evidence boundaries for fast lookup.

Attribute / factorGeneral preference
WeightHigher
LOCAL_PREFHigher
AS_PATH lengthShorter
MEDLower when comparable

Best Path operational reference

Topic-specific bounded interpretation: known-good state, suspicious signatures and the next technical proof boundary.

BoundaryKnown-good for Best PathSuspicious signatureNext proof
IntentMatches ordered BGP path selection among eligible candidates rather than a single-attribute decision such as shortest AS_PATH designConfiguration differs from design/peerCompare effective configuration
Control stateStable expected region/role/topology/path stateoperators 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 selectionInspect protocol detail and adjacent state
ForwardingExpected VLAN/egress/RIB/FIB pathControl state exists but traffic path disagreesMAC/FIB/CEF/adjacency proof
ClosureOriginal test passes for explained reasonSymptom moved, was bypassed or protection disabledRegression test
Confirmation

Confirm action

Continue?