BGP question: Default MED

Unanswered Question
Sep 24th, 2009

Hi guys! here again with some questions:

While using BGP, I've read that prefixes have a default MED of 0 if no value is present in the updates of a EBGP peer.

My questions is, why some times the MED is present and some others it does not? I mean in the output of the " show ip bgp" I was trying to figure it out, and at first i tought that it displayed a 0 if the prefix was originated in the contiguous AS, but i found other prefixes originated many AS hops away that also displayed a 0 in the "show ip bgp". So what's the rule here? I know for example, that Local Preference defaults to 100 on prefixes from IBGP peers, but for EBGP prefixes it displays nothing, but for MED?

Thanks in advance!!

I have this problem too.
0 votes
  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
Giuseppe Larosa Fri, 09/25/2009 - 03:57

Hello Omar,

the key point is that BGP allows to advertise prefixes without a MED attribute so there is not a single rule that everyone follows.

The presence of MED or not depends also on the way the prefix is injected in the BGP table on BGP originator node.

it is possible to mark a missing MED as worst using

bgp bestpath med missing-as-worst



Hope to help


omarmontes Fri, 09/25/2009 - 07:52

Here is a printscrint of the output, sorry for the screenshot, It's from a PDF and can't copy it.

And yes :P I did it in a rack so it's not a missprint haha, in real devices it does the same thing.

What I'm looking for is some kind of rules as to when does it put a 0. For example, in the output the 67.7 router is a EBGP peer, but ive seen the same think (no MED, or at least not showed) from IBGP peers.

thanks in advance!

Giuseppe Larosa Fri, 09/25/2009 - 10:58

Hello Omar,

by looking at your sh ip bgp example we can make some notes:

advertisements with MED=0 are the result of the usage of network command on originating router.

We can notice the origin code i (rightmost character in the line).

instead the lines that refer to advertisements with a missing MED attribute have origin code ? so they are the result of redistribution into BGP of another routing protocol (or connected or static).

Here best paths are chosen based on the shortest AS path (> symbol).

Hope to help


omarmontes Fri, 09/25/2009 - 11:21

Thanks Giuseppe, that's what I though too, but I've seen that this is not consistent, look at the following output, where some eBGP routes have the MED=0 and some does not:

Giuseppe Larosa Fri, 09/25/2009 - 11:35

Hello Omar,

I wonder if a route-map setting origin to i has been used to create the eBGP routes with origin i and missing MED.

This is technically possible (set origin igp in route-map config).

But it looks like we cannot say anything definitive here.

I can say that MED can miss on a great quota of BGP routes in a real BGP table.

So, you cannot be sure that MED is present in a line of a sh ip bgp.

Hope to help


omarmontes Sat, 09/26/2009 - 09:27

I solved this trough trial&error, made some scenarios and here is the resulting rules:

1.- If the prefix is comming from a iBGP peer and the metric is not set, the "show ip bgp" shows MED = 0.

2.- If the prefix is comming from a eBGP peer, the metric is not set, and that eBGP peer is the originator of the prefix (by means of redistribution or network statement), the "show ip bgp" shows MED = 0

3-. If the metric has been modified, then for every prefix from (iBGP and eBGP) the MED is shown.

3.- Else, MED = null

Thanks for the help!

AJAZ NAWAZ Thu, 04/22/2010 - 08:39

The problem with a MED value of zero is that it wins in most cases, which may not necessarily result in the best path (or preferred path). That is because if MED is inserted into BGP updates from external peers, the number is more often than not >0

I question why iBGP updates even contain a MED value at all. Its purpose it to hint to external neighbors about preferred inbound paths.


vishwancc Thu, 04/22/2010 - 22:00

Hi Ajay,

I question why iBGP updates even contain a MED value at all. Its purpose it to hint to external neighbors about preferred inbound paths.

---->1 use for this is when you are using Multihoming with single ISP,since MED vlaue do not cross the AS others router in the
AS come to know about the exit point for the destination network ( customer ) through that MED which is used by IBGP ,you could also use AS prepend to acheive this but when you have multihoming with single ISP MED is a better option since the memory and processing required for AS prepend routes are more.




This Discussion