Sub topic 13
Route Types and Path Preference
This chapter assumes you know how LSA types 1 to 5 work, how SPF computes cost, and how longest-prefix match picks a route from the routing table.
The Four Route Types
OSPF labels every route it installs according to how the router learned it. The label decides which route wins when several candidates exist for the same prefix.
| Code in `show ip route` | Route type | Learned from | Cost metric |
|---|---|---|---|
| O | Intra-area | Type 1 and 2 LSAs in the same area | Sum of link costs |
| O IA | Inter-area | Type 3 LSAs from an ABR | Cost to ABR plus ABR's advertised cost |
| O E1 | External type 1 | Type 5 LSA from an ASBR | External cost plus internal cost to the ASBR |
| O E2 | External type 2 | Type 5 LSA from an ASBR | External cost only (default) |
Path Preference Order
When OSPF has several routes to the same prefix, it prefers route types in a fixed order, before it looks at cost:
- Intra-area (O)
- Inter-area (O IA)
- External type 1 (O E1)
- External type 2 (O E2)
Cost only breaks ties within the same type. An intra-area route with cost 500 beats an inter-area route with cost 5.
This order is separate from longest-prefix match. A router first picks the most specific prefix in the table. The preference order applies only when OSPF has several routes to the same prefix.
E1 Versus E2
The difference matters when a network has more than one ASBR.
- E2 is the default. Its metric is the external cost set at redistribution and does not change as the route crosses the network. Every router sees the same metric, so cost to the ASBR matters only as a tiebreaker.
- E1 adds the internal cost to reach the ASBR at each hop. Use it when several ASBRs advertise the same prefix and you want each router to pick the closest exit.
Suppose ASBR-A and ASBR-B both advertise 203.0.113.0/24 with external cost 20. As E2, both routes show metric 20 on every router. As E1, a router three links of cost 10 from ASBR-A and one link of cost 10 from ASBR-B sees metrics 50 and 30, and picks ASBR-B.
Common Errors
- Expecting a lower-cost inter-area route to beat an intra-area route. It never does.
- Mixing E1 and E2 for the same prefix. E1 always wins, whatever the metrics.
- Comparing E2 metrics across routers and assuming they reflect distance. They do not.
Exercise
R1 learns 10.5.0.0/16 two ways: an inter-area route with cost 10 and an E1 route with cost 5. Which does R1 install, and why?
Show answer
R1 installs the inter-area (O IA) route. OSPF compares route types before cost, and inter-area ranks above external type 1. The lower E1 cost is not considered.
Exercise
Two ASBRs advertise the same prefix as E2 with external cost 20. R1 is 10 away from ASBR-A and 40 away from ASBR-B. Which ASBR does R1 use, and what metric does the route show?
Show answer
R1 uses ASBR-A. E2 metrics tie at 20, so OSPF breaks the tie with the lower internal cost to the ASBR (10 versus 40). The route shows metric 20.