Please go through the following post to learn about MED in BGP and its influence for path selection for the routes learned from same AS.
BGP Path Selection by MED (Multi-Exit Discriminator)
Above example and most of the examples you may find online or in books are created for routes learned for same AS. But in Cisco IOS, MED is not taken in to the consideration if the routes are coming from different ASes.
Let's see such an example..
See the snippet, All are eBGP neighbors and R4 on AS 400 is originating a route 44.44.44.44/32 and propagating to R3 through R1 and R2.
R1 and R2 are configured with route-maps to manually set the MED because they are not originating the prefix and needs advertise the MED to an eBGP neighbor R3..
Following are the configurations of the routers..
By examining the configuration you can see a low metric is advertised by R2.
Let's see the BGP table of R3,
As you can see, It is chosen the high metric route as the best route..
According to the best path selection algorithm of Cisco IOS,
(01) Weight (highest preferred,)
(02) Local Preference (highest preferred)
(03) Origination ((local originate, next-hop 0.0.0.0 preferred))
(04) AS Path (shortest preferred)
(05) Origin Code (i preferred over ?)
(06) MED (lowest preferred, compared if routes learned from same AS by default)
(07) Path Type (external preferred over internal)
(08) IGP metric to Next-hop (lowest preferred, if equal go to next step)
(09) Multipath configured check (if configured, install in local routing table and go to next step)
(10) Age of the Route (oldest preferred, compares for external routes only)
(11) Router ID (lowest preferred, Originator ID is used as router-id for routes learned from RRs)
(12) Cluster List length (shortest preferred, learned from clients preferred over non-clients)
(13) Neighbor ID (lowest preferred)
In this case if MED is not taken into consideration, all are equal until the Age of the Route. So the 1st learned route should be from the 1.1.1.1 and it is preferred here. This is because the route is learned via 2 ASes and MED is compared for the routes learned via same AS by default..
How ever we can change this behavior by entering the following command in BGP process of R3,
R3(config-router)#bgp always-compare-med
Let's see the BGP table of R3,
As you can see, It is chosen the high metric route as the best route..
According to the best path selection algorithm of Cisco IOS,
(01) Weight (highest preferred,)
(02) Local Preference (highest preferred)
(03) Origination ((local originate, next-hop 0.0.0.0 preferred))
(04) AS Path (shortest preferred)
(05) Origin Code (i preferred over ?)
(06) MED (lowest preferred, compared if routes learned from same AS by default)
(07) Path Type (external preferred over internal)
(08) IGP metric to Next-hop (lowest preferred, if equal go to next step)
(09) Multipath configured check (if configured, install in local routing table and go to next step)
(10) Age of the Route (oldest preferred, compares for external routes only)
(11) Router ID (lowest preferred, Originator ID is used as router-id for routes learned from RRs)
(12) Cluster List length (shortest preferred, learned from clients preferred over non-clients)
(13) Neighbor ID (lowest preferred)
In this case if MED is not taken into consideration, all are equal until the Age of the Route. So the 1st learned route should be from the 1.1.1.1 and it is preferred here. This is because the route is learned via 2 ASes and MED is compared for the routes learned via same AS by default..
How ever we can change this behavior by entering the following command in BGP process of R3,
R3(config-router)#bgp always-compare-med
No comments:
Post a Comment