OSPF Router ID
Course Contents
1. What is a OSPF Router ID?
The OSPF Router ID (RID) is a 32‑bit value that uniquely identifies each router in an OSPF network.

As you an see above, It is displayed in IPv4 format (for example 1.1.1.1) and is used to:
- Identify routers when using Hello packets.
- Indicate the origin of LSAs in the LSDB.
Because OSPF builds a complete map of the network, each router must have a unique Router ID.
If two routers have the same RID, they simply won’t form a neighbor relationship.

Let’s now see together how routers actually choose their Router ID.
2. OSPF Router ID Selection Rules
When the OSPF process starts on a router, the Router ID is selected in this order:

- Step 1 – If manually configured using the router-id command, this value is used.
- Step 2 – If not, the highest IP address on any active loopback interface is chosen.
- Step 3 – If no loopback is available, the highest IP address on any active physical interface is used.
Only interfaces that are up/up are eligible.
3. Configure Router ID
Let’s take a simple example together to understand. You have a router called R1, and you want to see what OSPF Router ID will be assigned.

The Interfaces are already configured as you can see above.
We can start by enabling the OSPF process and see how the router picks the Router ID:
R1(config)# router ospf ?
<1-65535> Process ID
R1(config)# router ospf 1
We chose OSPF Process number 1.
One the OSPF Process is started, we can check by using the command show ip ospf <process> what Router ID has been selected:
R1# show ip ospf 1
Routing Process "ospf 1" with ID 10.10.10.1
Supports only single TOS(TOS0) routes
Supports opaque LSA
SPF schedule delay 5 secs, Hold time between two SPFs 10 secs
Minimum LSA interval 5 secs. Minimum LSA arrival 1 secs
Number of external LSA 0. Checksum Sum 0x000000
Number of opaque AS LSA 0. Checksum Sum 0x000000
Number of DCbitless external and opaque AS LSA 0
Number of DoNotAge external and opaque AS LSA 0
Number of areas in this router is 0. 0 normal 0 stub 0 nssa
External flood list length 0
Here, the Router ID is 10.10.10.1, which is the IP address of Loopback0.
→ So the router followed step 2 in the selection rules.
What Happens If the Loopback Goes Down?
Let’s simulate that. We shut down the Loopback interface:
R1(config)# no interface loopback 0 %LINK-5-CHANGED: Interface Loopback0, changed state to administratively down %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to down
Then we reset the OSPF process to force the router to choose a new Router ID:
R1# clear ip ospf process Reset ALL OSPF processes? [no]: yes
We need to confirm ‘Yes’ otherwise it will not work.
Let’s check again:
R1# show ip ospf 1
Routing Process "ospf 1" with ID 192.168.1.1
Supports only single TOS(TOS0) routes
Supports opaque LSA
SPF schedule delay 5 secs, Hold time between two SPFs 10 secs
Minimum LSA interval 5 secs. Minimum LSA arrival 1 secs
Number of external LSA 0. Checksum Sum 0x000000
Number of opaque AS LSA 0. Checksum Sum 0x000000
Number of DCbitless external and opaque AS LSA 0
Number of DoNotAge external and opaque AS LSA 0
Number of areas in this router is 0. 0 normal 0 stub 0 nssa
External flood list length 0
This time, the Router ID is 192.168.1.1, which is the IP of the G0/0 interface.
→ So the router followed step 3 in the rules.
Manually Setting the Router ID (Best Practice)
In a production network interface can go down, the best practice is alway to manually set the Router ID to make sure it never changes.
Let’s configure the Router ID manually to 1.1.1.1:
R1(config)# router ospf 1
R1(config-router)# router-id ?
A.B.C.D OSPF router-id in IP address format
R1(config-router)# router-id 1.1.1.1
Now if we verify again:
R1# show ip ospf 1
Routing Process "ospf 1" with ID 1.1.1.1
Supports only single TOS(TOS0) routes
Supports opaque LSA
SPF schedule delay 5 secs, Hold time between two SPFs 10 secs
Minimum LSA interval 5 secs. Minimum LSA arrival 1 secs
Number of external LSA 0. Checksum Sum 0x000000
Number of opaque AS LSA 0. Checksum Sum 0x000000
Number of DCbitless external and opaque AS LSA 0
Number of DoNotAge external and opaque AS LSA 0
Number of areas in this router is 0. 0 normal 0 stub 0 nssa
External flood list length 0
And in the running configuration:
R1# show run | s ospf
router ospf 1
router-id 1.1.1.1
→ The Router ID is now fixed, no matter what happens to the interfaces.
4. Conclusion
The Router ID is selected automatically in this order:

Summary
- The OSPF Router ID uniquely identifies a router in the OSPF network.
- It must be unique within the OSPF topology.
- If two routers use the same Router ID, they will not form a neighbor relationship.
- Although OSPF can select it automatically, it’s best practice to configure it manually using the router-id command.