Setting the OSPF RID


You want to set the OSPF Router ID (RID) of a particular router.


There are several ways to set the OSPF Router ID (RID). The easiest is to create and configure a Loopback interface:

Router5#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
Router5(config)#interface Loopback0
Router5(config-if)#ip address

If you don't want to use a Loopback interface, you can still force the router ID to use a particular IP address with the router-id configuration command:

Router5#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
Router5(config)#router ospf 87



If you don't use either of these methods, the router will select the highest IP address from its interfaces and use this as the OSPF RID. The trouble with doing this is that you might add a new IP address to the router at some point. If this new address is higher than the previous RID, the router will change its RID the next time OSPF restarts. This could have strange consequences because if the interface priorities are the same, OSPF uses the highest RID to select the DR. Please refer to Recipe 8.7 for more information on DR selection.

We recommend using the Loopback interface method. Loopback interfaces ensure there is a single unique IP address for every router in the network, which is extremely useful for network management. Further, it is common to configure your loopback addresses in DNS, but not to necessarily include all of your interfaces. This is useful when if you enable domain name lookups on your router, as discussed in Recipe 8.20.

In IOS level 12.0, Cisco introduced a new way to select the RID by using the router-id command. This command allows you to set the RID to any IP address. You can even set the RID to be an address that is not configured on any of the router's interfaces, or even an address that is not in the routing tables. However, this is not a very wise thing to do because it makes troubleshooting much more difficult.

In some cases, you might have both a router ID and a loopback address set. The rule is that OSPF will use the router-id command first, if one exists. If there is no router-id command, then it uses the highest IP address on any of the loopback interfaces. Bear in mind that you can configure as many loopback interfaces as you like (although this is somewhat unusual in production networks, there are special situations when additional loopback interfaces can be useful). Finally, if there is no router-id command and no loopback interface, the OSPF process will use the highest IP address on the router for the RID.

You can see what the RID for your router is with the following command:

Router5#show ip ospf 
 Routing Process "ospf 87" with ID
 Supports only single TOS(TOS0) routes
 SPF schedule delay 5 secs, Hold time between two SPFs 10 secs
 Minimum LSA interval 5 secs. Minimum LSA arrival 1 secs
 Number of external LSA 5. Checksum Sum 0x28868 
 Number of DCbitless external LSA 0
 Number of DoNotAge external LSA 0
 Number of areas in this router is 1. 1 normal 0 stub 0 nssa
 Number of interfaces in this area is 2
 Area has no authentication
 SPF algorithm executed 47 times
 Area ranges are
 Number of LSA 36. Checksum Sum 0xEEAA1 
 Number of DCbitless LSA 9
 Number of indication LSA 0
 Number of DoNotAge LSA 0

The router continues to use the same RID address even if you subsequently add a router-id command or a loopback interface. To force OSPF to update the RID, either reload the router or restart the OSPF process using the clear ip ospf process command:

Router5#clear ip ospf process
Reset ALL OSPF processes? [no]: yes


See Also

Recipe 8.7; Recipe 8.20

Router Configuration and File Management

Router Management

User Access and Privilege Levels


IP Routing





Frame Relay

Handling Queuing and Congestion

Tunnels and VPNs

Dial Backup

NTP and Time


Router Interfaces and Media

Simple Network Management Protocol





First Hop Redundancy Protocols

IP Multicast

IP Mobility




Appendix 1. External Software Packages

Appendix 2. IP Precedence, TOS, and DSCP Classifications


show all menu

Cisco IOS Cookbook
Cisco IOS Cookbook (Cookbooks (OReilly))
ISBN: 0596527225
EAN: 2147483647
Year: 2004
Pages: 505
Similar book on Amazon © 2008-2017.
If you may any questions please contact us: