Octet

Give me the full BGP best path selection order on a Cisco router.

Show the answer

Say this first

First the next hop must be reachable. Then: 1 highest weight, 2 highest LOCAL_PREF, 3 locally originated, 4 shortest AS_PATH, 5 lowest origin (IGP before EGP before incomplete), 6 lowest MED, 7 eBGP over iBGP, 8 lowest IGP metric to the next hop, 9 multipath check, 10 oldest eBGP path, 11 lowest router ID, 12 shortest cluster list, 13 lowest neighbor address. The first step where paths differ decides. A common memory aid for the first part is "N WLLA OMNI": Next hop, Weight, Local pref, Locally originated, AS path, Origin, MED, Neighbor type, IGP metric.

Go deeper

StepComparePreferNotes
0Next hop reachableReachableAlso: not looped, passed inbound policy
1WeightHighestCisco only, local to the router; 0 learned, 32768 local
2LOCAL_PREFHighestDefault 100; shared across the AS
3Locally originatedLocalnetwork or redistribution, then aggregates
4AS_PATH lengthShortestAn AS_SET counts as 1; confederation segments do not count
5ORIGINi, then e, then ?
6MEDLowestOnly between paths from the same neighbor AS by default
7Peer typeeBGPThen confederation eBGP, then iBGP
8IGP metric to NEXT_HOPLowestHot potato routing
9MultipathWith maximum-paths, equal paths are installed; one is still marked best
10Path ageOldest eBGPStability; skipped with bgp bestpath compare-routerid
11Router IDLowestORIGINATOR_ID for reflected routes
12CLUSTER_LIST lengthShortest
13Neighbor addressLowestThe peer's IP address

How I explain it in an interview

Group the steps. Weight and local preference are the knobs you control. Locally originated, AS path, origin and MED describe the route itself. eBGP versus iBGP and IGP metric describe where it enters your network. The rest are tie breakers chosen for stability and determinism.

Proving it on a device

show ip bgp <prefix> lists every path and says best #2. IOS-XR goes further with show bgp <prefix> bestpath-compare, which explains why each path lost.

Junos

No weight. Junos first compares protocol preference (BGP is 170), then follows broadly the same order: local preference, AS path length, origin, MED, eBGP over iBGP, IGP cost, then tie breakers.

Traps

  • Saying lowest local preference wins, or placing MED before AS path length.
  • Forgetting that weight only affects the router it is set on.
How did you do?Book 4.1 Global Internet