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 1.1.1.0 /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 192.168.12.2 remote-as 2
R1(config-router)#network 1.1.1.0 mask 255.255.255.0
R3(config)#router bgp 1
R3(config-router)#neighbor 192.168.23.2 remote-as 2
R3(config-router)#network 1.1.1.0 mask 255.255.255.0
R2(config)#router bgp 2
R2(config-router)#neighbor 192.168.12.1 remote-as 1
R2(config-router)#neighbor 192.168.23.3 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 192.168.23.2
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
*  1.1.1.0/24       192.168.23.3             0             0 1 i
*>                  192.168.12.1             0             0 1 i

You have seen the example above before. R2 prefers the path through 192.168.12.1. Note that the 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 655 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

546 Sign Ups in the last 30 days

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

Forum Replies

  1. First of Congratulation Rene…for ur CCIE Number… U deserve it. The lab u post & the way u write article in most simple form is simply amazing. Why don’t u start writing books for CCIE R&S TS… I would love to hv one in my collection. Wish u all the success. I m a fan of ur blog who is chasing the dream of CCIE R&S.

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

    Rene

  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.

    ... Continue reading in our forum

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