Sub topic 3
The Router ID and How It Is Chosen
This chapter assumes you know IPv4 addressing, basic interface configuration, and the idea that OSPF routers exchange link-state information. You do not need to know the Hello protocol yet. That comes next.
What the Router ID Is
The router ID (RID) is a 32-bit number that uniquely identifies a router inside an OSPF domain. It is written like an IPv4 address, such as 1.1.1.1, but it does not have to be a reachable address. OSPF uses it in three places:
- Hello and other packet headers name the sender by its RID.
- Link-state advertisements (LSAs) record which router originated them.
- Elections and the neighbor table use the RID to tell routers apart.
Two routers with the same RID in one domain cause unstable behavior. Each router sees LSAs that appear to come from itself, and the link-state databases become inconsistent.
How a Router Picks Its ID
A Cisco IOS-style router chooses its RID in this order:
- The value set with the
router-idcommand underrouter ospf. - The highest IPv4 address on an active loopback interface.
- The highest IPv4 address on an active physical interface.
The choice is made when the OSPF process starts. It is not recalculated if an interface address changes later. Without a loopback or a configured value, the RID can depend on a physical interface, which makes it fragile.
Setting It Explicitly
Always configure the RID by hand. This example comes from the chapter's configuration sample:
router ospf 1
router-id 1.1.1.1FRRouting uses a similar command:
router ospf
ospf router-id 1.1.1.1A fixed RID stays the same when interfaces go down, addresses change, or the router reboots. That makes logs, show output, and DR elections predictable.
Common Errors
- Changing the RID has no effect. The new value is used only after the OSPF process restarts. On IOS,
clear ip ospf processdoes this, and it drops adjacencies briefly. - Duplicate RIDs. This often happens when routers are cloned from one configuration. Give each router a unique value, such as a number per device.
- Assuming the RID must be routable. It does not. If you set
1.1.1.1and no interface has that address, OSPF works normally. - Relying on automatic selection. The RID can change after a reload if an interface is down or a higher address is added.
Exercise
Router A has no router-id command. It has Loopback0 at 10.255.0.1, GigabitEthernet0/0 at 192.168.5.1, and GigabitEthernet0/1 at 172.16.9.1, all up. Which RID does it choose, and why?
Show answer
10.255.0.1. With no configured RID, OSPF prefers the highest IPv4 address on a loopback interface. It ignores physical interface addresses, even though 192.168.5.1 is numerically higher, because a loopback exists.