Table of Contents
OSPF Route Type
There are three main route types that can be learned with OSPF.
- Intra Area Route
- Networks in the same area
- OSPF routes based on LSA type 1 and LSA type 2
- Code “O”
- Inter Area Route
- Network in other areas
- OSPF routes based on LSA type 3
- Code “O IA”
- External route
- Networks in non-OSPF domains
- OSPF routes based on LSA type 5
- 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.
Related article
The following article explains the path cost of OSPF in detail.
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
- Intra Area route
- Inter Area route
- External route metric-type 1
- 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.
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.
- R1 S1/0(64) → R2 S1/1(64) → R3 S1/0(64) → R4 Lo0(1)
Cumulative path cost 193
Intra area route - 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.
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.
- R4 S1/1(64) → R3 S1/1(64) → R2 E0/0(10)
Cumulative path cost 138
Inter area route - 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.
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
How the OSPF works
- OSPF Overview
- OSPF process flow
- OSPF Router ID : Identify OSPF routers
- What if the router ID of the OSPF router is duplicated?
- OSPF Neighbor and Adjacency
- OSPF DR/BDR
- How show ip ospf neighbor looks on Ethernet
- OSPF Network Type : Classification of OSPF-enabled interfaces
- Synchronization process of OSPF LSDB
- Problems with large-scale OSPF network
- OSPF Area – Inside the area, in detail; outside the area, just a summary
- OSPF Router Type
- OSPF LSA Type
- OSPF Area Type
- OSPF Basic Configuration and Verification Commands
- Details of enabling OSPF on the interface
- OSPF Advertising Loopback Interface
- Configuring and Verifying OSPF Hello/Dead interval
- OSPF Cost Configuration and Verification
- Configuring and Verifying OSPF Router Priority
- Configuring OSPF Neighbor Authentication
- Neighbor Authentication over Virtual-link
- OSPF Configuring and Verifying Stub area [Cisco]
- OSPF Stub Area Configuration Example [Cisco]
- OSPF default route generation : default-information originate command
- Configuration Example of OSPF default route generation : stub area
- OSPF Virtual-Link : Virtual area 0 point-to-point link
- Configuring and Verifying OSPF Virtual-link [Cisco]
- OSPF Virtual-link Configuration Example [Cisco]
- OSPF Virtual-link for discontinuous backbone configuration example
- OSPF Route Summary and Configuration
- Cisco OSPF Route Summary Configuration Example
- OSPF Route Type Preference
- Why the OSPF neighbor state gets stuck in Exstart?
- OSPF packet type and header format
- OSPF Hello Packet
- OSPF DD(Database Description) Packet
- OSPF LSR(Link State Request) Packet
- OSPF LSU(Link State Update) Packet
- OSPF LSAck(Link State Acknowledgement) Packet
- Limitation of OSPF redistribution routes – redistribute maximum-prefix command
- Overview of LSA Filters for OSPF – Filter LSA Type 3/Type 5
- Configuration example of LSA type 3 filter
- Configuration example of LSA type 5 filter
- OSPFv3 Configuration Example [Cisco]
- Configuration Example of OSPFv3 Route Summary [Cisco]