Pcornel
Networking · Routing › BGP › BGP Path Selection

MED

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

Back to the Topic

Answer

MED (Multi-Exit Discriminator) is a hint to a neighboring AS about which entry point into your AS it should prefer; lower is better. By default it is compared only between paths from the same neighbor AS, and it is weaker than LOCAL_PREF and AS_PATH.

Remember

Lower wins. MED is compared only between paths from the same neighbouring AS unless bgp always-compare-med is set, and only after Weight, LOCAL_PREF, AS_PATH and ORIGIN are equal. It is a request to the neighbour, who can override it with LOCAL_PREF. A missing MED counts as 0 (best) unless bgp bestpath med missing-as-worst is configured.

First checks

show ip bgp <prefix> on the router that chooses → metric is the MED on each path. show running-config | include med → always-compare-med, deterministic-med, missing-as-worst. Confirm the MED you send on the receiving side.

Commands

show ip bgp
clear ip bgp <neighbour> soft out

Verify in this order

MED set outbound toward the neighbouring AS → neighbour receives the prefix on each link → paths from the same neighbouring AS? (otherwise MED is skipped) → earlier attributes equal → lower MED wins → neighbour's best path → inbound traffic

Where it usually breaks

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

MED · routing reference

PropertyMED
DirectionSuggests inbound entry to neighbor
PreferenceLower wins when compared
StrengthLater than LOCAL_PREF/AS_PATH in common order
GuaranteeNone; remote policy can override

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

Confirmation

Confirm action

Continue?