Pcornel
Networking · Routing › BGP › BGP Path Selection

Best Path

Cheat sheet · https://pcornel.dk/topic.php?topic=1136

Back to the Topic

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

Remember

The first differing attribute decides — a higher LOCAL_PREF beats any AS_PATH length, and MED is only compared between paths from the same neighbouring AS. A BGP best path can still lose the routing table to a route with lower administrative distance (RIB-failure).

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

Commands

show ip route <next-hop>
show ip bgp rib-failure
show ip route
show ip cef
show ip bgp

Verify in this order

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

Where it usually breaks

underlay/interface reachability → protocol adjacency/session → received/originated state → policy → best path/RIB → FIB/adjacency → traffic path

Common Cisco BGP best-path order

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

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=1136

Confirmation

Confirm action

Continue?