Официален блог на WebEKM EKM очаквайте сайта онлайн скоро.

Download Free Templates http://bigtheme.net/ free full Wordpress, Joomla, Mgento - premium themes.

BGP MED attribute – understanding of
‘bgp deterministic-med’ and ‘bgp always-compare-med’ commands

Thanks to MED attribute we have influence on how adjacent eBGP router should get into our AS.It is especially helpful if we have 2 or more eBGP entrance into our AS.  Now, we will check how a single eBGP router that  receives MED attribute for the same prefix from many eBGP speakers and different AS processes metric attribute.



Lab consists of 4 Autonomous Systems A1,A2,A3,A5. The goal of this lab is understanding how MED attribute (metric) works in BGP, so we don’t need full reachability between R1 in AS1 and prefix in AS5. We only need to get this prefix from updates from R2, R3 and R4. The lab that is ready to download contains everything what is needed to practice this topic. ASs are configured, also loopback is already injected into BGP process with ‘network’ command on R6.  


Here is entire topology of our lab.

Here you may download the lab from Mega Upload with decryption key:



in order tu unpack the rar file use as usual password :



Before we go over the MED we have to know what attribute is being taken into consideration if we have 2 or more EXACT path to reach given prefix and we are not going to compare MED. This attribute is Route Age as the next attribute from the best path attribute algorithm.  BGP prefers the route that has been learned first (the older entry in BGP table). In case of the lab we have 3 paths from R1 via R2, R3 and R4. I have set up also the metrics with route-maps for particular paths via R2 – 200, via R3 – 150 and via R4 -50. Remember the lowest metric (MED) is always prefered if is being compared so R4 should takes precedence, unless … First things first.

Firstly let’s learn 2 crucial commands that are being run under BGP process in order to influence on metric behaviour:
bgp deterministic-med – this command is being used only against single AS. BGP router will be comparing only MED attribute from the routers that belong to the same AS (in our case AS2). So only between R2 and R3 MED will be compared. 

bgp always-compare-med – this command is being used to compare MED attribute from all eBGP peers, from different AS. In our case MED will be compared between R2, R3 also R4.

Firstly let’s check how BGP table of R1 looks without above 2 commands.


Stage 1



If we don’t compare MED between R1 and R2 also between AS2 and AS3 then the oldest path wins! This is exactly what we see. R2 has the highest MED 200 for prefix but wins, because this entry is the oldest in BGP table of R1 (The oldest entry is lowest, the newest at the top).


Stage 2

Let’s run command ‘bgp deterministic-med’  on R1 to start compare MED between R2 and R3

Now, BGP process starts to compare MED from routers from AS2 and they have been groupped together. Path via R2 is still an older entry then via R3, but since MED is being taken into consideration, the path via R3 is prefered. R4 from AS3 in not being taken into consideration until we force that with command ‘bgp always-compare-med’.

Stage 3

Let’s runbgp always-compare-med’  on R1 to start compare MED between AS2 and AS3 BGP routers.

Now, BGP process on R1 compares MED attribute from all 3 routers from AS2 and AS3. This is exactly what we wanted to achieve. The path with lowest metric wins, besides all path have been lay out properly in the BGP table from the lowest MED to the highest!

Default Behaviour

What is worth to mention is  that by default BGP compares MED attribute from routers within the same AS. I our case R2 and R3. We don’t have to configure anything. Let’s have  a look on R1 BGP table :


If by default, BGP process compares MED in the same AS we should get the same outcome as in Stage 2 when we run bgp deterministic-med. The same path with metric 150 is choosen as the best, but BGP table looks differently, because entries haven’t been groupped.

, ,

Onlain bookmaker bet365.com - the best bokie