BGP Best-Path Selection — The Full 13-Step Order
The complete BGP path-selection algorithm CCNP ENCOR expects you to recite. Every step in order, with the tie-breaker mnemonic and a worked example for the top three most-common decision points.
- BGP has many attributes. When multiple paths exist to the same prefix, BGP walks them through a fixed 13-step tie-breaker until only one survives — that becomes the install-in-RIB path.
- For most CCNP questions, three attributes matter: **weight** (local, higher wins), **local preference** (AS-wide, higher wins), **AS_PATH length** (shorter wins). Master those and you'll answer 80% of the exam questions.
- Cisco mnemonic: **N W L A O M M E B R** — Next-hop, Weight, Local pref, AS-path, Origin, MED, eBGP > iBGP, IGP metric, oldest, Router-ID.
Why this order matters
BGP is a policy-based routing protocol — the “best path” is whatever the operator says it is. Cisco’s implementation walks a fixed decision tree of attributes so that the operator can predict, exactly, which path a change will select. If you can’t recite the order, you can’t design predictable inbound/outbound policy.
The full 13-step order
Cisco IOS / IOS-XE / NX-OS BGP compares two paths in this order. Whichever step first produces a clear winner ends the comparison.
| # | Step | Prefer |
|---|---|---|
| 0 | Next-hop reachable? | Drop paths whose next-hop is unreachable in the IGP. |
| 1 | Weight | Higher wins. Cisco-proprietary, local to this router only. |
| 2 | Local Preference | Higher wins. Advertised to iBGP neighbors, AS-wide. |
| 3 | Locally originated? | Prefer routes originated on this router (network / redistribute / aggregate). |
| 4 | AS_PATH length | Shorter wins. Prepending increases it. |
| 5 | Origin | i (IGP) > e (EGP) > ? (incomplete). |
| 6 | MED | Lower wins. Only compared if AS_PATH prefix is the same neighbor AS. |
| 7 | eBGP over iBGP | Prefer paths learned via eBGP. |
| 8 | IGP metric to next-hop | Lower wins. |
| 9 | Multi-path? | If maximum-paths configured & candidates are equal to here, install multiple. |
| 10 | Oldest eBGP route | Prefer the path that was learned first (stability). |
| 11 | Router-ID | Lower wins. |
| 12 | Neighbor address | Lower wins. Final tie-breaker. |
The mnemonic
Most textbooks use variants of:
N W L L A O M E I O R N
Next-hop · Weight · Local pref · Locally originated · AS-path · Origin · MED · eBGP > iBGP · IGP metric · Oldest · Router-ID · Neighbor
Or a shorter version most engineers actually remember for the top 4:
W L A M — Weight, Local pref, AS-path, MED.
If you can order those four and remember eBGP > iBGP sits between them and the tie-breakers, the rest falls into place.
The three attributes you’ll see 80% of the time
1. Weight (higher wins)
Cisco-only. Set per-router with a route-map inbound. Not advertised anywhere. Use it when you want this router to prefer a path without affecting the rest of the AS.
route-map PREFER-ISP1 permit 10
set weight 200
!
router bgp 65001
neighbor 203.0.113.1 route-map PREFER-ISP1 in
2. Local Preference (higher wins)
Advertised to iBGP neighbors, so the whole AS agrees on the exit. Use for outbound policy — “the whole company should exit via ISP1 unless ISP1 is down.”
route-map OUT-VIA-ISP1 permit 10
set local-preference 300
!
router bgp 65001
neighbor 203.0.113.1 route-map OUT-VIA-ISP1 in
3. AS_PATH prepending (longer loses)
Add your AS number multiple times to make a path look worse to neighbors, so they prefer someone else. Use for inbound policy — “please, ISP2, don’t send me traffic on this prefix.”
route-map PREPEND-OUT permit 10
set as-path prepend 65001 65001 65001
!
router bgp 65001
neighbor 203.0.113.2 route-map PREPEND-OUT out
Worked example
R1 has three eBGP paths to 10.0.0.0/24:
| Path | Weight | Local pref | AS-path | MED |
|---|---|---|---|---|
| via ISP-A | 0 | 200 | 65100 65200 | 100 |
| via ISP-B | 0 | 200 | 65300 | 100 |
| via ISP-C | 100 | 100 | 65400 | 50 |
Walk the algorithm:
- Weight — ISP-C wins (100 vs 0). Comparison ends. Winner: ISP-C.
If Weight had been equal, we’d have compared Local Pref (ISP-A and ISP-B tie at 200 > ISP-C at 100 → ISP-C drops). Then AS-path: ISP-B (length 1) beats ISP-A (length 2). Winner would have been ISP-B.
Understand: weight is checked FIRST, so a locally-set weight overrides an AS-wide local-preference decision. This is often surprising.
Common exam / real-world mistakes
- Confusing weight and local-preference direction. Weight = local (never leaves the router). Local pref = AS-wide (advertised iBGP). MED = “hint to neighbor AS” (advertised eBGP outbound but not further).
- Setting MED when AS_PATH varies. MED is only compared if the prefix is coming from the same neighbor AS. Otherwise BGP skips step 6.
- Assuming lower LP wins. Higher LP wins. Trap for exam-day nerves.
- Forgetting the next-hop reachability check. If the next-hop advertised in BGP isn’t in your IGP, the route is invalid regardless of any attribute. Common iBGP mistake with route-reflectors.
- Never using
bgp bestpath as-path multipath-relaxwhen you want ECMP over eBGP paths from different upstream ASes.
Cheat strip
Order N W L L A O M E I O R N
Next-hop reach → Weight (hi) → Local pref (hi)
→ Locally originated → AS-path (short) → Origin (i > e > ?)
→ MED (lo, same-AS only) → eBGP > iBGP → IGP metric (lo)
→ Oldest eBGP → Router-ID (lo) → Neighbor (lo)
Top 3: Weight (local, hi wins)
Local pref (AS-wide, hi wins)
AS-path length (short wins)
Verify: show bgp ipv4 unicast | show ip bgp <prefix>
show ip bgp neighbors <ip> advertised-routes
VXLAN Basics — VNI, VTEP, and Why Modern DCs Use It
The Layer-2-over-Layer-3 overlay every modern data center runs. VXLAN encapsulation, VNI, VTEP roles, unicast vs multicast flood-and-learn vs BGP EVPN — the CCNP ENCOR essentials.
QoS Marking & Queuing — DSCP, Trust Boundaries, LLQ, CBWFQ
The CCNP ENCOR QoS chapter, distilled: classification, marking with DSCP, trust boundaries, and queuing with LLQ and CBWFQ. Where to mark, where to trust, and how the router services the queues.
Want this drilled into reflex?
1:1 weekly sessions, live feedback on your labs, and US interview prep — built around the CCNP® exam blueprint. Free first session. No card on file until you decide.
Related topics
BGP Basics
Definitive CCNP-level BGP guide — autonomous systems, eBGP vs iBGP, path-vector routing, neighbor states, full best-path selection process, attributes deep dive (AS_PATH, LOCAL_PREF, MED, communities), route reflectors, RPKI, 8 worked scenarios, and the BGP debug workflow.
IP ConnectivityOSPF Single-Area
Definitive CCNA-level OSPF guide — link-state mental model, seven neighbor states, LSA types, DR/BDR election, cost tuning, authentication, route summarization, common debug patterns, and 8 worked scenarios.
IP ConnectivityStatic Routing
Definitive CCNA-level static routing guide — next-hop vs exit-interface vs fully-specified, default routes, floating statics, summary routes, recursive lookup, IPv6 statics, AD reference, 8 worked scenarios, and the static-routing debug workflow.
Get the free CCNA 12-week roadmap
You're already reading up on BGP Best-Path Selection — The Full 13-Step Order. The roadmap is the order I recommend studying every CCNA topic in — with what to lab each week and where BGP Best-Path Selection — The Full 13-Step Order fits. A written personal reply, not an autoresponder. Expect it within one business day.
Personal reply from a senior network engineer. No third-party tracking. Unsubscribe any time.