BGP best-path calculation

When a BGP router learns multiple routes to the same NLRI, it must choose a single best route. The following list defines the BGP route selection decision process.
  1. Highest administrative weight: Administrative weight can be assigned to each NLRI locally on a router and the value cannot be communicated to another router. A higher value indicates a better route.

  2. Highest LOCAL_PREF PA: This attribute can be set on a router inside an AS and distributed inside the AS. A higher value indicates a better route.

  3. Locally injected routed: Pick the route injected into BGP locally using the network command redistribution.

  4. Shortest AS_PATH length: A shorter AS_PATH indicates a better route. This attribute counts each ASN in the AS_SEQUENCE as one.

  5. Origin PA: IGP (I) routes are preferred over EGP (E) routes, which are in turn preferred over incomplete (?) routes.

  6. Smallest Multi-Exit Discriminator (MED) PA: A smaller value indicates a better route.

  7. Neighbor Type: External BGP (eBGP) routes are better than internal BGP (iBGP) routes.

  8. IGP metric for reaching the NEXT_HOP: When comparing IGP metrics for each NLRIs NEXT_HOP, a smaller value indicates a better route.

  9. Keep the oldest eBGP route: If the routes being compared are eBGP and one is the best path, retain the existing best path. This action reduces eBGP route flaps.

  10. Choose the smallest neighbor router ID: Use the route with the smallest next-hop router router-id. Only perform this step if bgp bestpath compare-routerid is configured.

  11. Smallest neighbor ID: The local router has at least two neighbor relationships with a single other router. For this case, the router prefers the route advertised by the lowest neighbor ID.