Courseiva
OSPFRouter Config

router-id [ip]

The router-id command assigns a specific IP address as the OSPF router ID, overriding the default selection process, and is used to ensure a stable and predictable router identifier for OSPF operation.

Definition: router-id [ip] is a Cisco IOS router config command. The router-id command assigns a specific IP address as the OSPF router ID, overriding the default selection process, and is used to ensure a stable and predictable router identifier for OSPF operation.

Overview

The `router-id` command in OSPF configuration mode is used to manually assign a specific IP address as the OSPF router ID, overriding the default selection process. The OSPF router ID is a 32-bit identifier that uniquely identifies a router within an OSPF domain. By default, OSPF selects the highest loopback interface IP address, or if no loopback is configured, the highest physical interface IP address.

This default behavior can lead to instability: if an interface goes down or its IP changes, the router ID may change, causing OSPF neighbors to reset and potentially disrupting routing. Manually setting the router ID ensures a stable, predictable identifier, which is critical for network stability and troubleshooting. The command is typically used during initial OSPF configuration or when migrating IP addresses.

It fits into the broader configuration workflow after enabling OSPF and before configuring network statements or neighbor relationships. The command takes effect immediately and is stored in the running configuration; a reload or OSPF process restart is not required, but existing OSPF adjacencies will be reset if the router ID changes. The command requires privilege level 15 (enable mode) and is executed in router configuration mode.

Understanding the router ID is fundamental for OSPF operation, as it is used in DR/BDR elections, LSA identification, and path selection. Without a stable router ID, OSPF may experience frequent reconvergence, leading to network instability. The `router-id` command is the preferred method for setting the router ID; alternatives include relying on the default selection or using a loopback interface, but manual assignment provides the most control and predictability.

In summary, the `router-id` command is a simple yet powerful tool for ensuring OSPF stability and is a best practice in any production network.

Syntax·Router Config
router-id [ip]

When to Use This Command

  • Setting a loopback interface IP as the router ID to ensure stability and avoid changes when physical interfaces go down.
  • Configuring a specific router ID to match network documentation or to control DR/BDR elections in an OSPF network.
  • Overriding the default router ID selection when the highest loopback or physical interface IP is not desirable.
  • Ensuring router ID uniqueness in a multi-area OSPF design to prevent adjacency issues.

Parameters

ParameterSyntaxDescription
ipA.B.C.DSpecifies the IP address to use as the OSPF router ID. The address can be any valid IPv4 address, but it is recommended to use a stable loopback address. Common mistakes include using an IP address that is already in use on another router (causing duplicate router IDs) or using an IP address that is not reachable (though reachability is not required for router ID selection).

Command Examples

Basic router-id configuration

router ospf 1 router-id 1.1.1.1
R1(config-router)# router-id 1.1.1.1
R1(config-router)#
*Mar  1 00:01:23.456: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on GigabitEthernet0/0 from FULL to DOWN, Neighbor Down: Router ID changed
*Mar  1 00:01:23.456: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on GigabitEthernet0/0 from DOWN to FULL, Neighbor Down: Router ID changed

The command sets the OSPF router ID to 1.1.1.1. The syslog messages indicate that OSPF adjacencies are reset because the router ID changed, then re-established. This is normal behavior when modifying the router ID.

Verifying router ID after configuration

show ip ospf
Routing Process "ospf 1" with ID 1.1.1.1
Start time: 00:01:23.456, Time elapsed: 00:05:12.789
Supports only single TOS(TOS0) routes
Supports opaque LSA
Supports Link-local Signaling (LLS)
Supports area transit capability
Router is not originating router-LSAs with maximum metric
Initial SPF schedule delay 5000 msecs
Minimum hold time between two consecutive SPFs 10000 msecs
Maximum wait time between two consecutive SPFs 10000 msecs
Incremental-SPF disabled
Minimum LSA interval 5 secs
Minimum LSA arrival 1000 msecs
LSA group pacing timer 240 secs
Interface flood pacing timer 33 msecs
Retransmission pacing timer 66 msecs
Number of external LSA 0. Checksum Sum 0x000000
Number of opaque AS LSA 0. Checksum Sum 0x000000
Number of DCbitless external and opaque AS LSA 0
Number of DoNotAge external and opaque AS LSA 0
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Number of areas transit capable is 0
External flood list length 0
IETF NSF helper support enabled
Cisco NSF helper support enabled
Reference bandwidth unit is 100 mbps
    Area BACKBONE(0)
        Number of interfaces in this area is 1
        Area has no authentication
        SPF algorithm last executed 00:03:45.678 ago
        SPF algorithm executed 3 times
        Area ranges are
        Number of LSA 3. Checksum Sum 0x00ABCD

