As you might have learned in CCNA or CCNP, OSPF will use cost as the metric to choose the shortest path for each destination, this is true but it’s not entirely correct. OSPF will first look at the “type of path” to make a decision and secondly look at the metric. This is the prefered path list that OSPF uses:
- Intra-Area (O)
- Inter-Area (O IA)
- External Type 1 (E1)
- NSSA Type 1 (N1)
- External Type 2 (E2)
- NSSA Type 2 (N2)
After the path selection it will look at the lowest cost path. To give a quick example…when Prefix “X” is learned as an intra-area route (O) and as an inter-area route (O IA) then OSPF will always select the intra-area route, even if the inter-area route has a lower cost.
I will demonstrate this behavior to you using the following topology:
We will create a loopback0 interface on R2 – R7 using the same prefix 1.1.1.1/32 and advertise it in OSPF as following:
- R2: Intra-Area (O)
- R3: Inter-Area (O IA)
- R4: External Type 1 (E1)
- R5: External Type 2 (E2)
- R6: NSSA Type 1 (N1)
- R7: NSSA Type 2 (N2)
We will check R1 to see what path it will prefer, let’s configure OSPF first:
R1(config)#router ospf 1
R1(config-router)#router-id 11.11.11.11
R1(config-router)#network 192.168.12.0 0.0.0.255 area 0
R1(config-router)#network 192.168.13.0 0.0.0.255 area 0
R1(config-router)#network 192.168.14.0 0.0.0.255 area 0
R1(config-router)#network 192.168.15.0 0.0.0.255 area 0
R1(config-router)#network 192.168.16.0 0.0.0.255 area 167
R1(config-router)#network 192.168.17.0 0.0.0.255 area 167
R1(config-router)#area 167 nssa
First we’ll advertise the correct areas on R1. Don’t forget to make area 167 the NSSA area. Let’s continue with the other routers:
R2(config)#router ospf 1
R2(config-router)#router-id 22.22.22.22
R2(config-router)#network 192.168.12.0 0.0.0.255 area 0
R2(config-router)#network 1.1.1.1 0.0.0.0 area 0
On R2 we will advertise 1.1.1.1/32 as an intra-area route.
R3(config)#router ospf 1
R3(config-router)#router-id 33.33.33.33
R3(config-router)#network 192.168.13.0 0.0.0.255 area 0
R3(config-router)#network 1.1.1.1 0.0.0.0 area 3
R3 will advertise 1.1.1.1/32 in area 3 to make it an inter-area route.
R4(config)#router ospf 1
R4(config-router)#router-id 44.44.44.44
R4(config-router)#network 192.168.14.0 0.0.0.255 area 0
R4(config-router)#redistribute connected subnets metric-type 1
R4 will redistribute prefix 1.1.1.1/32 as an external type 1 route.
R5(config-if)#router ospf 1
R5(config-router)#router-id 55.55.55.55
R5(config-router)#network 192.168.15.0 0.0.0.255 area 0
R5(config-router)#redistribute connected subnets metric-type 2
R5 will redistribute prefix 1.1.1.1/32 as an external type 2 route.
R6(config)#router ospf 1
R6(config-router)#router-id 66.66.66.66
R6(config-router)#network 192.168.16.0 0.0.0.255 area 167
R6(config-router)#redistribute connected subnets metric-type 1
R6(config-router)#area 167 nssa
R6 is a NSSA ABR and will advertise 1.1.1.1/32 as a N1 route.
R7(config)#router ospf 1
R7(config-router)#router-id 77.77.77.77
R7(config-router)#network 192.168.17.0 0.0.0.255 area 167
R7(config-router)#redistribute connected subnets metric-type 2
R7(config-router)#area 167 nssa
Last but not least, R7 will redistribute 1.1.1.1/32 so it shows up as a N2 route.
Let’s verify our configuration:
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
55.55.55.55 1 FULL/BDR 00:00:38 192.168.15.5 FastEthernet0/3
44.44.44.44 1 FULL/BDR 00:00:38 192.168.14.4 FastEthernet0/2
33.33.33.33 1 FULL/BDR 00:00:38 192.168.13.3 FastEthernet0/1
22.22.22.22 1 FULL/BDR 00:00:37 192.168.12.2 FastEthernet0/0
77.77.77.77 1 FULL/BDR 00:00:30 192.168.17.7 FastEthernet0/5
66.66.66.66 1 FULL/BDR 00:00:39 192.168.16.6 FastEthernet0/4
All OSPF neighbor adjacencies are working. Let’s take a look at the routing table to see what path OSPF has decided to use:
Hi Brandon,
That’s a good question and rarely asked.
Here the best explanation that is taken from Cisco website about ISPF:
As you know, OSPF uses Dijkstra’s SPF algorithm to compute the shortest path tree (SPT). During the computation of the SPT, the shortest path to each node is discovered. The topology tree is used to populate the routing table with routes to IP networks. When changes to a Type-1 or Type-2 link-state advertisement (LSA) occur in an area, the entire SPT is recomputed. In many cases, the entire SPT need not be recomputed because most of the tr
... Continue reading in our forumHi Rene, Hi all
I still have problems for the choice between an E1 or N1 route (same between E2 or N2)
In the drawing of this course, what would have been the result if the router injecting the E1 route had been an internal router of area 3 ? R1 would then have received :
Will R1 still prefer the E1 route, an inter-area external over an intra-area external ?
Thanks a lot
Imen
Hello Imen,
OSPF doesn’t make a difference between inter-area or intra-area external routes. It doesn’t matter where the external route originated, it’s the cost that makes the difference.
When I booted up this lab again, I did find something interesting. When I wrote this lesson, I used IOS 12.4 and this is the list that OSPF uses for path selection:
Since Cisco IOS release 15.1(2)S, Cisco uses the path selection order from RFC 3101 which obsoletes RF
... Continue reading in our forumI apologize if this was already asked and answered, I just could not find it. So the questions is what is the criteria OSPF uses when choosing route between several equal cost and equal type paths. Thats in a single OSPF process, if one uses CISCO router, then CISCO by default set max path for OSPF to 4. But CISCO is not the only router there is and whatever is its default its CISCO default, not OSPF, strictly speaking. So how the OSPF itself then chooses the route to use? In other words, if I run max path 1 on the router (or use some router that has it as defa
... Continue reading in our forumHello Rene/Laz,
I am going to use the below topology for my question.
//cdn-forum.networklessons.com/uploads/default/original/2X/1/1045bd180a02ffe0a9f370b3770dc4f597ac4259.png
In this diagram, OSPF is running everywhere. Router 3 and Router 4 have loopback addresses as it is depicted in the topology. My question is regarding path manipulation in OSPF. In this scenario, Router 4 is learning 3.3.3.3 route through two different ways. However, Router 4 is installing 3.3.3.3 route with the exit interface of G 0/2 as the best path (note: all the interfaces are Gig in
... Continue reading in our forum