Skip to main content
PacketMentor logo
Open menu
Home
Training
Learn
CCNA Library (74)
Browse all CCNA topics →
Network (13)
Device Operations (5)
Network Access (12)
Wireless (6)
IP Connectivity (10)
IP Services (11)
Security (10)
Automation (7)
Network+ Library (77)
Browse all Network+ topics →
1.0Networking Concepts (22)
2.0Network Implementation (17)
3.0Network Operations (16)
4.0Network Security (15)
5.0Network Troubleshooting (7)
NSE 4 Library (45)
CCNP Library (26)
Practice
All practice →
Troubleshooting Labs
Packet Tracer Labs
Interactive Simulators
Mock ExamPricing
Contact 📞 +1 (860) 556-3010 Book a Call
← All topics
CCNP IP Connectivity Advanced

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.

Quick summary
  • 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.

#StepPrefer
0Next-hop reachable?Drop paths whose next-hop is unreachable in the IGP.
1WeightHigher wins. Cisco-proprietary, local to this router only.
2Local PreferenceHigher wins. Advertised to iBGP neighbors, AS-wide.
3Locally originated?Prefer routes originated on this router (network / redistribute / aggregate).
4AS_PATH lengthShorter wins. Prepending increases it.
5Origini (IGP) > e (EGP) > ? (incomplete).
6MEDLower wins. Only compared if AS_PATH prefix is the same neighbor AS.
7eBGP over iBGPPrefer paths learned via eBGP.
8IGP metric to next-hopLower wins.
9Multi-path?If maximum-paths configured & candidates are equal to here, install multiple.
10Oldest eBGP routePrefer the path that was learned first (stability).
11Router-IDLower wins.
12Neighbor addressLower 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:

PathWeightLocal prefAS-pathMED
via ISP-A020065100 65200100
via ISP-B020065300100
via ISP-C1001006540050

Walk the algorithm:

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

  1. 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).
  2. 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.
  3. Assuming lower LP wins. Higher LP wins. Trap for exam-day nerves.
  4. 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.
  5. Never using bgp bestpath as-path multipath-relax when 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
Master this on a real network

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.

Claim my free session →

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.