OSPF Path Selection explained

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 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

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

Hello Ravi

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

I hope this has been helpful!

Laz

And here’s an overview of these four types:

https://notes.networklessons.com/ospf-e1-e2-n1-n2-routes

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

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

1 Like

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

1 Like