How to configure BGP MED Attribute

Hello John

We must make sure we understand what the phrase “originating AS is the same”. In the table you shared, the AS_PATH indicates that the three paths are learned from different ASes. Path 1 is learned from AS 50, path 2 from AS 20 and path three from AS 10. Note these are the first ASes in each of the AS paths, which means they are the directly connected ASes. AS Path when read from left to right shows the ASes you pass through to get to the destination.

To clarify this, take a look at the following diagram:

R5 advertises the 1.1.1.1/32 network, and AS1 sees three paths:

  • 2 4 via R2
  • 3 4 via R3
  • 3 4 via R4

If those paths are equal, and we reach the MED attribute, then by default it won’t be used to compare the MED between the paths via R3 and R4, because both are advertised to R1 from the same AS, namely AS3. It is the leftmost AS in the AS_PATH that matters for the comparison of MED.

So going back to your scenario, since all three paths are learned from different ASes, the bgp always-compare-med command will make no difference in the behavior. That means that for Path 3, you can put anything you like in the place of the ?, and the MED will choose Path 3. This is true whether bgp always-compare-med is used or not.

I hope this has been helpful!

Laz