BGP Path Selection and Best-Path Decision
This domain tests the decision steps that turn several candidate paths into one installed route, and the SR OS knobs that modify those steps.
Candidate paths first
Only paths with a resolvable NEXT_HOP are candidates. If the next hop is unreachable through the IGP (or through the tunnel/route-table entry), the path is not eligible regardless of attributes - SR OS shows it as invalid rather than best.
Decision order (highest wins unless stated)
- Highest LOCAL_PREF (default 100).
- Locally originated (network, aggregate, redistribute) over learned.
- Shortest AS_PATH.
- Lowest ORIGIN (IGP < EGP < incomplete).
- Lowest MED - compared only among paths from the same neighbour AS unless
always-compare-med(all paths) ordeterministic-med(group by AS, then compare) is configured. - eBGP over iBGP.
- Lowest IGP metric to NEXT_HOP.
- Tie-breaks: lowest router ID, shortest CLUSTER_LIST, lowest peer address.
SR OS controls
best-path-selection supports always-compare-med, deterministic-med, ignore-nh-metric, ignore-router-id, as-path-ignore (AS_PATH length not compared) and origin-valid (prefer RPKI valid paths). med-out defaults to igp-cost, so MED values on the wire reflect the sender's IGP distance to the next hop unless you set a fixed value - verify the exact step order against the SR OS best-path-selection reference, since these flags reorder it.
Worked example
Two eBGP paths to 203.0.113.0/24: via AS 65010, AS_PATH length 3, LOCAL_PREF 100, MED 50; via AS 65020, AS_PATH length 3, LOCAL_PREF 200, MED 10. The second wins on LOCAL_PREF alone - MED is never consulted. If both carried LOCAL_PREF 100, default MED comparison would be skipped (different neighbour ASes) and the lowest IGP metric to the next hop would decide.
Traps
- Comparing MED from different neighbour ASes without
always-compare-med. - Setting LOCAL_PREF outbound to an eBGP peer where it is stripped anyway.
- Ignoring next-hop reachability, which invalidates an otherwise attractive path.