What is MED?
Multi-Exit Discriminator
MED (Multi-Exit Discriminator) is an optional BGP attribute that suggests to a neighbouring AS which of several links it should use to reach you.
When two networks connect in more than one place, each side chooses for itself which link to send traffic over. MED is a way to express a preference to the other side: you set a lower MED on routes announced over the link you'd like traffic to arrive on, and a higher MED on the backup. It is a 32-bit value, often shown as "metric" in router output, and lower wins. MED is non-transitive: the neighbouring AS may pass it among its own routers over iBGP, but it does not send it on to any further AS. In best-path selection it comes after LOCAL_PREF, AS_PATH length and ORIGIN, and by default it is only compared between routes received from the same neighbouring AS, since MED values from two different networks mean nothing relative to each other. Routes without a MED are usually treated as MED 0, which makes them the most preferred unless the router is configured to treat a missing MED as the worst.
MED is only a hint. The receiving network can ignore it, reset it, or override it with LOCAL_PREF, which is evaluated first and is what most providers use to prefer customer routes. In practice MED works best between two networks with a direct agreement, such as a customer and a provider or two peers across several cities; for steering traffic from the wider internet, prepending to the AS_PATH or communities are the usual tools. Knobs such as always-compare-med and deterministic MED change the default comparison and should be set consistently across a network. The BGP Fundamentals lesson places MED in the full best-path order.
Lessons that use MED
- BGP FundamentalsTeaches this term · Intermediate · 75 min
How the Border Gateway Protocol glues the internet together: autonomous systems, sessions, path attributes, best-path selection, iBGP scaling and a hands-on eBGP lab with real FRR configuration.