OSPF learns the same prefix as intra-area, inter-area and external. Which wins?
Show the answer
Say this first
OSPF picks by route type first and cost second. Intra-area (O) beats inter-area (O IA), which beats external type 1 (E1 or N1), which beats external type 2 (E2 or N2). Cost only compares routes of the same type. All of them have administrative distance 110, so AD plays no part.
Go deeper
The order
Ointra-areaO IAinter-areaO E1orO N1O E2orO N2
An intra-area path with cost 500 beats an inter-area path with cost 10. This surprises people in designs where the same subnet is reachable inside the area over a slow link and through the backbone over fast ones.
Where it bites
- A backup WAN link placed in the same area as a branch makes the branch prefer the slow link, because the path becomes intra-area. Put the link in the right area or fix the design.
- Two ABRs summarizing differently produce a mix of more-specific and summary routes. Longest prefix match still applies first in the FIB, before any OSPF preference.
Order of decisions overall
Longest prefix match across all sources, then administrative distance between protocols, then this OSPF route-type order, then cost, then ECMP across equal-cost paths.
They will ask next
Does OSPF compare cost across E1 and E2 routes?
No. Any E1 wins over any E2. Cost only matters within the same type.
Traps
- Saying the lowest cost always wins in OSPF. Route type is checked before cost.