Route Selection and Best-Path Decision Process
Route Selection and the Best-Path Decision Process
This domain tests the tie-break ladder BGP applies when several routes to one prefix are valid, and how SR OS reports the outcome.
The ladder
A route must first be valid: next hop resolvable, AS_PATH loop-free, accepted by policy. Among valid routes BGP chooses, in order: highest LOCAL_PREF; locally originated (network or aggregate) over learned; shortest AS_PATH; lowest ORIGIN (IGP < EGP < INCOMPLETE); lowest MED when both routes come from the same neighboring AS; eBGP over iBGP; lowest IGP metric to the NEXT_HOP; then oldest eBGP route, lowest router-id, shortest CLUSTER_LIST, lowest neighbor address.
SR OS exposes this through show router bgp routes <prefix> detail, which marks the chosen route as best. maximum-paths enables ECMP for routes still tied after the IGP-metric step.
Worked example
Two iBGP routes to 198.51.100.0/24 arrive. Route X has LOCAL_PREF 200 and AS_PATH length 5; route Y has LOCAL_PREF 100 and AS_PATH length 1. X wins, because the comparison never reaches AS_PATH - LOCAL_PREF is evaluated first. This is the most commonly tested point in the domain. If both had LOCAL_PREF 200, Y's shorter AS_PATH would win. If AS_PATH were also equal, MED would only be compared when both routes came from the same neighbor AS; otherwise the eBGP/iBGP and IGP-metric steps follow.
Traps
Assuming shortest AS_PATH is the primary criterion - LOCAL_PREF and local origination come first. Comparing MED across different neighbor ASes; by default it is ignored there. Forgetting that an unreachable next hop invalidates a route before any attribute is examined. Treating SR OS preference (protocol-level route preference) as LOCAL_PREF; they operate at different layers.