BGP Always-Compare-MED

The following is a great example of “more than meets the eye”!  During my CCNP studies, I learned the BGP Best Path Selection Process inside and out…. or so I thought.  The Best Path Selection Process is the process BGP uses to select the best path to a target prefix. 

Depending on who sources the documentation, this process is described as having 9, 10, 11, 12, etc decision making mechanisms and they are “roughly” as follows:

1. BGP prefers the path with the highest weight. Note that the BGP weight parameter is a Cisco-specific parameter.

2. BGP prefers the path with the highest local preference value.

3. BGP prefers the path originated by BGP on the local router.

4. BGP prefers the path with the shortest autonomous system.

5. BGP prefers the path with the lowest origin type. (NOTE: IGP < EGP< INCOMPLETE.)

6. BGP prefers the path with the lowest multi-exit discriminator (MED).

7. BGP prefers eBGP paths over iBGP paths.

8. BGP prefers the path with the lowest IGP metric to the BGP next-hop.

9. BGP prefers the path that points to a BGP router with the lowest BGP router ID.

During my CCIP/CCIE studies, I learned that the preceding selection process is much more complicated.  Please visit the following link for a very well documented blog about this process:

http://rbcciequest.wordpress.com/2008/02/27/bgp-path-selection/

I apologize for having an attack of ADD but I felt obligated to provide a bit of history before waxing the following topic…..

***NEWS BULLETIN***

Did you know that if the same prefix is learned by different ASs, the BGP Best Path Selection Process will not take the MED into consideration and continue on with the BGP Best Path Selection Process?

 Let’s face it.  When uber-geeks like us learn something new and unexpected, we do the following, “OMG!!!!  Did you just see that!  That is the coolest thing EVER!!!!”.

Don’t try denying it 😉  You now that feeling…. You love that feeling….  And you can’t get enough of it!  OK, enough fanaticizing!  Let’s move on 😉

Please view the following topology:

As you can see, R1 selected the path with the higher MED of “2000”:

BGP disregarded the MED, continued down the Best Path Selection Process and selected the advertisement originating from the BGP advertiser with the lowest RID!

Again, this is a result of the Best Path Selection Process ignoring the MED because the 1.1.1.1 prefix is being advertised from different ASs.

Now let’s use the “bgp always-compare-med” command under the BGP process on R1:

And clear the BGP process……

And BAMM! 

Isn’t that just b.e.a.utiful?

So there you have it.  If you like BGP to compare the MED when a prefix is advertised by more than 1 AS, issue the “bgp always-compare-med” command under the BGP process.

Until next time,

LAB ON!!!!

Posted on November 23, 2010, in BGP. Bookmark the permalink. Leave a comment.

Leave a comment