# OSPF Path Selection explained

**URL:** https://forum.networklessons.com/t/ospf-path-selection-explained/969
**Category:** Lessons Discussion
**Created:** [December 24, 2016, 6:54pm UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969 "2016-12-24T18:54:27Z")
**Posts on this page:** 18
**Page:** 5

<div class="post-metadata">

### Author: ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)
#### Post date: [March 7, 2023, 11:07am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/81 "2023-03-07T11:07:06Z")

</div>

Hello Vlad

Wow, that’s an interesting discovery. I labbed this one up and found the same result. And actually, it’s interesting that in my case the ABR chose the non-backbone route to the destination.

For some reason, it seems that OSPF will not load balance to destinations that may exist in different areas. I have been unable to find any documentation that tells us why, but there is a possibility that this behavior is Cisco-specific or even IOS-specific. [RFC 2328](https://www.rfc-editor.org/rfc/rfc2328#page-178) regarding OSPF load balancing, states the following:

> ```
> There is no requirement that a router running OSPF keep track of
> all possible equal-cost routes to a destination. An
> implementation may choose to keep only a fixed number of routes
> to any given destination. This does not affect any of the
> algorithms presented in this specification.
> 
> ```

This seems to jive with what is happening here. It would be interesting if you could experiment further to see what is used as the tiebreaker. Could it be the next hop IP address or the router ID of the advertising router? It would be an interesting experiment to undertake.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

### Author: ![vigneshkarthi1293](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/v/e9bcb4/32.png) [@vigneshkarthi1293](https://forum.networklessons.com/u/vigneshkarthi1293)
#### Post date: [April 7, 2023, 5:42am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/82 "2023-04-07T05:42:12Z")

</div>

difference between OSPF N1 / N2 and E1 and E2 Route ?

---

<div class="post-metadata">

### Author: ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)
#### Post date: [April 8, 2023, 6:20am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/83 "2023-04-08T06:20:54Z")

</div>

Hello Ravi

Take a look at this lesson that answeres your question in detail:

> **[OSPF Path Selection explained](https://networklessons.com/ospf/ospf-path-selection-explained)**
>
> OSPF will select a path based on the origin BEFORE looking at the cost of the path. In this lesson, I'll explain to you how it works.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [April 14, 2023, 2:13pm UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/84 "2023-04-14T14:13:51Z")

</div>

And here’s an overview of these four types:

[https://notes.networklessons.com/ospf-e1-e2-n1-n2-routes](https://notes.networklessons.com/ospf-e1-e2-n1-n2-routes)

---

<div class="post-metadata">

### Author: ![samirkhair](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/cdc98d/32.png) [@samirkhair](https://forum.networklessons.com/u/samirkhair)
#### Post date: [December 4, 2023, 3:38pm UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/85 "2023-12-04T15:38:36Z")

</div>

Hi,

I’m not sure this part is completely true:

> N1 \> E1 \> N2 \> E2.

Because RFC 3101, section 2.5 Calculating Type-7 AS External Routes, point 6 (b) states:

> ```
> (b) Type 1 external paths are always preferred over type 2
> external paths. When all paths are type 2 external paths,
> the paths with the smallest advertised type 2 metric are
> always preferred.
> [OSPF]
> 
> ```

So, if the metric is lower on E2, it will be preferred over N2.

And 6. (d) also says:

> ```
> (d) If the new AS external path is still indistinguishable
> from the current paths in N's routing table entry, select
> the preferred path based on a least cost comparison. Type
> 1 external paths are compared by looking at the sum of the
> distance to the ASBR/forwarding addresses and the
> advertised type 1 metric (X+Y). Type 2 external paths
> advertising equal type 2 metrics are compared by looking
> at the distance to the ASBR/forwarding addresses.
> ~[OSPF]
> 
> ```

So, although Type 1 is preferred over Type-2, E1 is preferred over N1 if its metric is lower, and the same with E2 and N2.

It’s only if metrics are the same that Type-7 (N1 and N2) are preferred over Type-5 (E1 and E2), as per the next step:

> ```
> (e) If the current LSA is functionally the same as an
> installed LSA (i.e., same destination, cost and non-zero
> forwarding address) then apply the following priorities in
> deciding which LSA is preferred:
> 
> 1. A Type-7 LSA with the P-bit set.
> 
> 2. A Type-5 LSA.
> 
> 3. The LSA with the higher router ID.
> 
> ```

I have confirmed this with labs, but please correct me if I am wrong.

Sam

---

<div class="post-metadata">

### Author: ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)
#### Post date: [December 6, 2023, 6:01am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/86 "2023-12-06T06:01:45Z")

</div>

Hello Samir

Yes, you are correct. I believe a more correct way of stating the overall order of preference of route types for OSPF becomes:

- Intra-Area Paths (O)
- Inter-Area Paths (O IA)
- External Type 1 (E1) Paths / NSSA Type 1 (N1) Paths
- External Type 2 (E2) Paths / NSSA Type 2 (N2) Paths

Within the same path-type category (like E1/N1 or E2/N2), OSPF will prefer **the path with the lower metric**. Only when the metric is the same will type E1 be preferred over N1, and type E2 be preferred over N2.

I will let Rene know so he can consider updates to the lesson. Thanks for sharing your thoughts and your experimentation with us!

I hope this has been helpful!

Laz

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [December 8, 2023, 9:25am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/87 "2023-12-08T09:25:04Z")

</div>

Thanks @samirkhair

I’ll lab this up and give it another try. The first time I tried this was on IOS 12.4, and it changed since IOS 15. I’ll update the lesson.

Rene

---

<div class="post-metadata">

### Author: ![davidantoine1991](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/d/97f17d/32.png) [@davidantoine1991](https://forum.networklessons.com/u/davidantoine1991)
#### Post date: [May 21, 2024, 1:27am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/88 "2024-05-21T01:27:02Z")

</div>

Lag, in his config guide for the lab, he has type 1 and the config you mentioned points to R5. Because i am having the same error

---

<div class="post-metadata">

### Author: ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)
#### Post date: [May 24, 2024, 5:55am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/89 "2024-05-24T05:55:20Z")

</div>

Hello David

Both the error in the previous post you quoted, as well as the one you are seeing is actually expected behavior. Within the lesson, Rene has added the following note:

> Since Cisco IOS release 15.1(2)S, Cisco uses the path selection order from RFC 3101, which obsoletes RFC 1587. This means that it prefers N1 routes before E1 and N2 over E2 routes. In other words, the preferred path list is O \> O IA \> N1 \> E1 \> N2 \> E2.

So it looks like you are using IOS release 15.1(2)S or later, and if so, that is why you are seeing the N1 routes before the E1 routes. Similarly, you’ll see the N2 routes being selected before the E2 routes. Does that make sense?

Take a look at this NetworkLessons note on [OSPF Path Selection](https://notes.networklessons.com/ospf-path-selection) for more details.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

### Author: ![giorgiortavidze](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/g/c67d28/32.png) [@giorgiortavidze](https://forum.networklessons.com/u/giorgiortavidze)
#### Post date: [December 28, 2024, 9:49am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/90 "2024-12-28T09:49:46Z")

</div>

Hello  
In real scenarios, can a router have the same prefix available simultaneously as both an intra-area and an inter-area route? For example, if the network 192.168.1.0/24 exists in Area 1 and is advertised by an ABR into Area 0, is it possible for a router to learn this prefix from both intra-area and inter-area routes at the same time?"

---

<div class="post-metadata">

### Author: ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)
#### Post date: [January 2, 2025, 2:09pm UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/91 "2025-01-02T14:09:48Z")

</div>

Hello George

Yes, it is possible for a router to learn the same prefix from both intra-area and inter-area routes at the same time. However, the router will prefer the intra-area route over the inter-area route due to OSPF’s route selection process. In other words, only the intra-area route will be installed in the routing table.

OSPF prefers intra-area routes over inter-area routes because they are considered more reliable. This is because intra-area routes **are within the same OSPF area** , and therefore have a more direct path to the destination.

In your scenario, if a router in Area 1 learns about the network 192.168.1.0/24 from both an intra-area route (from within Area 1) and an inter-area route (from Area 0), only the intra-area route will be installed in the routing table. If however the intra-area route becomes unavailable for some reason, the router will then install the inter-area route. This is part of OSPF’s built-in redundancy and failover mechanisms.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

### Author: ![speedosuper111](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/a183cd/32.png) [@speedosuper111](https://forum.networklessons.com/u/speedosuper111)
#### Post date: [November 7, 2025, 2:47pm UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/92 "2025-11-07T14:47:17Z")

</div>

Why do E1 and N1 show a cost of 21, and E2 and N2 show a cost of 20?

---

<div class="post-metadata">

### Author: ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)
#### Post date: [November 10, 2025, 8:47am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/93 "2025-11-10T08:47:38Z")

</div>

Hello Speedosuper111

That question gets to the heart of the difference between the “1” and “2” type OSPF routes for N and E.

Type 2 routes in both cases, once they enter the OSPF domain, **do not add any more OSPF cost** , no matter how deep into the OSPF infrastructure they go. They maintain **the original cost (20)** no matter how many additional hops they traverse within the OSPF infrastructure.

Type 1 routes in both cases, take the original cost (20) and **add any additional cost** that may exist within the OSPF domain.

So looking at this diagram:  
 ![image]()

- We can see that when the 1.1.1.1/32 network on R4 (which is E1) is advertised to R1, the cost of the hop from R4 to R1 is added to the original cost of 20, resulting in a cost of 21. For every additional hop (say to R6 or R7) the cost is incremented accordingly.
- We can see that when the 1.1.1.1/32 network on R5 (which is E2) is advertised to R1, the cost of the hop from R5 to R1 is NOT added to the original cost of 20, resulting in a cost of 20. For every additional hop (say to R6 or R7) the cost is NOT incremented, but remains the same at 20.

The N1 and N2 type routes have a similar behavior.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

### Author: ![davidilles](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/davidilles/32/9686_2.png) [@davidilles](https://forum.networklessons.com/u/davidilles)
#### Post date: [December 14, 2025, 2:29pm UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/94 "2025-12-14T14:29:22Z")

</div>

Hello, everyone.

This part is a bit confusing so I need some clarity regarding it.

O \> O IA \> External Routes

The routes on the left (before \>) will always be preferred over the ones on the right, **regardless of the cost?**

Take 192.168.1.0/24 as an example. It’s an inter-area route from the perspective of **R3**

![obrázok]()

```auto
R3#

O IA 192.168.1.0/24 [110/2] via 20.20.20.4, 00:52:06, GigabitEthernet

```

Now, I will configure this exact same network on R7-XR (so R3 will also receive a intra-area route). I will give it a very high cost.

```auto
R7-XR#

interface Loopback0
 ipv4 address 192.168.1.1 255.255.255.0

router ospf 110
auto-cost reference-bandwidth 10000

area 2
interface Loopback0
cost 665
loopback stub-network enable

```

R3, who had the O IA route now replaced it with the O route.

```auto
R3#
O 192.168.1.0/24 [110/666] via 192.168.5.7, 00:17:18, GigabitEthernet2

```

R3 didn’t care whether the cost was higher or lower, all it cared about was the fact that this comes from inside the area so it should be preferred.

All of this works fine for O \> O IA \> external routes but starting from external routes, it works differently?

Let’s focus on N1 \> E1 \> N2 \> E2 now.

![obrázok]()

R5 is redistirbuting **6.6.6.6/32 into Area 51** as a **N1 route and advertising this to R4**. I’ve also configured R2-XR to redistribute that exact same network as a **E1 route** (I’ve cut the link to Area 51 for R2-XR because it would advertise the route as N1 there). The blue area on the right is a normal area and R4 is receiving the E1 route there.

```auto
R4#show ip ospf database

Type-5 AS External Link States

Link ID ADV Router Age Seq# Checksum Tag
6.6.6.6 2.2.2.2 1031 0x80000002 0x0011EE 0

Type-7 AS External Link States (Area 51)

Link ID ADV Router Age Seq# Checksum Tag
6.6.6.6 5.5.5.5 33 0x8000000C 0x0091DE 0

```

At the moment, the cost is exactly the same for both routes and R4 is preferring the N1 route.

`O N1 6.6.6.6 [110/21] via 192.168.1.5, 00:01:35, GigabitEthernet2`

If I change the metric on R5 to a larger value (the 6.6.6.6/32 prefix is coming from EIGRP)

`R5(config-router)#redistribute eigrp 100 metric 500`

R4 will now prefer the E1 route

`O E1 6.6.6.6 [110/21] via 20.20.20.2, 00:00:10, GigabitEthernet1`

So if there are two routes of the same metric type (E1/N1), N1 will only be preferred **if the cost ties?** Which isn’t how it works with O and IA routes, those will always be preferred one over the other regardless of the cost.

If I tell R2-XR to advertise an E2 route instead, the N1 route will be preferred regardless of the metric on R4.

`O N1 172.16.10.0 [110/501] via 192.168.1.5, 00:00:15, GigabitEthernet2`

So to summarize, different route types O \> O IA \> N/E-1 \> N/E-2 will always be preferred over eachother, regardless of the cost. An O Route will beat an O IA route. An E1 route will beat an E2 or an N2 route.

However, routes of the same kind such as E1 or N1 will only be preferred if the cost ties?

Thank you  
David

---

<div class="post-metadata">

### Author: ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)
#### Post date: [December 17, 2025, 7:52am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/95 "2025-12-17T07:52:36Z")

</div>

Hello David

What you’ve proved here is something that is found in [RFC 3101](https://datatracker.ietf.org/doc/html/rfc3101#page-13) that defines how preference is defined for the route types:

Preference is defined as follows:

```
      (a) Intra-area and inter-area paths are always preferred over
          AS external paths.

      (b) Type 1 external paths are always preferred over type 2
          external paths. When all paths are type 2 external paths,
          the paths with the smallest advertised type 2 metric are
          always preferred.

```

So this confirms the behavior that you see in your experiment.

So it would probably be more correct to say:

O \> O IA \> (N1 \> E1) \> (N2 \> E2) if:

- the cost between N1 and E1 are the same
- the cost between N2 and E2 are the same
- If the costs are different, then the cost overrides the route type

I will let Rene know to consider adding appropriate notes to clarify this point. Thanks so much for this useful and enlightening experiment!

I hope this has been helpful!

Laz

---

<div class="post-metadata">

### Author: ![davidilles](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/davidilles/32/9686_2.png) [@davidilles](https://forum.networklessons.com/u/davidilles)
#### Post date: [December 24, 2025, 9:03am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/96 "2025-12-24T09:03:49Z")

</div>

Hello Laz.

Great, thanks for confirming.

Turns out it can get even more complicated because N1/2 doesn’t necessarily have to be preferred over E1/2 **even if the cost ties.**

![obrázok]()

Here I am redistributing a network configured on R3-XR (3.3.3.3/32) into areas 0 and 1. This means that it won’t have the P-bit set in the NSSA area.

I’ve set the cost on R2’s G2 interface to 2, so it will receive an E1 route from Area 0 and an N1 route from Area 1, both with the same cost. In this case, it prefers E1 over N1

![obrázok]()

![obrázok]()

Turns out that the P-bit needs to be set in the NSSA route in order for it to actually be preferred if the cost ties.

David

---

<div class="post-metadata">

### Author: ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)
#### Post date: [December 27, 2025, 7:30am UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/97 "2025-12-27T07:30:59Z")

</div>

Hello David

Thanks for sharing your experimentation with us. Indeed, this is an additional nuance that has been added to OSPF operation based on RFC 3101, which deals with OSPF NSSAs.

The specific behavior is described in [section 2.5 of the RFC](https://datatracker.ietf.org/doc/html/rfc3101#page-14) like so:

```
          If the current LSA is functionally the same as an
          installed LSA (i.e., same destination, cost and non-zero
          forwarding address) then apply the following priorities in
          deciding which LSA is preferred:

             1. A Type-7 LSA with the P-bit set.
             2. A Type-5 LSA.
             3. The LSA with the higher router ID.

```

Putting it a different way, this means that when an OSPF router compares a Type-5 LSA (E1/E2) and a Type-7 LSA (N1/N2) **with equal cost and type** , the Type-7 route is preferred **only if its P-bit is set**.

Now, the question I always like to dig deeper into is why?? The answer to this is somewhat complex, but I’ll try to be brief and link to additional info.

When two LSAs are “functionally the same,” meaning they share the same destination, cost, and a non-zero forwarding address, the OSPF router uses the P-bit as the primary tie-breaker to satisfy several operational goals:

1. By giving the highest priority to a Type-7 LSA with the P-bit set, OSPF ensures that the route explicitly intended for domain-wide propagation is the one selected for the routing table.
2. To prevent the policy paradox (i.e., traffic hijacking), which is further described [in this section of RFC3101](https://datatracker.ietf.org/doc/html/rfc3101#page-28).

These behaviors are beneficial when applied to large-scale OSPF deployments, and their benefits are most evident when used in large-scale networks. These benefits cannot be readily observed in small labs, but the behaviors can be studied.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

### Author: ![davidilles](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/davidilles/32/9686_2.png) [@davidilles](https://forum.networklessons.com/u/davidilles)
#### Post date: [December 27, 2025, 1:02pm UTC](https://forum.networklessons.com/t/ospf-path-selection-explained/969/98 "2025-12-27T13:02:54Z")

</div>

Hello Laz.

Thank you so much, I appreciate the confirmation.

David

[Previous page](https://forum.networklessons.com/t/ospf-path-selection-explained/969.md?page=4)
