•An OSPF router ID is a 32-bit value, represented as an IPv4 address. It is used to uniquely identify an OSPF router, and all OSPF packets include the router ID of the originating router.

•Every router requires a router ID to participate in an OSPF domain. It can be defined by an administrator or automatically assigned by the router. The router ID is used by an OSPF-enabled router to do the following:

Participate in the synchronization of OSPF databases – During the Exchange State, the router with the highest router ID will send their database descriptor (DBD) packets first.

Participate in the election of the designated router (DR) – In a multiaccess LAN environment, the router with the highest router ID is elected the DR. The routing device with the second highest router ID is elected the backup designated router (BDR).

Router ID Order of Precedence

Cisco routers derive the router ID based on one of three criteria, in the following preferential order:

  1. The router ID is explicitly configured using the OSPF router-id rid router configuration mode command. This is the recommended method to assign a router ID.
  2. The router chooses the highest IPv4 address of any of configured loopback interfaces.
  3. The router chooses the highest active IPv4 address of any of its physical interfaces.

Configure a Loopback Interface as the Router ID

Instead of relying on physical interface, the router ID can be assigned to a loopback interface. Typically, the IPv4 address for this type of loopback interface should be configured using a 32-bit subnet mask ( This effectively creates a host route. A 32-bit host route would not get advertised as a route to other OSPF routers.

OSPF does not need to be enabled on an interface for that interface to be chosen as the router ID.

interface loopback

Explicitly Configure a Router ID

In our reference topology the router ID for each router is assigned as follows:

•R1 uses router ID

•R2 uses router ID

•R3 uses router ID

Use the router-id rid router configuration mode command to manually assign a router ID. In the example, the router ID is assigned to R1. Use the show ip protocols command to verify the router ID.

router-id command

Modify a Router ID

•After a router selects a router ID, an active OSPF router does not allow the router ID to be changed until the router is reloaded or the OSPF process is reset.

•Clearing the OSPF process is the preferred method to reset the router ID.

clear ip ospf process