What MED is
The multi-exit discriminator is an optional non-transitive attribute, shown as metric in Cisco output. You attach it to routes you send to a neighbouring AS to say which of several links into your network you would like it to use. Lower wins.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
When MED applies
MED is useful in one situation: you have two or more links to the same neighbouring AS. By default a Cisco router compares MED only between paths that came from the same neighbouring AS, so MED never decides between ISP A and ISP B.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
MED sits at step 6 of the best-path list, after ORIGIN. It is only reached when every earlier attribute ties, which also means a provider setting local preference on customer routes can override it.
Setting MED
! On R1, the preferred entry point
route-map TO-ISPA-MED permit 10
set metric 50
!
router bgp 64500
address-family ipv4 unicast
neighbor 192.0.2.1 route-map TO-ISPA-MED out
! On R3, the backup entry point (a second link to ISP A)
route-map TO-ISPA-MED permit 10
set metric 100
!
router bgp 64500
address-family ipv4 unicast
neighbor 192.0.2.9 route-map TO-ISPA-MED out
end
clear ip bgp * soft outTwo company routers connect to ISP A. ISP A compares 50 and 100 and sends traffic for the company prefix in through R1. R3 is a hypothetical second router added here for illustration.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Related settings
Two commands change how MED is compared. bgp always-compare-med compares MED between paths from different neighbouring ASes, which can give surprising results if the providers use different scales. bgp deterministic-med makes the comparison independent of the order in which paths arrived. A missing MED is treated as 0 unless bgp bestpath med missing-as-worst is set.
Reading MED
ISP-A#show ip bgp 198.51.100.0 BGP routing table entry for 198.51.100.0/24, version 8 Paths: (2 available, best #1, table default) 64500 192.0.2.2 from 192.0.2.2 (1.1.1.1) Origin IGP, metric 50, localpref 100, valid, external, best 64500 192.0.2.10 from 192.0.2.10 (3.3.3.3) Origin IGP, metric 100, localpref 100, valid, external
Check your understanding
A company has one link to ISP A and one to ISP B. Does MED choose between them by default?
R1 sends MED 50 and R3 sends MED 100 to ISP A. Which link does ISP A prefer?
Does ISP A pass your MED on to ISP C?