8.8 Issue with Using Private AS  Numbers
8.8.7
The MULTI_EXIT_DISC (MED) attribute
The Mutliexit Discriminator (MED) attribute is an optional nontransitive attribute (type code 4). It is a hint to external neighbors about the preferred path into an AS that has multiple entry points; a lower MED is preferred over a higher MED.

Unlike local preference, the MED attribute is exchanged between ASs, but a MED attribute that comes into an AS does not leave the AS. When an update enters the AS with a certain MED value, that value is used for decision-making within the AS. When BGP passes on the routing update to another AS, the MED is reset to zero (unless the outgoing MED is set to a specific value).

When the route is originated by the AS itself, the MED value follows the internal IGP metric of the route. This becomes useful when a customer has multiple connections to the same provider. The IGP metric reflects how close or how far a network is to a certain exit point. A network that is closer to exit point A than to exit point B will have a lower IGP metric in the border router connected to A. When the IGP metric translates to MED, traffic coming into the AS can enter from the link closer to the destination because a lower MED is preferred for the same destination. This can be used both by providers and customers to balance the traffic over multiple links between two ASs.

Unless otherwise specified, the router compares MED attributes for paths from external neighbors that are in the same AS. MEDs from different ASs are not comparable because the MED associated with a route usually gives some indication of the AS internal topology. Comparing MEDs from different ASs would be like comparing apples and oranges. Still, for administrators who have a reason to do so, Cisco offers the bgp always-compare-med router command.

In the local preference example shown previously, an AS was shown determining how to influence its own outbound decision. In the example illustrated in the figure, the MED shows how an AS can influence the outbound decision of another AS. In the Figure, ANET and YNET try to influence the XNET outbound traffic by sending it different metric values.

XNET is receiving routing updates about 128.213.0.0/16 from three different sources; San Jose (metric 120), Los Angeles (metric 200), and New York (metric 50). San Francisco will compare the two metric values coming from ANET and will prefer the San Jose router because it is advertising a lower metric (120). When the bgp always-compare-med router configuration command is used on the San Francisco router, it will then compare metric 120 with metric 50 coming from New York and will prefer New York to reach 128.213.0.0/16. Note that San Francisco could have influenced its decision by using local preference inside XNET to override the metrics coming from outside ASs. Nevertheless, MED is still useful in case XNET prefers to base its BGP decisions on outside factors to simplify router configuration on its end. Customers that connect to the same provider in multiple locations could exchange metrics with their providers to influence each other's outbound traffic, leading to better load balancing.