This command manually sets the router-id used by OSPF. If it is not set, OSPF will automatically set its router-id to be the highest loopback IP address or the highest IP address (if no loopback interfaces are present). One thing to note is, even though the router-id is based on an IP address, it can be set to any 32 bit number in an IP address format. For example: 255.255.255.255 is an acceptable router-id.
Router(config-router)#router-id <ip address>
In this example we will change R1’s router-id to 10.1.1.1.
R1(config)#router ospf 1
We can now see that, on R2, the change has taken effect.
R2(config-router)#do show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface