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.

12 comments:

  1. its a good one.

    regards
    shivluy

    ReplyDelete
  2. Excelent information.

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

    thanks a lot/....

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

    ReplyDelete
  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 0.0.0.0 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?


    Thanks,

    ReplyDelete
  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).

    ReplyDelete
  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



    192.168.5.0/24 172.17.18.2 (172.17.18.2 Rid) 20 A Oi tunnel.5
    192.168.5.0/24 172.17.19.2 (192.168.5.11 Rid) 20 A Oi tunnel.200

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

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

    ReplyDelete
  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 :
    http://www.cisco.com/en/US/tech/tk365/technologies_white_paper09186a0080531fd2.shtml#routepref

    "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 1.1.1.1 [110/20] via 23.0.0.2, 00:00:16, FastEthernet0/1

    Type-5 AS External Link States

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

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

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



    Hope you enjoy the sharing !

    See ya !


    Nic


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

    ReplyDelete
    Replies
    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.

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

    ReplyDelete

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

Ivan Pepelnjak, CCIE#1354, is the chief technology advisor for NIL Data Communications. He has been designing and implementing large-scale data communications networks as well as teaching and writing books about advanced technologies since 1990. See his full profile, contact him or follow @ioshints on Twitter.