How to configure BGP MED Attribute

Great explanation and difference on MED and AS PAth Prepending! Thanks Rene

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.

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 a global reach (although if you pre-pend with too long a path, you might get filtered). 2) MED is pretty far down on the BGP best path selection criteria, and BGP rarely gets to the point where MED would be a tie breaker.

For these reasons, everyone does AS-Path prepending for influencing inbound traffic flow.


Hi Rene/Andrew,

I have one question

I have two ISP A and B with two different provide and AS. i need incoming traffic should come from ISP A and outgoing traffic should go on ISP B.

so which attributes i need to use for this.


The question is whether you have your own AS number or not. If you don’t, you won’t have much control over incoming traffic from ISP A or ISP B. Let’s assume, however, you have been issued an Internet valid BGP Autonomous System number, and you have BGP peerings with both ISP A and ISP B.

You state you want incoming traffic to come from ISP A. In this case, you would use ASPath Pre-pending towards ISP B. This will make your AS Path appear longer (and therefore less desirable) when it is advertised from ISP B.

For outgoing traffic, you have lots of options. If you have only one Cisco router in your company, and it is peered with both ISPs, then you can use Weight. Otherwise, it would be best to use Local Preference, where you set a higher preference for where you want the outgoing traffic to flow (in this case, ISP B).

1 Like

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 Prepend on Houston router2.

thank you


Hi Hoan,
Yes, MED is communicated to iBGP peers. I tested that this morning. Since MED is an optional, non-transitive attribute, however, those iBGP neighbors will not transmit that MED to any EBGP neighbors they may have.

19 posts were merged into an existing topic: How to configure BGP MED Attribute

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 AS 1. <------- R2

late reply but thanks, it is fixed.

Hello Rene

please , how can in control downstream traffic between two bgp neighbor in Dual Homed bgp topology ? looking forward to your reply .

only two router with two different connections .

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 attribute
* AS PATH prepending
* Community/local pref agreement

Remember however, that the ISP has the final word for inbound traffic.

I hope this has been helpful!


Can you explain between:

  • deterministic-med
  • non-deterministic-med

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 X, if Internet Service Provider A (ISP A) sets the MED to 10, and ISP B sets the MED to 20, both ISPs agree that ISP A has the better performing path to X.

This information has come from the following Cisco documentation:

I hope this has been helpful!


It’s confusing when you say BGP MED aka/or/(Metric). Yes it’s a Metric in the CLI but in Cisco’s docs (at least some of them) it’s Multi Exit Discriminator. IF you search the cisco documentation I liked bellow about MED for Metric it doesn’t find anything. I think you should update your documents to at least mention the Cisco definition I liked. Thanks! I really enjoy your site!

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

The truth is that the original naming of the attribute was Inter AS Metric, and has since been changed to Multi Exit Discriminator, so this is the reason why the term Metric is still sometimes used.

However, to be absolutely correct, the term should be MED. I will let Rene know to clarify the wording to avoid confusion in the future.

I hope this has been helpful!


Absolutely brilliant!

I was going to ask the difference between MED and AS-PATH prepending but it has been answered. One more thing though at the beginning you wrote: “R1 and R3 will both advertise network /24 in BGP. We can use MED to tell AS 1 which path to use to reach this network”. I think it should be AS 2 instead


Hello sales2161

Yes, you are correct. I will let Rene know.



Afternoon chaps - I realise that MED is only meant for eBGP peers but is there actually anything in the BGP UPDATE message which would prevent it from being advertised to an iBGP neighbor?