How to configure BGP MED Attribute

MED (or metric) is the sixth BGP attribute:

  • MED can be used to advertise to your neighbors how they should enter your AS.
  • MED is exchanged between autonomous systems.
  • The lowest MED is the preferred path.
  • MED is propagated to all routers within the neighbor AS but not passed along any other autonomous systems.

Let’s look at an example:

bgp med topology

MED (also called metric) is exchanged between autonomous systems and you can use it to let the other AS know which path they should use to enter your AS. R2 is sending a MED of 200 towards AS 3. R3 is sending a MED of 300 to AS 3. AS 3 will prefer the lower metric and send all traffic for AS 1 through R2. Let me show you how to configure this on a Cisco router:

bgp as path prepend lab

Above we have two autonomous systems. R1 and R3 will both advertise network /24 in BGP. We can use MED to tell AS 2 which path to use to reach this network.

R1(config)#router bgp 1
R1(config-router)#neighbor remote-as 2
R1(config-router)#network mask
R3(config)#router bgp 1
R3(config-router)#neighbor remote-as 2
R3(config-router)#network mask
R2(config)#router bgp 2
R2(config-router)#neighbor remote-as 1
R2(config-router)#neighbor remote-as 1

This is the BGP configuration, nothing special so far.

R2#show ip bgp 
BGP table version is 2, local router ID is
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*             0             0 1 i
*>                     0             0 1 i

You have seen the example above before. R2 prefers the path through Note that the default metric (MED) is 0. Let’s play with the MED now:

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now! Here is why:

  • Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.
  • Try for Just $1. The Best Dollar You’ve Ever Spent on Your Cisco Career!
  • Full Access to our 707 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

513 Sign Ups in the last 30 days

100% Satisfaction Guaranteed!
You may cancel your monthly membership at any time.
No Questions Asked!

Forum Replies

  1. Hi Kandhla,

    It’s up to the network engineers / ISPs but there is one key difference between AS path prepending and MED:

    • When you use AS path prepending, it will show up at your neighbor AS and all other ASes behind them.
    • When you use MED, it will show up at your neighbor but NOT at any AS behind them.


  2. So how is MED different from AS Path Prepend? MED only affects your single neighbor AS where AS PATH prepend would be sent to all AS’s?

    Also I thought MED standing for Multi Exist Discriminator… not sure where I got that.

  3. MED = Multi-Exit Discriminator

    AS Path pre-pending and MED are both ways in which you are trying to influence inbound traffic into your AS–these are really the only two tools available for you for this purpose. So you are right in the sense that they serve the same purpose, but they do so via different BGP attributes (obviously). In reality, almost no-one uses MED, for two reasons: 1) As you point out, MED will only be learned by your directly connected neighboring AS, so it won’t do much for influencing traffic beyond that. AS-Path prepending, however, has

    ... Continue reading in our forum

  4. Hello Rawaz.

    If I understand correctly, your scenario involves a dual homed BGP topology and you want to know how to control, or at least influence, inbound traffic, correct?

    Because inbound traffic is essentially sent to you, you do not have the ultimate control of how traffic enters your AS. Your ISP may have outbound policies that will always override all of your attempts to influence inbound traffic. However, you do have the option of influencing inbound traffic. There are several ways to do this including:

    * Leaking more specific routes
    * Using the MED

    ... Continue reading in our forum

  5. Hello Brian

    Thanks for bringing this to our attention. I can understand how this can be confusing. According to this Cisco documentation, MED is also known as the external metric of a route, because the lower the MED value, the more preferred a route becomes.

    Similarly, the following BGP case studies documentation refers to MED as “the metric attribute” which is also known as “MED”.

    ... Continue reading in our forum

41 more replies! Ask a question or join the discussion by visiting our Community Forum