Interarea routing and path selection with OSPF

What path does OSPF choose to a specific destination?

Recently when I have been labbing OSPF more than before I noticed I stumbled when verifying the path ospf chooses for a specific destination. Lets look for instance at the topology here. First lets see with ospf database commands which path the routers uses and why, then how we can manipulate this.

First we look at the routingtable ofcourse, and the output from R1 shows that ECMP through both R2 and R3 is being used:

This is kind of straight forward since the same bandwidth is being used on every interface in the topology, hence also the metrics. But how do we dig deeper into the ospf’s point of view, why did ospf choose to use those paths? And what happens when we manipulate the cost for one of the paths?

Current ospf database

As of current, OSPF on R1 has two routes via two different ABR’s to the network in area 100. To see more detail about this “network summary”, we can look into the ospf database LSA type 3 on the Router R1:

We see that R1 has two LSA Type3 for the network, one summary using R2 as ABR and the other one using R3 as ABR:

Advertising Router:
Advertising Router:

This means that those are the ABRs for this area towards the given summary, or prefix. We also see the metric advertised by those ABR’s into area 0. This value is advertised into the area in a distance vector manner and thats why OSPF is considered to be both link state and distance vector. Its linkstate inside an area, but more like distance vector between areas.

Next step would be to check our router R1’s cost to reach either of the ABRs. To do this, we want to look for the router LSA, or LSA type1, for the ABR’s. To accomplish this we can use the command “show ip database router self-originate” .
The self-originate command is simply to sort out only LSAs originating from the router itself. In this case, thats the only ones of interest because that LSA would describe the link between this router and the ABR. If no router-LSA would be present with the self-originate command, that would simply mean that the router is not adjacent with the ABR.

The output shows us two networks as expected, one for each link to the routers R2 and R3. The metric to both ABR’s is in this case 1, the cost is equal to both ABR’s which we remeber advertises equal cost to the destination. Therefore the total cost for both paths is 2 – Cost to ABR is 1, and the cost from the ABR to destination is also 1.

Cost Manipulation

We can easily manipulate the cost on any link, and by doing that also inflect the path choosen by the routing protocol. As long as we remember the steps of path election its quite easy to see where we can manipulate the cost to accomplish what we want to do. Lets say the task is to use the path via R2 but keep the path via R3 as backup, we would want to raise the total cost for that path. We can in this case choose to raise the cost on either of the links of router R3 to gain a higher total cost for that particular path.

Lets raise the cost on the interface of R3 towards R4:

What do we expect to happen now? Instead of cost 1 + 1, we would get a cost of 1 + 10. Remember the cost from R1 to R3 is still unchanged and therefore still 1. New total cost would be 11 for this path, making it less preferred by ospf and therefore not installed in the RIB. Lets verify.

Was the routing table updated? Yes, ofcourse.



Leave a Reply

Your email address will not be published. Required fields are marked *