The MED attribute indicates the metric used in IGP. After the MED attribute is set for routes, an EBGP peer can select a route with the smallest MED value for the traffic that enters an AS.
The MED serves as the metric used by an IGP. MED determines the optimal route when traffic enters an AS. When an MBGP router obtains multiple routes to the same destination address but with different next hops through EBGP peers, the route with the smallest MED value is selected as the optimal route.