Assigning an OSPF router id Open Shortest Path First

Practice this topic in the router emulator Every OSPF router within the network will have a router ID that uniquely identifies it to the other routers on the network. This router-id can be statically assigned, or it can be dynamically assigned based on an interface IP addresses.

Static configuration

To statically assign the router-id, use the router-id id command from router configuration mode. Note that although it looks like an IP address, it is not an actual address. The router-id is a 32 bit number simply represented in IP address format.
Router(config-router)#router-id 1.1.1.1

Dynamic configuration

If the router-id command is not provided, the router will get its ID from the IP address of one of its interfaces in an up/up state. This means of course, if you have no interfaces up/up with IP addresses, the OSPF process will not start as it will have no way of knowing its router-id. With this in mind, how does it chose the IP address to use if you have multiple interfaces?

Router ID selection

The first criterion the router uses when selecting an interface to base its router-id on is interface type. The only distinctions it makes between types is whether it is a loopback interface or not. Loopback interfaces are first considered to base the router-id on. If there are no loopback interfaces, the router will use an IP address from another other up/up interface. The second criterion is based on the value of the IP address. If the router has decided to use a loopback interface to get its router-id and there are multiple loopbacks, it will then chose the interface with the highest IP address e.g. 192.168.1.1 is higher than 10.1.1.1. The same is true if a selection is based on any other non loopback interface. Other than assigning an IP address to an interface, there is no other configuration for a dynamically assigned router-id

Starting OSPF and assigning the router-id

Step 1 is to start the OSPF process with the router ospf <procId> command from global configuration mode. The process ID is just a local value and has no influence on any other router in the network. A process number is assigned as it is possible to have multiple, separate instances of OSPF running on one router. In this instance we will use a process id of 1.
Router(config)#router ospf 1
Step 2 is to decide whether we want to manipulate the router-id or leave it as is. If we dont care what the router-id is set to, skip this step. If we do care, we must then either statically assign it using the router-id command, or configure an interface (most likely a loopback) with the appropriate IP address.
Router(config-router)#router-id 1.1.1.1

						or

Router(config)#interface Loopback1
Router(config-if)#ip address 1.1.1.1 255.255.255.255
Step 3 is only required if you have assigned a router-id statically or dynamically. When OSPF starts it choses its router-id based on the criteria given above. Once you change the router-id, it does NOT automatically change the router-id of OSPF while it is running. To do this we must restart the OSPF process. Below is the command to start OSPF with the process number 50
Router#clear ip ospf 50

 Further reading

Comments