"Please Enter Here"
While Local Preference controls how traffic leaves your network, MED (Multi-Exit Discriminator) is an attempt to influence how a neighboring AS routes traffic into your network. It's the BGP equivalent of putting a "preferred entrance" sign on your building.
The Rule: Lower MED is Better.
Imagine your company has two connections to the same upstream ISP — one in New York and one in Los Angeles. Your primary servers are in New York. You want the ISP to send traffic destined for your network into the New York connection whenever possible.
You configure your BGP advertisements like this:
Advertise 203.0.113.0/24 via New York link → MED = 10
Advertise 203.0.113.0/24 via Los Angeles link → MED = 50
The ISP's routers see both paths to your network and, all else being equal, prefer the one with MED 10 — the New York entry point.
The critical limitation: MED is advisory, not binding. The neighboring AS can be configured to ignore your MED values entirely and use its own Local Preference or other attributes instead. In practice, MED is only compared between paths that were learned from the same neighboring AS — most BGP implementations won't compare MEDs from different neighbors at all unless explicitly configured to do so (bgp always-compare-med in Cisco IOS).
MED is also only propagated one AS hop — the ISP you send it to will not pass your MED values further upstream.
Key Point: MED influences ingress traffic from a directly connected neighbor, but it is a suggestion, not a guarantee. Neighbors can and do ignore it.