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

Configuration

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

561 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. please check your article. the example you have given and configuration you did.

  2. Thanks Husain, I just fixed the names so that the pictures match the configurations.

  3. why are u running this command and please also tell me what are med and local preference.

    neighbor 192.168.23.2 route-map MED out

    i think it should be

    neighbor 192.168.23.2 route-map MED in

    please clear it

  4. MED is used to tell your neighbor AS what link they should use to send traffic to your AS. Local preference is used to select an exit path for your AS.

    The route-map is correct as we are sending the metric to our neighbor AS. For local preference you’ll need an inbound route-map.

  5. Another fun fact: Although MED is a discretionary non-transitive attribute, it IS transitive across confederation ASes.

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