The single best path toward a destination are as follows. Note that only routes with no AS loops and that have a valid next-hop are candidates for this selection process.
The following order is used by Cisco routers:
- Prefer the highest weight (local to the router) — default = 0
- Prefer the highest local preference (propagated to other routers within the AS) — default = 100
- Prefer a route originated by the local router (where next hop is 0.0.0.0)
- Prefer the shortest AS Path
- Prefer the lowest origin code (where i < e < incomplete)
- Prefer the lowest MED (exchanged between autonomous systems)
- Prefer an EBGP path over an IBGP path
- Prefer the path through the closest IGP neighbor
- Prefer the oldest route for EBGP paths
- Prefer the path with the lowest neighbor BGP RID
- Prefer the path with the lowest neighbor IP address
Notes:
- The MED is only compared if the paths were originated in the same AS. To always check MED, the Cisco command bgp always-compare-med can be entered to require it, allowing MED to be applicable for comparison when prefixes originate in different ASNs.
- IETF and Cisco differ in the value assigned to a missing MED. Where the IETF assigns a value of infinity to a missing value, making it the least preferred, Cisco makes it the most preferred (zero). To change the Cisco value to match the IETF standard, enter the bgp bestpath missing-as-worst command.
- Origin Codes: “i” is typically seen when a route is advertised locally with the network keyword. “e” is learned through another peer/speaker, while “?” is incomplete, typically due to redistribution from static route or other IGP.