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 from 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.