OSPF Router ID

Hi everyone, I have a question on manually setting the RID. Is there a conflict if a RID Ip is being used somewhere else in the area? Or is it only locally significant to the neighbors?

Hello Mario

The Router ID of an OSPF router must be unique within an OSPF autonomous system, including all associated OSPF areas of that autonomous system (AS). This is described in RFC2328 as shown below:

Router ID
A 32-bit number assigned to each router running the OSPF
protocol. This number uniquely identifies the router within
an Autonomous System.


Router ID
A 32-bit number that uniquely identifies this router in the AS.
One possible implementation strategy would be to use the
smallest IP interface address belonging to the router. If a
router’s OSPF Router ID is changed, the router’s OSPF software
should be restarted before the new Router ID takes effect. In
this case the router should flush its self-originated LSAs from
the routing domain (see Section 14.1) before restarting, or they
will persist for up to MaxAge minutes.

Now, to your specific question. If you are manually configuring the RID, then that RID must be unique among the RIDs in the AS. You can actually configure an IP address of on R1, and an OSPF RID on R2 of as long as R1 doesn’t use that IP as an RID.

So RIDs must be unique among themselves, and IP addressing (obviously) must be unique among themselves. However, RIDs and IP addresses of interfaces do not have to be unique (unless you use those IP addresses as RIDs).

In any case, it’s always best practice to manually configure RIDs and use IP addresses that are completely different than those used for actual interfaces in order to avoid confusion, or misconfigurations.

I hope this has been helpful!


Hi Reene,

What happens when you a duplicate router id is detected in your OSPF network? let’s say one of my important DC router has router id - & it has BGP running on the router? we setup a remote site in same area(area 0)? we saw an outage but I want to know whats the correct reason for outage?

Hello Sampath

The router ID in OSPF is used to identify routers in the OSPF database as well as to create OSPF neighbor adjacencies. If you have two routers with the same router ID in your OSPF domain, then this will result in unpredictable routing and almost certainly in intermittently unreachable networks.

Imagine you have a network where R1 and R2 are using the same router ID. When R3 receives OSPF packets from these two routers, it will interpret all the received information as coming from the same OSPF device. This can result in:

  1. R3 continually creating and tearing down neighbor adjacencies with R1 and R2 as it receives OSPF hello packets with the same router ID on two different interfaces.
  2. The routes learned by R3 from R1 and R2 are identified as routes coming from a single router, so the next hop IP will be incorrect for some of them.
  3. Router IDs are also used for virtual links, so having duplicate router IDs will cause this feature to fail.

I hope this has been helpful!



You wrote the following

  • My question is where is the problem here because I didn’t get it?

  • I mean where is the problem of that the new highest Loopback IP address becoming the new Router-ID?


Hello Ameen

The OSPF router ID is chosen based on the process described in this NetworkLessons note:

Now let’s say that you have configured your OSPF router with a loopback interface with an IPv4 address of, and that router has chosen the IP address of the loopback as the router ID.

Several months down the road, a new administrator was hired, and he decides to configure another feature on the router that requires the addition of a loopback interface. Let’s say he creates a new loopback with an IP address of All of a sudden, OSPF will choose that as the new router ID. The OSPF topology will become unstable, and no one will know why. It’s not readily perceivable.

For this reason, it is best practice to use the router-id command in the OSPF router configuration mode to configure the router ID. That way, no changes to any loopback interfaces will cause disruptive changes.

I hope this has been helpful!


1 Like

Thank you so much for the explanation.

1 Like

What will happen if we configure the same Router IDs on an indirectly connected neighbor within an area? Do the link state ID and advertising Router IDs from LSAs not cause any issue? I tried this scenario by configuring R1 → R2 → R3 where the router IDs are same on R1 and R3. Initially, when the router IDs were different, I was able to ping the IP address of R3 from R1. From the debugs I could see the neighbors were in full adjacency. When the same router IDs were configured, R3 removed the route to R1. But after a while, the route randomly appeared again.

R3(config-router)#network area 0
*Aug 20 21:07:35.359: %OSPF-5-ADJCHG: Process 2, Nbr on GigabitEthernet0/0 from LOADING to FULL, Loading Done

R3#sh ip route
Gateway of last resort is not set is variably subnetted, 2 subnets, 2 masks
C is directly connected, GigabitEthernet0/0
L is directly connected, GigabitEthernet0/0

R3#sh ip os
 Routing Process "ospf 1" with ID
 Start time: 00:00:08.960, Time elapsed: 00:15:08.932

R3#sh ip route
Gateway of last resort is not set

O [110/2] via, 00:13:44, GigabitEthernet0/0 is variably subnetted, 2 subnets, 2 masks
C is directly connected, GigabitEthernet0/0
L is directly connected, GigabitEthernet0/0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to, timeout is 2 seconds:

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to, timeout is 2 seconds:
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/14/24 ms
R1#sh ip ospf
 Routing Process "ospf 1" with ID

I expected it get stuck in loading state when exchanging the LSAs as they might see same router IDs from different routers on the LSAs

Hello Gokul

If you have two routers with the same router ID that are directly connected, they will never become neighbors. However, as stated in the lesson, if you have two routers that are not directly connected in the same area, as in the example you described, then adjacencies will form. However, this situation is not ideal. You will see that the SPF algorithm will continually be run as OSPF will try to reconverge. This is because LSAs contain within their contents the router ID of the generating router. If that router ID appears in the OSPF database in multiple LSAs, this results in the SPF algorithm being run continuously which will in turn cause flapping OSPF routes.

Take a look at this Cisco documentation on troubleshooting duplicate OSPF router IDs in a topology for more information.

I hope this has been helpful!


Hello Guys,

I have an OSPF lab in PacketTracer. I first configured my neighbors without any Loopback. Then i configured a loopback and restarted the OSPF process but the RID is not changing. The only way to change the RID is to statically configure. Is that a normal behavior or a PacketTracer issue?


Hello David

That sounds interesting. I tried labbing this up in Packet Tracer and found the same issue. I’m using Packet Tracer Version

I also found that once the router chooses the router ID, it cannot be changed even if you do a clear ip ospf process. Even when I manually configured the router ID, and then removed it, the manually configured router ID remained.

From my experimentation, I found that in order for OSPF to change the router ID, you must either reload the router, or delete the OSPF configuration and reinstate it.

At first I believed this was a bug, but for completeness, I tried the same thing on Cisco CML. It had the same behavior! :open_mouth:

What I have found is this:

  1. When the router ID has been chosen as the IP address of a physical interface, even if you create a loopback interface and clear the OSPF process, the router ID will not change. You must either reboot the machine or delete and recreate the OSPF config.
  2. When the router ID has been chosen as the IP address of a loopback, even if you create a new loopback with a higher IP address, clearing the OSPF process will not change the router ID. The only way it will change is if you delete the loopback interface or change its IP address to something else.
  3. When creating, changing, or deleting a manually configured router ID, the router ID will change after clearing the OSPF process.

Notice that it is only when you create, change or delete the router ID that you get the following message from the console:

% OSPF: Reload or use "clear ip ospf process" command, for this to take effect

So it seems that packet tracer is recreating the behavior of OSPF router IDs correctly. This has been interesting, thanks for pointing this out!

I hope this has been helpful!


1 Like