BGP how MED attribute is compared

A BGP router will, by default, compare the MED attribute of routes that come from the same AS. This behavior can be modified using the commands bgp deterministic-med and bgp always-compare-med.

Enabling the bgp deterministic-med command ensures the comparison of the MED variable when choosing routes advertised by different peers in the same autonomous system. Enabling the bgp always-compare-med command ensures the comparison of the MED for paths from neighbors in different autonomous systems. This is useful when multiple service providers or enterprises agree on a uniform policy for setting MED. Thus, for network X, if Internet Service Provider (ISP) A sets the MED to 10, and ISP B sets the MED to 20, both ISPs agree that ISP A has the better performing path to X.

Note: The two commands are separate and independent. Enabling one does not affect the other. Both can be enabled at the same time.

Links:

https://forum.networklessons.com/t/how-to-configure-bgp-med-attribute/956/68?u=lagapidis

https://forum.networklessons.com/t/how-to-configure-bgp-med-attribute/956/62?u=lagapides

https://forum.networklessons.com/t/how-to-configure-bgp-med-attribute/956/44?u=lagapides

https://forum.networklessons.com/t/how-to-configure-bgp-med-attribute/956/54?u=lagapides

https://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/16046-bgp-med.html#backinfo