Octet

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

  1. router-id 1.1.1.1 under router ospf.
  2. Highest IPv4 address on a loopback interface that is up.
  3. 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

Cisco IOS
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]: yes

Clearing 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.

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-id to two routers.
How did you do?