Build the Next-Generation Data Center
6 week online course starting on September 1st

OSPF route selection rules

OSPF implementation in Cisco IOS deviates slightly from OSPF/NSSA standards (RFC 2328 and RFC 3101). These are the OSPF route selection rules as implemented by Cisco IOS release 12.2(33)SRE1 (all recent releases probably behave identically):

Note: Update history is at the end of the post

Update history:
  • The original version of this post was published on 2008-01-17.
  • The post was updated and renamed on 2011-03-30 after a lengthy (and very productive) discussion with one of my readers.
  • 2011-04-16: Fixed the final tie-breaker part.
  • 2016-02-19: Fixed a typo - early OSPF RFC was RFC 1583, not RFC 1683


  1. its a good one.


  2. Excelent information.

    I've been searching for this for hours, but always you just find information about E1, E2 routes and what they you said...not the whole story..

    thanks a lot/....

  3. Anton Yurchenko31 March, 2011 02:05

    Big big thanks! I had pieces of it written down, but pieces about Cisco specific behavior are excellent finds.

  4. I have a question about OSPF default originates.

    I have 4 ABR in once OSPF domain. Three of the ABRs are generating a OSPF default route with a metric of 200 and 1 is using a metric of 1000. The show ip ospf database external shows that the default originate with 200 as an E2 and the default originate with the metric of 1000 as and E2 route. The ABR with a metric of 1000 is the BDR and the ABR with metrics of 200 are the DRs. The default route for clients of the DRs prefer the BDR default route with a metric of 1000 over the default of the DR with a metric of 200. Any ideas on how to fix this situation?


  5. DR/BDR doesn't matter. They just influence how updates are flooded through the network.

    Make sure all routers originate either E1 or E2 default routes (not a mix).

  6. Can someone please tell what the tie breaker is, i have 2 routes in OSPF that are teh same but it prefers the first one when both are recieved ( Rid) 20 A Oi tunnel.5 ( Rid) 20 A Oi tunnel.200

  7. It is well known (and in every textbook) that in IOS intra-area through the backbone are preferred over intra-area across a nonzero area, cost notwithstanding, but I cannot find any reference for this behaviour in RFC2328. Do you know the reason for this feature (or bug)?

    One similar case where behaviour is different is identical externals from the same ASBR, which is also an ABR, received across two distinct areas from another ABR in the same areas: these are selected by cost, with possible ECM, at least in 12.4(4)T1. This seems to be consistent with section 16.4.1 of RFC2328.

    No matter how many times you read RFC2328, there is always one more case that forces you to read it again and fire up GNS3.

  8. Well, apparently I did misread all those textbooks, and IOS follows RFC. Intra-area routes from two different areas (a corner case not as easy to see as I previously believed) are treated by the ABR exactly as externals, selected by cost with possible ECM.

  9. Ivan I have a comment here :

    Inter-area routes are preferred over external routes; see Section 16.2 paragraph (5) of the OSPF RFC.

    This is 100% true :)
    In case of redistribution, an O-E2 Route can be preferred over an O route ... :(

    Quote from :

    "The OSPF route selection rule is that intra-area routes are preferred over inter-area routes, which are preferred over external routes. However, this rule should apply to routes learned via the same process. In other words, there is no preference between external routes from one process compared to internal routes of other process."

    I don't want to flood your blogpost but this is the result of the test:

    O E2 [110/20] via, 00:00:16, FastEthernet0/1

    Type-5 AS External Link States

    Link ID ADV Router Age Seq# Checksum Tag 1307 0x80000001 0x009BFC 0

    R2(config-router)#distance ospf intra-area 109

    O [109/11] via, 00:00:09, FastEthernet0/0

    Hope you enjoy the sharing !

    See ya !


  10. Does only ABR sends default route to neighbor , while we enable default originate ?
    or it is not specific.

    1. Any router can originate E1 or E2 default route (unless it's in a stub area). On top of that, ABR would originate default route into stub/NSSA areas.

  11. I'm trying this out on junipers and cannot explain this

    Area 0 Area 1

    ---------------R2 ( ABR ) --------------------
    R1 R4
    ---cost 100----R3 ( ABR and ASBR ) ------------
    E1 Redistibuted at R3

    Costs not indicated are 1

    the route from R1 to E1 will always be the highcost direct link

    I can only conclude that R1 prefers this link as it considers ASBR as in its own area
    but I cannot find this documented in the RFC
    do you have any idea ?

  12. Hi! Article need update. In Cisco IOS Release 15.1(2)S and later releases, RFC 3101 replaces RFC 1587, and RFC 3101 behavior is automatically enabled.

  13. Hi Ivan,

    When you say " Cisco IOS ignores this rule even after configuring no compatible rfc1683 (Section 16.4.1 of the OSPF RFC)" it should say " Cisco IOS ignores this rule even after configuring no compatible rfc1583 (Section 16.4.1 of the OSPF RFC)"

    Apart from this, thanks for the post!

  14. Hello Ivan,

    i think that N2P=1 routes are preferred over E2 routes, which are preferred over N2P=0 routes. P is the P-bit.
    This behaviour is actually a bit more compliant with RFC3101, Section 2.5, (6)(e).
    i believe i have verified this with IOS 15.2(4)M2 in gns3.


You don't have to log in to post a comment, but please do provide your real name/URL. Anonymous comments might get deleted.