Pcornel
Networking · Routing › BGP

BGP Path Selection

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

Back to the Topic

Answer

BGP path selection is the ordered comparison BGP uses to pick one best path per prefix: Weight, LOCAL_PREF, local origination, AS_PATH length, ORIGIN, MED, eBGP over iBGP and IGP metric to the next hop, then tie-breakers. The first difference decides.

Remember

BGP selects among paths using attributes and reachability, not simply the numerically shortest network path. In Cisco-oriented study, reason through locally significant attributes such as weight/local preference, locally originated paths, AS-path length, origin, MED and eBGP/iBGP distinctions before later tie-breakers.

Always verify that the BGP next hop is reachable in the relevant routing table. A 'best' path that cannot resolve a next hop does not provide usable forwarding.

First checks

  • show ip route — Display IPv4 routing table. Proves which routes are installed in the local RIB and exposes prefix, source, next hop, AD/metric and default-route state.
  • show ip cef — Inspect FIB/CEF forwarding entries. Shows FIB/CEF forwarding entries and how a destination prefix resolves toward an interface/next hop.
  • show ip bgp summary — Check BGP neighbor session state and prefix counts. Shows BGP peer session state, peer AS, uptime and prefix-count/state summary for an address family.
  • show ip bgp — Inspect BGP paths and attributes. Shows BGP candidate paths, next hop and path attributes and identifies the locally selected best BGP path.
  • Symptom: The expected prefix appears in BGP output, yet forwarding does not reach the destination. → BGP path selected but traffic still fails

Commands

show bgp ipv4 unicast <prefix>
BGP path attributes and best-path information for a prefix.
show ip route [prefix]
Display IPv4 routing table.
show ip cef [prefix]
Inspect FIB/CEF forwarding entries.
show ip bgp [prefix]
Inspect BGP paths and attributes.
show bgp ipv4 unicast neighbors {{neighbor}} advertised-routes
Shows routes advertised to a BGP neighbor.
show bgp ipv4 unicast neighbors {{neighbor}} routes
Shows accepted routes from a BGP neighbor where supported.
show bgp ipv4 unicast neighbors <neighbor>
Shows BGP session capabilities, timers, message counters, policies and per-peer state.
show bgp ipv4 unicast community <community>
Filters BGP table output by community value where supported.
show bgp ipv4 unicast neighbors <peer> | section Capabil
Inspect negotiated peer capabilities such as route refresh and address-family support.
show bgp ipv4 unicast neighbors <peer>
Inspect peer state, last reset reason, messages and negotiated session metadata.
show bgp ipv4 unicast neighbors <peer> advertised-routes
Display routes selected for advertisement to a specific peer.
show bgp ipv4 unicast neighbors <peer> received-routes
Display received routes when platform/configuration exposes pre-policy received state.
show bgp ipv4 unicast rib-failure
Display BGP paths that were not installed in the IP routing table due to RIB-selection conditions.
show bgp ipv4 unicast neighbors <neighbor> received-routes
Inspect received routes when the platform/configuration retains that view.
show ip bgp <prefix>
show ip route <prefix>

Verify in this order

prefix received from each neighbour → path valid (NEXT_HOP reachable, inbound policy permits) → first differing attribute in decision order → best marker → RIB (no rib-failure) → CEF → 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

BGP path-selection factors

FactorTypical preferenceBoundary
WeightHigherLocal to one Cisco router
Local PreferenceHigherPropagated inside the AS; common outbound-exit policy
Locally originatedPreferredLocal origination can outrank learned alternatives
AS_PATHShorterOnly after higher-priority factors are equal
OriginIGP < EGP < incompleteOne later comparison factor
MEDLowerComparison rules/context matter
eBGP vs iBGPeBGP preferredLater than the attributes above
IGP metric to next hopLowerRequires usable next-hop reachability

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

Confirmation

Confirm action

Continue?