Professional Documents
Culture Documents
Ospf-Best-Path Selection
Ospf-Best-Path Selection
====================================================
Reference Diagram:
In example 1, there are several different paths to 1.1.1.1. By order of operations, the
router will first consider the length of the route. Whichever route is longest, meaning
the most host bits are set therefore becoming more specific, will be selected.This aspect
supersedes where it was learned, what the metric is, or most other factors in terms of
destination based routing.
Step 1) Determine the Longest Match, the most specific route.
Example 1: R1 has two paths to 1.1.1.1. One is advertised as a /8, the other as a /32. Because the /32 is the longest match, you can see within the CEF table it is
the path selected (even though the other path is in the RIB)
Now, assume each route has the same length but is learned from various sources. The
route could have been entered statically, learned from OSPF via neighbors or
redistribution, or even RIP. In any case, the router next chooses the path with the
lowest administrative distance. Admin distance for each protocol can be set manually,
however does have default values. Example 2 displays where this can be seen in the
routing table. These values are good to know, especially if you are attempting to add in
floating static routes, or are performing redistribution and you don't want the new
protocol to be the primary means of path propagation just yet.
Step 2) Determine the path with the lowest administrative distance
Admin Distance:
Connected.................0
Static.........................1
EIGRP Summary......5 (This occurs only on the router where the
summary was generated)
eBGP........................20
Internal EIGRP.........90
OSPF........................110
IS-IS.........................115
RIP...........................120
External EIGRP.......170
iBGP........................200
NHRP......................250 (You'll typically only when using phase
3 DMVPN)
Example 2: The only change on R1 here is the creation of a static route to 1.1.1.1. Because static routes, by default, have a lower admin distance the path through
R3 is now preferred.
I didn't mention Type-4 LSAs (ASBR Summary) because they are advertised simply to
recurs to a type 3 in order to find the ASBR. Now that we have all of our routes
generated with a type code next to it as in the example 3, OSPF has enough
information to select the best path in this order:
1. Intra-Area
2. Inter-Area
3. E1 or N1 (determined by metric - if equal E1 is chosen)
4. E2 or N2 (determined by forward metric - if equal E2 is chosen)
Example 4: Here, I took the path to 1.1.1.1 on R2 out of OSPF completely, and instead redistributed it into OSPF making is an external (O E2/E1) route.
Therefore, Inter area route to R3 is now the best selection.
Finally, now that we have the longest matched route, of the lowest admin distance, and
in the case of OSPF the most preferred origination we can check the metrics.
Technically, the RFC does not dictate the metric to be correlated to anything, however
Cisco has chosen to inversely correlate the OSPF 'cost' to bandwidth. For example, the
higher the bandwidth the lower the cost by default. Cisco routers determine what to
base the cost versus bandwidth on a 'reference bandwidth' which defaults to 100mbps.
The reference bandwidth is then divided by the link bandwidth to generate the link
cost. For Example:
In addition to these routing decisions, within OSPF there are also underlying rules
about path selection that cannot be broken. Such as how inter area routes must traverse
area 0.
There are also caveats to some rules depending on operating system. For example, IOS
follows a slightly different variation of an older OSPF RFC (RFC1583) while NX-OS,
by default, adheres to RFC2328. The difference within these two RFCs is minor,
however can cause major issues, including loops within a network. The difference in
the two RFCs is:
RFC1583: If an N2 and E2 route to the same destination is learned, the one with
the lowest cost is chosen
RFC2328: If an N2 and E2 route to the same destination is learned, the router
will ALWAYS prefer the route towards the NSSA area, regardless of cost.