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 R1(config-router)#router-id 10.1.1.1 Reload or use “clear ip ospf process” command, for this to take effect R1(config-router)#do clear ip ospf pro Reset ALL OSPF processes? [no]: y
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 220.127.116.11 1 FULL/DR 00:00:32 10.2.2.3 FastEthernet1/0 10.1.1.1 1 FULL/DR 00:00:38 10.1.1.1 FastEthernet0/0