How to configure BGP MED Attribute

Hello David

I agree, the writing is a little bit vague. Let me try to more clearly explain what I believe they are saying.

First of all, everything hinges on the fact that MED, by default, is used as a mechanism to influence incoming traffic into an AS from multiple entry points. By default, the comparison is always done between two or more entry points into the same AS.

This is not a hard and fast rule, but a common practice that you should be prepared for. In this case, MED values are used by the ISPs to influence the inbound traffic (from the ISPs point of view) . By having a MED value for each prefix, ISPs can more effectively manage how traffic is distributed across multiple entry points into their network. This may be a method of attempting to load balance incoming traffic across those multiple entry points. But note, that this makes sense only if that same ISP has two entry points into its AS. See below.

MED is an optional attribute, which means it may or may not be included in the BGP update. When there is no MED, a MED of 0 is assumed, and because lower MED values are preferred, a MED value of 0 will always be preferred over any other value (assuming the MED attribute is the tie-breaker in the path selection). You can indeed modify this behavior by using the missing-med-as-worst keyword. Why would you do this? Well, I’ll tell you shortly.

Now here, what is being said in simpler terms is that by default, MED is only compared between routes that come from the same AS (requires the AS_PATH values to be identical). That’s its purpose. However, because most enterprises will use two or more different ISPs for their multiple connections to the Internet, this by default means that they are coming from two different ASes. Thus, MED will never be compared. If you want to use MED as part of your path selection mechanism, even if that MED comes from different ASes, then you must “relax BGP rules” and compare MED from different ASes.

Here’s a scenario where all of this comes together:

Imagine you have two ISPs, each with a single link to your enterprise network. ISP A chose to use the default behavior of MED and didn’t set a MED for some routes, while ISP B choose to relax BGP rules and added a MED value. By default, routes from ISP A (without MED) would be preferred if MED becomes the tie breaker. However, this may not align with your traffic engineering goals. Using missing-med-as-worst, you can ensure that routes from ISP B, where MED is defined and indicating a specific preference, are chosen first.

This is simply one more mechanism we can use to route BGP traffic, and it can be used based on what you need. In almost all such cases, you would negotiate with your ISPs concerning what kind of BGP attributes they share with your network, and all of this is typically agreed upon beforehand. It’s rare that you’ll see an ISP or an enterprise modify such parameters without having some sort of agreement on paper that states how BGP networks will interface with each other.

I hope this has been helpful!

Laz