Course contents

Module 3: Path SelectionLesson 3.6 (6 of 13 in this module)15 of 43 in the BGP course

Attribute: MED

You have two links to the same provider and want traffic to use one. MED is the attribute made for that job, with a catch that trips up many designs.

Advanced · 9 min read

You'll learn to explain MED, set it for two links to one neighbouring AS, and say when it is ignored.

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.

MED works with one neighbouring AS, not across two
MED works with one neighbouring AS, not across twoLeft: R1 and R2 both connect to ISP A. The company sends MED 50 on one link and MED 100 on the other, and ISP A prefers MED 50. Right: the company connects to ISP A and ISP B with MED 50 and MED 100. Different ASes do not compare these values and MED is not passed on.Two links to the same ISP: MED worksLinks to two ISPs: MED does not steerISP AAS 64501R1AS 64500R2AS 64500MED 50MED 100ISP A prefers the lower MEDISP AAS 64501ISP BAS 64502CompanyAS 64500MED 50MED 100No router compares the two values.MED is not passed on to other ASes.

On small screens, swipe sideways or focus the diagram and use the arrow keys.

MED is a hint from one AS to one neighbouring AS. It cannot choose between two different providers.

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.

Where MED does and does not work
Where MED does and does not workThe neighbour must be the same AS.Two links to ISP AMED comparedLower value gets the trafficOne link each to ISP A and ISP BMED not compared by defaultUse prepending insteadAfter ISP A receives itMED is not passed onOnly affects ISP A

On small screens, swipe sideways or focus the diagram and use the arrow keys.

MED is not a tool for choosing between two different providers.

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 out

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

How the provider decides
How the provider decidesThe neighbour compares the values.R1 sendsmetric 50R3 sendsmetric 100ISP A compareslower value winsTraffic entersthrough R1

On small screens, swipe sideways or focus the diagram and use the arrow keys.

The request only works if the provider honours it.

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

Illustrative Cisco IOS XE output written for this lesson, not a router capture
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
ISP A hears the same prefix from the company on two links. Both come from AS 64500, so MED is compared. Metric 50 is lower than 100, so the path through R1 is best.

Check your understanding

Predict · scenario 1

A company has one link to ISP A and one to ISP B. Does MED choose between them by default?

Predict · scenario 2

R1 sends MED 50 and R3 sends MED 100 to ISP A. Which link does ISP A prefer?

Predict · scenario 3

Does ISP A pass your MED on to ISP C?

FAQ

Is a higher MED better?
No. Lower MED wins, because MED works like a metric. A MED of 50 beats a MED of 100.
Why is my MED ignored?
By default a router compares MED only between paths that came from the same neighbouring AS. Paths from different providers are not compared on MED.
Does MED cross several autonomous systems?
No. A MED received from a neighbour is not sent on to other autonomous systems. It affects only the AS that received it.