The first line shows the OSPF process and its router ID (1.1.1.1). This confirms the configured router ID is active. Other fields show OSPF timers, LSA counts, and area information.

Understanding the Output

The primary output for the router-id command is seen in the running configuration or via show ip ospf. In show ip ospf, the first line displays 'Routing Process "ospf 1" with ID 1.1.1.1', confirming the router ID. A good value is a stable IP address (often a loopback) that is unique in the OSPF domain.

A bad value would be an IP that is not reachable or duplicates another router's ID, causing adjacency problems. Watch for syslog messages indicating neighbor resets when the router ID changes. The router ID must be an IPv4 address; it does not need to be a configured interface IP, but it must be reachable if used as a source for OSPF packets.

Configuration Scenarios

Configure OSPF with a stable router ID using a loopback interface

A network engineer wants to ensure OSPF stability by using a loopback interface IP as the router ID. This prevents router ID changes if physical interfaces go down.

Topology

R1(Lo0:10.0.0.1/32)---(Gi0/0)10.0.12.0/30---(Gi0/0)R2(Lo0:10.0.0.2/32)

Steps

  1. 1.Step 1: Enter global configuration mode: R1# configure terminal
  2. 2.Step 2: Create a loopback interface: R1(config)# interface loopback 0
  3. 3.Step 3: Assign an IP address: R1(config-if)# ip address 10.0.0.1 255.255.255.255
  4. 4.Step 4: Exit interface configuration: R1(config-if)# exit
  5. 5.Step 5: Enter OSPF router configuration: R1(config)# router ospf 1
  6. 6.Step 6: Set the router ID: R1(config-router)# router-id 10.0.0.1
  7. 7.Step 7: Configure network statements: R1(config-router)# network 10.0.12.0 0.0.0.3 area 0
  8. 8.Step 8: Exit and verify: R1(config-router)# end
Configuration
! R1 Configuration
interface Loopback0
 ip address 10.0.0.1 255.255.255.255
!
router ospf 1
 router-id 10.0.0.1
 network 10.0.12.0 0.0.0.3 area 0

Verify: Use 'show ip ospf' to verify the router ID. Expected output includes 'Router ID: 10.0.0.1'. Also use 'show ip ospf neighbor' to confirm adjacency with R2.

Watch out: If the router ID is changed after OSPF adjacencies are established, the OSPF process will reset all adjacencies, causing temporary disruption. To avoid this, configure the router ID before enabling OSPF or during a maintenance window.

Override default router ID selection when no loopback exists

A router has no loopback interfaces, and the highest physical interface IP is 192.168.1.1. The engineer wants to use a different IP (10.0.0.1) as the router ID for consistency across the network.

Topology

R1(Gi0/0:192.168.1.1/24)---(Gi0/1)10.0.12.0/30---(Gi0/0)R2

Steps

  1. 1.Step 1: Enter global configuration mode: R1# configure terminal
  2. 2.Step 2: Enter OSPF router configuration: R1(config)# router ospf 1
  3. 3.Step 3: Set the router ID: R1(config-router)# router-id 10.0.0.1
  4. 4.Step 4: Configure network statements: R1(config-router)# network 10.0.12.0 0.0.0.3 area 0
  5. 5.Step 5: Exit and verify: R1(config-router)# end
Configuration
! R1 Configuration
router ospf 1
 router-id 10.0.0.1
 network 10.0.12.0 0.0.0.3 area 0

Verify: Use 'show ip ospf' to verify the router ID is 10.0.0.1. Use 'show ip ospf interface' to see that the router ID is manually set.

Watch out: The router ID does not need to be a routable IP address or match any interface IP. However, using an IP that is not assigned to any interface can cause confusion during troubleshooting. Always document the manually assigned router ID.

Troubleshooting with This Command

When troubleshooting OSPF issues, the router ID is a critical piece of information. A healthy OSPF network should have unique router IDs across all routers in the same OSPF domain. Duplicate router IDs can cause OSPF neighbors to flap or fail to form adjacencies.

Use 'show ip ospf' to display the router ID; the output includes 'Router ID' field. If the router ID is not what you expect, check if it was manually configured using 'show running-config | section router ospf'. If the router ID is 0.0.0.0, OSPF is not running or has not selected a router ID yet.

