When routers have more than one route to the same destination, they need to go through a route selection process to determine which to use. Working out why a particular path is being used is sometimes difficult, so knowing how the end result is achieved is useful. The steps below follow in a top-down way, ending with a final tie-breaker just in case the two routes are equal in all other respects:
1. Route Preference – if there is an OSPF route and a BGP route for the same destination, OSPF is selected since it has a lower preference (10 versus 170). Cisco IOS calls this “Administrative Distance”. You can change these defaults if you want – they are local to the router so will not affect other routers.
2. Local Preference – this is a value received in BGP routes. It defaults to 100, but can be modified. A higher preference wins here, but if the two routes are the same, we move on to step 3.
3. AS Path – The AS path is built up as routes are advertised between autonomous systems. A shorter path is better because it indicates fewer AS “hops” – i.e. the destination is theoretically closer over a shorter path.
4. Origin – the route’s origin code says whether it originated from an IGP (flagged as I), from an EGP (E) or is unknown (?). Origin I is most preferred and ? is least preferred. The thinking behind this is that a route that originated from an IGP is most likely to be accurate whereas ? is less reliable information.
5. MED – Multi-Exit Descriminator is a route attribute that ISP A sends to ISP B to get B to send traffic to A over one particular link (assuming there are two running between them and one is more preferable). ISP B may ignore this hint and just send traffic down whichever it prefers, of course. A lower MED is preferred.
6. EBGP over IBGP – if the route is learned via EBGP as well as IBGP, the EBGP one is chosen. The object is to choose the most efficient path to the destination, so if the route is coming from outside, that is probably the best path to choose. EBGP wins here.
7. Lowest IGP cost – if the routes are both learned via IBGP, the one that gets selected is the one with the lowest IGP cost to the destination.
8. Shortest Route Reflection Cluster List – if the routes were received via reflection, the one with the shorted cluster list is picked. If the route wasn’t received from a route reflector, this step is skipped.
9. Lowest Router ID – the advertising peer with the lowest router-ID wins. Router ID is normally derived from the loopback address of the router.
10. Lowest peer address – the route received via the lowest peer IP address wins. This step is the final tie-breaker.
If you are receiving two routes for a destination network, you can do a “show route <network> detail” to get more information about those routes. The “detail” flag will tell you which one is being used, what the origin code is, AS path etc.