It is known for all of us that when two routes are received from the same routing protocol, the route with the lowest metric will be selected and installed in the routing table.
In OSPF this is only true when the two routes are of the same type.
OSPF has the following route types:
- Intra-area routes: Intra-area routes are those which are originated and received from routers in the same area.
- Inter-area routers: Routes that are originated in different areas are considered inter-area routes.
- External routes: Routes that do not belong to the OSPF domain and were inserted from another routing protocol using redistribution for example. External routes can be type1 or type2 routes.
The following criteria is used by OSPF to select best routes:
- Intra-area routes.
- Inter-area routes.
- External type 1 routes.
- External type 2 routes.
- Route with the lowest cost if the same type.
- If cost is the same both routes will be installed in the routing table and load balance occurs.
The above criteria is very important to remember because sometimes you expect a certain behavior in the OSPF domain based on the metric of the routes while the network is not working as you except because route type has came into play and routes are installed based on route types.