How does OSPF choose its router ID, and when does it change?
Show the answer
Say this first
The router ID is a 32-bit number written like an IPv4 address. IOS takes the router-id command first,
then the highest IP on an up loopback, then the highest IP on an up physical interface. It is chosen when
the process starts and does not change until the process restarts, so I always set it by hand.
Go deeper
Selection order on IOS-XE
router-id 1.1.1.1underrouter ospf.- Highest IPv4 address on a loopback interface that is up.
- Highest IPv4 address on any other interface that is up.
The interface does not have to run OSPF to be used for the router ID.
Changing it
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
% OSPF: Reload or use "clear ip ospf process" command, for this to take effect
R1# clear ip ospf process
Reset ALL OSPF processes? [no]: yesClearing the process drops every adjacency on that router, so do it in a window.
Why it must be unique
The router ID names the router's Type 1 LSA. Two routers with the same ID keep overwriting each
other's LSA, which causes flapping routes and constant SPF runs. IOS logs %OSPF-4-DUP_RTRID_NBR when
a directly connected neighbor has the same ID. A duplicate further away in the area shows up as a flood
war: the same LSA re-originated again and again with rising sequence numbers.
They will ask next
What happens if a router has no IPv4 address at all, for example in an IPv6-only OSPFv3 network?
The process cannot pick a router ID and will not start. OSPFv3 still uses a 32-bit router ID, so on an IPv6-only router you must configure
router-idby hand.Is the router ID also the address OSPF uses as a source?
No. Packets are sourced from the interface address. The router ID only identifies the router in LSAs, neighbor tables and DR elections.
Traps
- Saying the router ID changes as soon as you add a higher loopback. It only changes on a process restart.
- Forgetting that a cloned config can carry the same
router-idto two routers.