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 739 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

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

  2. Hi Rene

    Does MED distributed to other routers within same AS? I have mpls cloud provided by Verizon, Verizon AS 65000,
    my office1 in Houston AS 65400 has two routers, router1 and router2, each has a mpls connections to Verizon , router2 is backup and configure MED 10.
    my office2 is in Sanfrancisco AS 65401. sometimes I have some unexplained network issue, connectivity from Sanfrancisco to Houston.
    I wonder if MED is the issue not being distributed to all Verizon routers in the mpls cloud and cause asymmetric routing, I am thinking changing MED to AS Path Pr

    ... Continue reading in our forum

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

  4. Hello Nguyen

    The following excerpt from Cisco documentation very clearly describes the use of these features:

    Enabling the bgp deterministic-med command ensures the comparison of the MED variable when choosing routes advertised by different peers in the same autonomous system. Enabling the bgp always-compare-med command ensures the comparison of the MED for paths from neighbors in different autonomous systems. The bgp always-compare-med command is useful when multiple service providers or enterprises agree on a uniform policy for setting MED. Thus, for network

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

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