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
- Intra-area routes are preferred over inter-area or external routes regardless of their cost; see Section 16.2 paragraph (6) of the OSPF RFC.
- Inter-area routes are preferred over external routes; see Section 16.2 paragraph (5) of the OSPF RFC.
- E1 routes are preferred over E2 routes; see Section 16.4 paragraph (6) of the OSPF RFC.
- External routes received from an intra-area ASBR should be preferred over external routes received from ASBRs in other areas. Cisco IOS ignores this rule even after configuring no compatible rfc1683 (Section 16.4.1 of the OSPF RFC)
- When comparing E1 routes, the route metric is the external cost added to the internal cost; see Section 16.4 paragraph (6.d) of the OSPF RFC.
- The internal cost of an E1/E2 route is the cost between the current router and the forwarding address specified in the Type-5 LSA (or originating ASBR if the forwarding address is set to 0.0.0.0); see Section 16.4 paragraph (3) of the OSPF RFC.
- When comparing E2 routes, only the external costs are compared; see Section 16.4 paragraph (6.b) of the OSPF RFC.
- If multiple E2 routes have the same external cost, the internal cost (as above) is compared; see Section 16.4 paragraph (6.d) of the OSPF RFC.
- NSSA (type-7 LSA) routes should be preferred over external (type-5 LSA) routes (paragraphs (6.c) and (6.e) of Section 2.5 of RFC 3101). Cisco IOS prefers external routes over NSSA routes; even if they have the same cost as the external routes (and maximum-path is configured), NSSA routes are not entered in the IP routing table.
- It seems the final tie-breaker is the LSA stability (or its position in the topology database/SPF tree?). For example, if the router cannot enter all equal-cost external routes into the IP routing table (based on maximum-path value), it appears to select the more stable ones (described by LSAs that have been longer in the OSPF topology database).
- 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.

its a good one.
ReplyDeleteregards
shivluy
Excelent information.
ReplyDeleteI'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/....
Big big thanks! I had pieces of it written down, but pieces about Cisco specific behavior are excellent finds.
ReplyDeleteI have a question about OSPF default originates.
ReplyDeleteI 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,
DR/BDR doesn't matter. They just influence how updates are flooded through the network.
ReplyDeleteMake sure all routers originate either E1 or E2 default routes (not a mix).