OSPF Path Selection — Route Type Preference
Core idea
When OSPF has multiple routes to the same destination, it compares the route type first, before metric. A more-preferred route type always wins, regardless of cost — the metric only breaks ties within the same type. This is why a “slower” path can still be chosen over a “faster” one.
Preference order
From most preferred to least preferred:
- Intra-area (
O) - Inter-area (
O IA) - External Type 1 —
E1andN1 - External Type 2 —
E2andN2
Type beats metric
Intra-area is preferred over inter-area, and both are preferred over any external route, regardless of cost. A Type 1 external (E1/N1) always beats a Type 2 external (E2/N2), also regardless of cost. Cost is only compared to break a tie between routes of the same type.
Why Type 1 beats Type 2
The difference is metric accuracy:
- Type 1 (E1/N1) = external (redistributed) cost + the internal cost to reach the ASBR. The metric grows hop by hop across the OSPF domain, so it reflects the true end-to-end cost.
- Type 2 (E2/N2) = external cost only. The internal cost to reach the ASBR is ignored, so the metric stays constant across the domain (this is the default for redistributed routes).
Because E1/N1 carries a more complete picture of the real path cost, OSPF trusts it over E2/N2.
N1 vs E1 (and N2 vs E2)
The N-over-E preference is a tie-breaker, not absolute
The order
O > O IA > N1 > E1 > N2 > E2comes from RFC 3101, which Cisco IOS uses by default since 15.1(2)S (it replaced the older RFC 1587 order, where E1 beat N1). But N1 and E1 are the same external class, so OSPF compares cost first. The N-over-E preference only applies when the costs are equal. A lower-cost E1 will beat a higher-cost N1.
Why the tie-break favors the NSSA route
The mechanism is the P-bit. A Type-7 LSA (NSSA, the N route) carries the P-bit set to 1. When an ABR translates a Type-7 into a Type-5 (the E route), the P-bit is cleared to 0. So on an equal-cost tie, the route with the P-bit set — the N route — wins. This only matters when the same prefix is learned as both an NSSA external and a regular external.
Example 1
/ospf---open-shortest-path-first/ospfv2/photos/pasted-image-20260801125204.png)
Resultado: La mejor forma de mover los paquetes desde R2 a Loopback (Area 0) es a traves de R5, y No a traves de r3. No importa que la interfaces sean Seriales contra Giga.
Example 2
/ospf---open-shortest-path-first/ospfv2/photos/pasted-image-20260801130743.png)
Resultado: (Ruta Inter Area: R9 quiere enviar un paquete a Area 1 entre R1 e R4).
El paquete tiene que pasar por el Area 0 porque no llegara directamente (No elegira su ruta directa por R4).