How BGP Selects Paths

A router running Cisco IOS Release 12.0 or later does not select or use an IBGP route unless both of the following are true:

       the router has a route available to the next-hop router

       the router has received synchronization via an IGP (unless IGP synchronization has been disabled)

BGP bases its decision process on the attribute values. When faced with multiple routes to the same destination, BGP chooses the best route for routing traffic
toward the destination. The following process summarizes how BGP chooses the best route.

       1. If the next hop is inaccessible, do not consider it. 

       This is why it is important to have an IGP route to the next hop. 

       2. If the path is internal, synchronization is enabled, and the route is not in the IGP, do not consider the route.

       3. Prefer the path with the largest weight (weight is a Cisco proprietary parameter).

       4. If the routes have the same weight, prefer the route with the largest local preference.

       5. If the routes have the same local preference, prefer the route that was originated by the local router. 

       For example, a route might be originated by the local router using the network bgp command, or through redistribution from an IGP.

       6. If the local preference is the same, or if no route was originated by the local router, prefer the route with the shortest autonomous system path. 

       7. If the autonomous system path length is the same, prefer the route with the lowest origin code (IGP < EGP < INCOMPLETE). 

       8. If the origin codes are the same, prefer the route with the lowest Multi Exit Discriminator (MED) metric attribute. 

       This comparison is only done if the neighboring autonomous system is the same for all routes considered, unless bgp always-compare-med is enabled. 

       9. If the routes have the same MED, prefer the external (EBGP) path over the internal (IBGP) path.

       All confederation paths are considered internal paths, but Confederation EBGP is preferred over Confederation IBGP.

       10. Prefer the route that can be reached through the closest IGP neighbor (the lowest IGP metric).

       This means the router will prefer the shortest internal path within the autonomous system to reach the destination (the shortest path to the BGP next-hop).

       11. If the following conditions are all true, insert the route for this path into the IP routing table: 

              Both the best route and this route are external.

              Both the best route and this route are from the same neighboring autonomous system.

              maximum-paths is enabled.