Understanding the need for OSPF RID and how to control it is indeed a very important aspect to take care of when dealing with OSPF.
The RID is a dotted decimal value used by OSPF routers to identify the other OSPF routers. Beside being used in OSPF operations, and to identify the neighbors in the output of the show commands, OSPF depends on the RID in many configuration aspects such as virtual-links, manipulating distance per neighbor, and others.
Cisco routers derive their Router IDs by the following means:
1. If the Router ID has been manually configured using the router-id command (can use any value unlike BGP which can use only up to 126.96.36.199 which is the last unicast IP), that Router ID is used.
2. If no Router ID has been manually configured, the router chooses the numerically highest IP address on any of its loopback interfaces.
3. If no loopback interfaces are configured with IP addresses, the router chooses the numerically highest IP address on any of its UP/UP physical interfaces. (accordingly you won’t have OSPF running unless one interface is UP/UP and the router will issue this log message “%OSPF-4-NORTRID: OSPF process 1 cannot start. There must be at least one “up” IP interface, for OSPF to use as router ID”).
The RID doesn’t need to be an IP that is reachable via OSPF or by any other routing protocol, it is just an ID, even if it is the IP of a running interface on the router, this interface does not have to be running OSPF to have its IP address used as the OSPF RID.
RID should be unique in the OSPF domain for OSPF to perform adjacency, and even more, each OSPF process on a single router must have a unique router ID, they won’t share the same router ID.
As a general rule, a router continues to use the RID learned from any interface (physical or logical) even if the interface subsequently fails or is deleted, to change this you either need to configure the RID manually or reload the router (clearing the ospf process won’t release it).
OSPF RIDs can be resolved via DNS by using the “ip ospf name-lookup” global configuration command, this will require a DNS server to be configured via the “ip name-server” command, or using local resolution via the “ip host” command. After enabling the RID resolution, the router is displayed by the name rather than by its router ID in all the OSPF show commands. Keep in mind one thing, using a DNS server might slow the output of the show commands, if doable I recommend using local resolution.
Finally I recommend always configuring the OSPF RID manually to prevent any hassles.
I hope that i’ve been informative.