This post will go over how a router decides what it’s Router-ID (RID) is. Just so we’re on the same page let’s look at a diagram.
We can see that this router is connected to 3 different networks.
OSPF will select it’s RID in this order: (#1 has the most weight, #3 has the least weight).
1.) router-id command – This command is set in “OSPF config mode”. This will always trump everything else.
2.) Loopback Interface IP address value – When you set a loopback address on a device it will trump all other ip addresses on the router except if the router-ID is configured. What happens if there is multiple loopback adapters and no router-id command configured? The router will use the highest loopback adapter IP address.
eg: 192.168.10.1 is HIGHER than 172.16.10.0 which is in turn HIGHER than 10.10.10.1
3.) Physical Interfaces – If the router-ID command AND loopback adapter have not been set on the router, the router will then look to it’s physical interfaces. In our example the LA router will look at the ip addresses 192.168.30.1, 192.168.20.1 and 172.16.10.6.
Because 192.168.30.1 is the “highest” configured IP address the router’s ospf Router-ID will become 192.168.30.1
Now that we understand how a router get’s it Router-ID we should also understand WHEN the router-ID is applied and or changed.
Let’s look at the example network. The network has been running for almost a month since it was deployed. You tell a junior network admin to add a loopback adapter and set to 192.168.25.1. The junior admin goes into the router and types ONLY this:
We can see that the IP address is in between 192.168.20.1 and 192.168.30.1. If we look back at how OSPF selects the router-id we can see that even though 192.168.30.1 is Higher than 192.168.25.1, the loopback interface (192.168.25.1) will trump the physical interface (192.168.30.1)
If you were to type: “do show ip ospf” what do you think the output will display?
… Insert Jeopardy music here …
The router will say that the Router-ID is STILL 192.168.30.1 !!!!!!!!!!
You are now probably scratching your head and asking how can that be? Doesn’t the loopback adapter trump the physical interface? This is why it’s important to know “When the router selects it’s Router-ID”. The router-ID is selected at boot time AND when OSPF is first enabled. Because the router was not restarted the router hasn’t been able to re-select it’s Router-ID!
Let’s look at another example…
Let’s say the router had been rebooted and it was running for another month. The same junior admin now accidentally REMOVES the loopback adapter on the router. If he were to do a “do show ip ospf” what will the router output for it’s Router-id?
Because he never restarted the router yet, the OSPF router-id would still be equal to the IP address of the Loopback adapter even though it had been completely removed!
Doing a reboot (reload) of the router you can see that the Router-ID has now been changed to the highest Physical Address.