TTR Networks

Intermediate · BGP Fundamentals · section 5 of 9

Best-path selection

✓ Lab-tested 17 October 2026 on FRR 10.2.1

A router often learns the same prefix from several peers. BGP installs exactly one best path per prefix (unless multipath is enabled) by walking down an ordered list of tie-breakers and stopping at the first one that produces a single winner.

The common order (Cisco IOS and FRR are nearly identical):

  1. Highest weight — local to the router, never advertised. (Cisco/FRR only.)
  2. Highest LOCAL_PREF — AS-wide outbound preference.
  3. Locally originated — prefer routes this router injected itself.
  4. Shortest AS_PATH
  5. Lowest ORIGIN — IGP < EGP < incomplete.
  6. Lowest MED — by default only compared between routes from the same neighbouring AS.
  7. eBGP over iBGP
  8. Lowest IGP metric to the NEXT_HOP — "hot-potato" routing: leave the network at the nearest exit.
  9. Oldest eBGP path — stability (not modelled in the simulator).
  10. Lowest router ID
  11. Lowest neighbour address

Before any of this, a path must be valid: its NEXT_HOP must be reachable and it must not contain a loop.

The key insight for design: steps 1–2 are your policy, steps 4–8 are the network's opinion. Operators rarely rely on AS_PATH length alone — they set LOCAL_PREF from inbound route-maps to express "prefer the customer, then the peer, then transit".

Try these in the simulator. By default all three paths have equal AS_PATH length, so R3 loses at eBGP over iBGP and ISP A beats ISP B on router ID.

  • Give R3 (iBGP) a LOCAL_PREF of 200. It now wins despite being iBGP — policy beats everything below it.
  • Reset, then prepend on ISP A by changing its AS_PATH to 64497 64497 64497 64499. ISP B wins on path length.
  • Reset, then give ISP A a MED of 50 and ISP B a MED of 10. Nothing changes: MED is only compared between paths from the same neighbouring AS, and these come from 64497 and 64498. Tick always-compare-med and ISP B wins.

Interactive: Best-path simulator Three routers in AS 64500 have learnt 203.0.113.0/24. Edit any attribute and watch the decision change. (needs JavaScript)

Check your understanding

Two eBGP routes have identical weight, LOCAL_PREF and AS_PATH length. One has ORIGIN incomplete (?) and MED 0; the other has ORIGIN IGP (i) and MED 500. Which wins?

  • The MED 0 route, because lower MED is preferred
  • The ORIGIN IGP route
  • Whichever was received first