OSPF Route Type

There are three main route types that can be learned with OSPF.

  1. Intra Area Route
    1. Networks in the same area
    1. OSPF routes based on LSA type 1 and LSA type 2
    1. Code “O”
  2. Inter Area Route
    1. Network in other areas
    1. OSPF routes based on LSA type 3
    1. Code “O IA”
  3. External route
    1. Networks in non-OSPF domains
    1. OSPF routes based on LSA type 5
    1. Code “O E1” or “O E2”

The best route for OSPF is determined by the cumulative path cost. For example, in the following figure, the best route from R1 to 192.168.23.0/24 is the route via R2, which has the lowest cumulative path cost.

Figure Example of best route selection in the same area

However, when a network is learned as an intra-area route and an inter-area route, the best route is not determined by cost. The intra-area route always takes precedence. Determining the best route by cost is only possible for OSPF routes of the same type. For OSPF routes of different types, the priority is determined regardless of the path cost. The priority order by OSPF route type is as follows

  1. Intra Area route
  2. Inter Area route
  3. External route metric-type 1
  4. External route metric-type2

Let’s look specifically at the priorities of these different types of routes.

Intra-area routes and inter-area routes

In the following network topology, consider a route from R1 to Loopback0 (192.168.0.4) on R4.

Figure Intra area routes and inter area routes
Figure Intra area routes and inter area routes

The OSPF-related configuration for R1 to R4 is as follows

R1

router ospf 1
 router-id 1.1.1.1
 log-adjacency-changes
 network 192.168.0.1 0.0.0.0 area 0
 network 192.168.12.0 0.0.0.3 area 0

R2

router ospf 1
 router-id 2.2.2.2
 log-adjacency-changes
 network 192.168.0.2 0.0.0.0 area 0
 network 192.168.12.0 0.0.0.255 area 0
 network 192.168.23.0 0.0.0.255 area 1
 network 192.168.32.0 0.0.0.255 area 0

R3

router ospf 1
 router-id 3.3.3.3
 log-adjacency-changes
 network 192.168.0.0 0.0.0.255 area 0
 network 192.168.23.0 0.0.0.255 area 1
 network 192.168.32.0 0.0.0.255 area 0
 network 192.168.34.0 0.0.0.255 area 0

R4

router ospf 1
 router-id 4.4.4.4
 log-adjacency-changes
 network 192.168.0.0 0.0.255.255 area 0

There are two routes from R1 to R4 Loopback0.

  1. R1 S1/0(64) → R2 S1/1(64) → R3 S1/0(64) → R4 Lo0(1)
    Cumulative path cost 193
    Intra area route
  2. R1 S1/0(64) → R2 E0/0(10) area 1 → R3 S1/0(64) → R4 Lo0(1)
    Cumulative path cost 139
    Inter area route

If we simply compare only the path cost, the route via R2 E0/0 in 2. should be preferred. The route via R2 E0/0 is an inter-area route, while the route via R2 S1/1 is an intra-area route. Since intra-area routes are preferred over inter-area routes, R1 chooses the route via R2 S1/1 in 1. even though the path cost is large. The routing table of R1 and the result of traceroute to 192.168.0.4 are as follows.

R1 show ip route/traceroute

R1#show ip route 
- omitted -

Gateway of last resort is not set

     192.168.12.0/30 is subnetted, 1 subnets
C       192.168.12.0 is directly connected, Serial1/0
O IA 192.168.23.0/24 [110/74] via 192.168.12.2, 00:06:29, Serial1/0
O    192.168.34.0/24 [110/192] via 192.168.12.2, 00:06:29, Serial1/0
     192.168.0.0/32 is subnetted, 4 subnets
C       192.168.0.1 is directly connected, Loopback0
O       192.168.0.2 [110/65] via 192.168.12.2, 00:06:29, Serial1/0
O       192.168.0.3 [110/129] via 192.168.12.2, 00:06:29, Serial1/0
O       192.168.0.4 [110/193] via 192.168.12.2, 00:06:29, Serial1/0
O    192.168.32.0/24 [110/128] via 192.168.12.2, 00:06:29, Serial1/0
R1#traceroute 192.168.0.4

Type escape sequence to abort.
Tracing the route to 192.168.0.4

  1 192.168.12.2 48 msec 68 msec 20 msec
  2 192.168.32.3 12 msec 40 msec 28 msec
  3 192.168.34.4 48 msec 36 msec *

Inter area route and External route

Next, verify the priority of the inter-area route and the external route. To do so, change the network topology as follows.

Figure Selecting an inter-area route and an external route
Figure Selecting an inter-area route and an external route

Instead of including 192.168.23.0/24 directly in the OSPF process on R3, we will redistribute Connected and create it as an external route. To do so, change the configuration of R3 as follows

R3

router ospf 1
 no network 192.168.23.0 0.0.0.255 area 1
 redistribute connected subnets metric 1

