Network Bytes · Episode 94 · CCNA 3.4
"OSPF router ID: how it's chosen"
Every OSPF router needs a unique router ID written like an IPv4 address. Cisco IOS takes it from the router-id command first, then the highest loopback address, then the highest active physical interface address.
What the router ID is
OSPF routers introduce themselves to each other by router ID. It is a 32-bit number written in dotted decimal, like 1.1.1.1, so it looks like an IPv4 address. It does not have to be an address that exists on the router, but it must be unique in the OSPF domain: two routers with the same ID cause neighbor and database problems.
Think of a conference name tag: you can write your own, or one gets filled in for you, following a set order.
First: the router-id command
If you set the ID yourself, that always wins:
`` router ospf 1 router-id 1.1.1.1 ``
This is the cleanest choice: the ID is easy to read in show output and never changes on its own.
Then: the highest loopback address
With no router-id command, the router looks at its loopback interfaces that are up and takes the highest IPv4 address among them. With Lo0 10.1.1.1 and Lo1 10.1.1.4, the router ID becomes 10.1.1.4.
Loopbacks are virtual interfaces. No cable can be unplugged from them, so they stay up unless someone shuts them down. That makes them a stable source for the ID.
Last: the highest active physical address
With no router-id command and no loopback, the router falls back to its active (up) physical interfaces and takes the highest IPv4 address. With G0/0 192.168.1.1 and G0/1 192.168.2.1, the ID becomes 192.168.2.1.
When the choice is made
The router ID is chosen when the OSPF process starts. If you change the router-id or add a loopback later, the old ID stays until you run clear ip ospf process (or reload). Check the current ID with show ip protocols or show ip ospf.
Try it yourself
In Cisco Packet Tracer, give a router two connected interfaces with addresses, turn on OSPF with router ospf 1, and check the ID with show ip ospf. Then set router-id 7.7.7.7, look again (it hasn't changed yet), run clear ip ospf process, and confirm the new ID.
Good to know
- CCNA 3.4 lists the OSPF router ID among the single-area OSPFv2 items to configure and verify (EP46 and EP47 cover OSPF basics, neighbors and DR/BDR, where the router ID breaks ties).
- The router ID is a 32-bit number in dotted decimal; it doesn't have to be an address on the router, and it must be unique in the OSPF domain.
- Cisco IOS order: the
router-idcommand underrouter ospf; otherwise the highest IPv4 address on a loopback that is up; otherwise the highest IPv4 address on an active (up) physical interface. Sources differ on whether a down physical interface can count, so this lesson says "active". - The choice is made when the OSPF process starts; a change takes effect only after
clear ip ospf processor a reload. - A loopback stays up unless it is shut down, unlike a physical port.
- "Conference name tag" is the analogy. The example addresses are private.
For CCNA learners
CCNA exam topic 3.4 covers configuring and verifying single-area OSPFv2, including the router ID. Know the selection order (router-id command, highest loopback, highest active physical), that the ID must be unique, and that a new ID needs clear ip ospf process to take effect.
Answer to the comment question
2. With no router-id command, OSPF only looks at the loopback addresses while a loopback is up, so it considers 10.0.0.5 and 10.0.0.6 and ignores the physical addresses 10.0.0.8 and 10.0.0.9, even though they are higher. It then picks the higher loopback address, so the router ID becomes 10.0.0.6.
Test your knowledge
Quick quiz: "OSPF router ID: how it's chosen"
4 multiple-choice questions. Pick one answer for each, then check how you did.
Sources
- Cisco Networking Academy (CCNA course mirror), "Router ID" module 8.2.1.3: the order of selection: the router-id command, then the highest loopback IPv4 address, then the highest active physical interface address
- ipSpace.net (Ivan Pepelnjak), "OSPF Router ID Selection: the Gory Details": how Cisco IOS selects and keeps the router ID, and when a change takes effect
- NetworkLessons, "OSPF Router ID": the selection order and why a manually set ID or loopback keeps it stable
- Cisco, "CCNA 200-301 v1.1 exam topics": 3.4 configure and verify single area OSPFv2, including router ID
Video transcript
How does an OSPF router choose its ID when you never set one?
Every OSPF router needs a router ID: a unique name written like an IP address.
Like a conference name tag: write your own, or one gets filled in, in a set order.
First: if you typed the router ID command, that wins.
If not, the highest loopback address wins. Loopbacks are virtual, so no unplugged cable can take them down.
With no loopback, the highest active physical address wins.
No router ID command. Loopbacks end in dot five and dot six. Physical ports end in dot eight and dot nine. How many of those four addresses does OSPF even consider? Comment your answer below!
That's your byte.
More from Network Bytes
- EP92"QoS policing vs shaping"
- EP93"Layer 3 switches and SVIs"
- EP95"enable secret vs enable password"
- EP96"Wildcard masks"