OSPF initially assigns all routers a router ID based on the highest loopback IP address of the interfaces configured for IP routing. If there is no loopback interface configured then it will be the highest VLAN IP address configured. This unique value, which is included in the hello packet transmitted in Link State Advertisements (LSA), identifies one router to another and helps establish adjacencies among OSPF routers. When you specify an interface as the router ID, this value supersedes the default ID.
The following example configures the router ID topology as displayed in OSPF Router ID Topology:
Router 1
Router 1(rw)->configure Router 1(rw-config)->interface loopback 1 Router 1(su-config-intf-loop.0.1)->ip address 1.1.1.1 255.255.255.255 Router 1(rw-config-intf-loop.0.1)->exit Router 1(rw-config)->router ospf 1 Router 1(rw-config-ospf-1)->network 10.1.2.2 0.0.0.255 area 1 Router 1(rw-config-ospf-1)->router-id 1.1.1.1 Router 1(rw-config-ospf-1)->exit Router 1(rw-config)->
Router 2
Router 2(rw)->configure Router 2(rw-config)->interface loopback 1 Router 2(su-config-intf-loop.0.1)->ip address 2.2.2.2 255.255.255.255 Router 2(rw-config-intf-loop.0.1)->exit Router 2(rw-config)->router ospf 1 Router 2(rw-config-ospf-1)->network 10.1.2.1 0.0.0.255 area 1 Router 2(rw-config-ospf-1)->network 10.2.3.1 0.0.0.255 area 0 Router 2(rw-config-ospf-1)->router-id 2.2.2.2 Router 2(rw-config-ospf-1)->exit Router 2(rw-config)->
Router 3
Router 3(rw)->configure Router 3(rw-config)->interface loopback 1 Router 3(su-config-intf-loop.0.1)->ip address 3.3.3.3 255.255.255.255 Router 3(rw-config-intf-vlan.0.1)->exit Router 3(rw-config)->router ospf 1 Router 3(rw-config-ospf-1)->network 10.3.4.1 0.0.0.255 area 2 Router 3(rw-config-ospf-1)->network 10.2.3.2 0.0.0.255 area 0 Router 3(rw-config-ospf-1)->router-id 3.3.3.3 Router 3(rw-config-ospf-1)->exit Router 3(rw-config)->
Router 4
Router 4(rw)->configure Router 4(rw-config)->interface loopback 1 Router 4(su-config-intf-loop.0.1)->ip address 4.4.4.4 255.255.255.255 Router 4(rw-config-intf-vlan.0.1)->exit Router 4(rw-config)->router ospf 1 Router 4(rw-config-ospf-1)->network 10.3.4.2 0.0.0.255 area 2 Router 4(rw-config-ospf-1)->router-id 4.4.4.4 Router 4(rw-config-ospf-1)->exit Router 4(rw-config)->