OSPF route failover

A colleague recently asked why, at a basic level, is dynamic routing such as OSPF useful? The very first thing that comes to mind is of course route failover. That is, when a network contains multiple routes to the same network, dynamic routing automatically will “failover” to an alternative route when the primary route is unavailable. With static routing, this would  have to be done manually.

The concept of route failover is best explained with an example. Let’s assume the below network scenario:

The nitty-gritty has all been setup and we can see for example on R2 we see the IP routing table:

R2#sh ip route
10.0.0.0/30 is subnetted, 3 subnets
C       10.0.0.8 is directly connected, FastEthernet1/0
O       10.0.0.0 [110/2] via 10.0.0.9, 00:05:40, FastEthernet1/0
[110/2] via 10.0.0.5, 00:05:40, FastEthernet0/0
C       10.0.0.4 is directly connected, FastEthernet0/0
192.168.0.0/32 is subnetted, 1 subnets
O       192.168.0.1 [110/2] via 10.0.0.5, 00:05:40, FastEthernet0/0
192.168.1.0/32 is subnetted, 1 subnets
O       192.168.1.1 [110/2] via 10.0.0.9, 00:05:40, FastEthernet1/0
C    192.168.2.0/24 is directly connected, Loopback0

The routes we’re interested in are highlighted in bold. Note how as expected, R2 reaches the 192.168.0.x network over fa0/0, and the 192.168.1.x network over fa1/0. Make a mental note of the metric and administrative distance in this case. Each route has [110/2]. Recall that these figures are [administrative distance / metric], so in this case the metric for each route is 2.

Now, lets say for some reason the link between R2 and R0 goes down:
Now here is where OSPF timers come into play. We can see the value of configured timers using the show ip ospf interface command. So for example for R2’s fa0/0 (the link that went down), we see:
R2#show ip ospf interface fa0/0
FastEthernet0/0 is up, line protocol is up
Internet Address 10.0.0.6/30, Area 0
Process ID 1, Router ID 192.168.2.1, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.2.1, Interface address 10.0.0.6
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
[…]
So basically, the two routers send a “are you there” (hello) packet, every 10 seconds. If these hello packets are not received for 40 seconds, the router is considered dead and the adjacency fails.
Aside: the Wait interval is the interval after which a new DR will be elected. By default, this is the same as the Dead interval.
Therefore, after 40 seconds the routing table must be re-calculated (in other words, SPF (short path first) is recalculated) and in fact if we re-issue the show ip route command on R2 we see:
R2#sh ip route
Gateway of last resort is not set
10.0.0.0/30 is subnetted, 3 subnets
C       10.0.0.8 is directly connected, FastEthernet1/0
O       10.0.0.0 [110/2] via 10.0.0.9, 00:10:31, FastEthernet1/0
C       10.0.0.4 is directly connected, FastEthernet0/0
192.168.0.0/32 is subnetted, 1 subnets
O       192.168.0.1 [110/3] via 10.0.0.9, 00:10:31, FastEthernet1/0
192.168.1.0/32 is subnetted, 1 subnets
O       192.168.1.1 [110/2] via 10.0.0.9, 00:10:31, FastEthernet1/0
C    192.168.2.0/24 is directly connected, Loopback0
First of all, note that both networks remain reachable, however they are now reached over Fa1/0 (the only remaining link). Secondly, note the value of the metric. We see that for the 192.168.0.0/24 network, we now have [110/3]. Note how the metric is now 3 since we pass through an extra hop to get to our network.