We will focus on the route 192.168.23.0/24 on R4 in this topology. there are two routes from R4 to 192.168.23.0/24.

  1. R4 S1/1(64) → R3 S1/1(64) → R2 E0/0(10)
    Cumulative path cost 138
    Inter area route
  2. R4 S1/1(64) → R3 E0/0 Non-OSPF domain
    Cumulative path cost 1 (Metric type 2, so the value of the seed metric)
    External route

If we simply look at the path cost, the route 2. should be preferred. However, it is the inter-area route, route 1, that is given the preference. Inter-area routes take precedence over external routes regardless of path cost. The routing table of R4 will have the following output.

R4 show ip route

R4#show ip route 
- omitted -

Gateway of last resort is not set

     192.168.12.0/30 is subnetted, 1 subnets
O       192.168.12.0 [110/192] via 192.168.34.3, 00:07:34, Serial1/0
O IA 192.168.23.0/24 [110/138] via 192.168.34.3, 00:07:34, Serial1/0
C    192.168.34.0/24 is directly connected, Serial1/0
     192.168.0.0/32 is subnetted, 4 subnets
O       192.168.0.1 [110/193] via 192.168.34.3, 00:07:34, Serial1/0
O       192.168.0.2 [110/129] via 192.168.34.3, 00:07:34, Serial1/0
O       192.168.0.3 [110/65] via 192.168.34.3, 00:07:34, Serial1/0
C       192.168.0.4 is directly connected, Loopback0
O    192.168.32.0/24 [110/128] via 192.168.34.3, 00:07:34, Serial1/0

External route metric-type 1 and metric-type 2

Finally, we will verify the priorities of metric type 1 and metric type 2 for the external routes. To do so, change the network topology as follows.

Figure Selecting External Route Metric Type 1 and Metric Type 2
Figure Selecting External Route Metric Type 1 and Metric Type 2

R2 will also generate the route 192.168.23.0/24 as an external route, with a metric type of 1. Change the configuration of R2 as follows.

R2

router ospf 1
 no network 192.168.23.0 0.0.0.255 area 1
 redistribute connected subnets metric-type 1

The path cost of the external route generated by R3 is constant at 1. On the other hand, the path cost of the external route generated by R2 will be added with an initial value of 20. Therefore, in a simple path cost comparison, the external route generated by R3 should be preferred. However, in reality, the external route of metric type 1 generated by R2 is preferred. If the same external route has metric type 1 and metric type 2, the route with metric type 1 will be preferred regardless of the path cost. The routing table of R1 and R4 is as follows.

R1 show ip route

R1#show ip route 
- omitted -

Gateway of last resort is not set

     192.168.12.0/30 is subnetted, 1 subnets
C       192.168.12.0 is directly connected, Serial1/0
O E1 192.168.23.0/24 [110/84] via 192.168.12.2, 00:04:38, Serial1/0
O    192.168.34.0/24 [110/192] via 192.168.12.2, 00:04:38, Serial1/0
     192.168.0.0/32 is subnetted, 4 subnets
C       192.168.0.1 is directly connected, Loopback0
O       192.168.0.2 [110/65] via 192.168.12.2, 00:04:38, Serial1/0
O       192.168.0.3 [110/129] via 192.168.12.2, 00:04:38, Serial1/0
O       192.168.0.4 [110/193] via 192.168.12.2, 00:04:38, Serial1/0
O    192.168.32.0/24 [110/128] via 192.168.12.2, 00:04:38, Serial1/0

R4 show ip route

R4#show ip route 
- omitted -

Gateway of last resort is not set

     192.168.12.0/30 is subnetted, 1 subnets
O       192.168.12.0 [110/192] via 192.168.34.3, 00:05:17, Serial1/0
O E1 192.168.23.0/24 [110/148] via 192.168.34.3, 00:05:17, Serial1/0
C    192.168.34.0/24 is directly connected, Serial1/0
     192.168.0.0/32 is subnetted, 4 subnets
O       192.168.0.1 [110/193] via 192.168.34.3, 00:05:17, Serial1/0
O       192.168.0.2 [110/129] via 192.168.34.3, 00:05:17, Serial1/0
O       192.168.0.3 [110/65] via 192.168.34.3, 00:05:17, Serial1/0
C       192.168.0.4 is directly connected, Loopback0
O    192.168.32.0/24 [110/128] via 192.168.34.3, 00:05:17, Serial1/0

Summary

Point

  • There are 3 OSPF route types
    • Intra area routes “O”
    • Inter area routes “O IA”
    • External routes “O E1” “O E2”
  • Determine the best route by path cost only when the routes are of the same type.
  • When the OSPF route type is different, the priority is determined regardless of the path cost.
    • Intra area routes -> Inter area routes -> External routes metric-type 1 -> External routes metric-type 2

Related articles

How the OSPF works