How to configure BGP MED Attribute

Hello William

The purpose of MED is to advertise to your neighbouring AS how they should enter your AS. This by definition requires that you have at least two connections to a particular AS. MED is then used by their BGP routers to determine via which path connectivity to your AS will be achieved. A prerequisite of the use of MED is that the two alternative paths into your network must be in the same AS. Note here that MED is propagated to all routers within a neighbouring AS but is not passed along to any other autonomous systems.

If you have the topology that you describe, then each AS, even if it belongs to the same entity, will have only one single entry point into your AS. Therefore there is no issue as to which path will be taken, since there is only one choice per AS.

So to answer your question, MED cannot be used to modify the way in which traffic from different AS’es enter your network.

Having said that, however, there is an exception to this rule. If two AS’es exist as two alternate paths to a third single AS, then yes, you can have a situation where you must compare MED values from multiple AS’es. But this involves outgoing traffic, and not incoming traffic. Take a look at this topology for example:


Here we have a network 10.1.1.0/24 that exists in AS 10. The path to this network is advertised by R4 and R5 which are in different AS’es to R6 in AS40 using a different MED. By default, R6 will not take the MEDs into account because they are from different AS’es, however, you can configure R6 with the bgp always-comare-med command, and only then will it compare them. However, keep in mind that the destination is still a single network, and exists within a single AS 10.

Such a configuration , informs R6 of how to reach the particular network, and does not inform the other AS’es of how to reach networks behind R6, so this situation is the other way around.

I hope this has been helpful!

Laz

1 Like