The multi-exit discriminator (MED) helps determine the optimal route for incoming traffic of an AS. It is similar to the metric used in IGP. When a BGP device obtains multiple routes to the same destination address but with different next hops from EBGP peers, the BGP device selects the route with the smallest MED value as the optimal route.
- Run the following command to enable comparison of the Multi Exit Discriminator (MED) for paths from neighbors in different autonomous systems.
set protocols bgp [vrf <vrf-name>] always-compare-med
MED is one of the parameters that is considered when selecting the best path among many alternative paths. The path with a lower MED is preferred over a path with a higher MED.
During the best-path selection process, MED comparison is done only among paths from the same autonomous system. Use the command bgp always-compare-med to change this behavior by enforcing MED comparison between all paths, regardless of the autonomous system from which the paths are received.
- Run the following command to configure a BGP routing process to assign a value of infinity (max possible) to routes that are missing the Multi Exit Discriminator (MED) attribute.
set protocols bgp [vrf <vrf-name>] bestpath med missing-as-worst