Common symptoms that the router ID is causing issues include: OSPF neighbors flapping, inability to form adjacency, or inconsistent LSDB. A step-by-step diagnostic flow: 1) Verify OSPF is enabled: 'show ip ospf'. 2) Check the router ID: if it is not the expected value, check for manual configuration. 3) If duplicate router IDs are suspected, use 'show ip ospf neighbor' to see neighbor router IDs. 4) Use 'debug ip ospf adj' to see adjacency events; if you see 'Duplicate router ID' messages, resolve by changing one router's ID. 5) If the router ID changed unexpectedly, check if an interface went down or if a loopback was added/removed. Correlate with 'show ip interface brief' to see interface status.

The 'router-id' command can also be used to force a new router ID without reloading: simply re-enter the command with a new IP, and OSPF will reset adjacencies. In summary, the router ID is a foundational element of OSPF; ensuring it is stable and unique is essential for a healthy OSPF network.

CCNA Exam Tips

1.

CCNA exam tip: The router ID is selected in order: 1) manually configured router-id command, 2) highest IP on a loopback interface, 3) highest IP on a physical interface. The exam may ask which router ID will be chosen.

2.

CCNA exam tip: Changing the router ID on a live router will cause OSPF adjacencies to reset, so it should be done during maintenance windows.

3.

CCNA exam tip: The router ID does not have to be a configured interface IP; it can be any unique 32-bit value, but it must be reachable for OSPF to function properly.

4.

CCNA exam tip: In a multi-area OSPF design, the router ID is used to identify the router in LSAs. Duplicate router IDs can cause routing loops or black holes.

Common Mistakes

Mistake 1: Forgetting to clear the OSPF process or reload after changing the router ID — the change takes effect immediately but resets adjacencies, which may cause temporary outages.

Mistake 2: Using an IP address that is not unique in the OSPF domain, causing neighbor adjacency issues and routing problems.

Mistake 3: Configuring a router ID that is not reachable (e.g., a non-existent IP), which can cause OSPF to fail to establish adjacencies.

router-id [ip] vs show ip ospf

The router-id and show ip ospf commands are commonly considered together because both involve the OSPF router ID, but they serve opposite purposes: one configures a static router ID, the other displays the currently active router ID along with other OSPF process information. Understanding the distinction is critical for troubleshooting OSPF adjacency issues and ensuring stable router identification.

Aspectrouter-id [ip]show ip ospf
ScopeConfiguration (sets parameter)Display (shows status)
ModeRouter configuration (config-router)Privileged EXEC (> enable)
PersistenceWritten to running-config and savedRuntime output only, not stored
PrecedenceOverrides dynamically elected router-IDShows current router-ID regardless of source
Typical useSet a stable router-ID before adjacencyVerify OSPF process health and router-ID

Use router-id [ip] when you need to force a specific, stable OSPF router ID, especially in environments with multiple loopbacks or to avoid router-ID changes due to interface flaps.

Use show ip ospf when you need to confirm the operational router ID, check OSPF area information, or verify that a configured router-id has taken effect.

Platform Notes

In IOS-XE (e.g., Catalyst 9000 switches), the 'router-id' command syntax is identical to classic IOS. However, in IOS-XE, the router ID can also be set via the 'ospf router-id' command under interface configuration for OSPFv3, but for OSPFv2, the command is the same. In NX-OS (e.g., Nexus switches), the equivalent command is 'router-id' under 'router ospf' configuration mode, but NX-OS also supports 'router-id' under 'feature ospf' context.

The syntax is identical: 'router-id <ip>'. In ASA firewalls, OSPF is supported in multiple context mode, and the command is 'router-id <ip>' under 'router ospf <process-id>'. In IOS-XR, the command is 'router-id <ip>' under 'router ospf <process-name>' configuration mode, but IOS-XR also requires the router ID to be configured as a separate statement; it cannot be inherited from an interface.

Behavior differences: In IOS 12.x, changing the router ID required a 'clear ip ospf process' to take effect; in later versions (15.x and 16.x), the change is immediate but resets adjacencies. In IOS-XE 16.x, the behavior is the same as IOS 15.x. In NX-OS, changing the router ID also resets adjacencies.

In IOS-XR, the router ID can be changed dynamically without resetting the OSPF process if the new ID is already in use? Actually, IOS-XR also resets adjacencies. Always test in a lab before production changes.

Related Commands

Practice for the CCNA 200-301

Test your knowledge with practice questions covering all CCNA 200-301 exam domains.

Practice CCNA 200-301 Questions