OSPFOSPF Config

router-id [ip]

Sets the OSPF router ID for the OSPF process on Cisco IOS-XR.

Overview

The 'router-id' command in Cisco IOS-XR is used to manually assign a router ID to an OSPF process. The router ID is a 32-bit identifier, typically expressed in dotted decimal notation like an IP address, that uniquely identifies a router within an OSPF autonomous system. It is crucial for OSPF operation as it is used in router LSAs, network LSAs, and as the source of OSPF packets. Without a manually configured router ID, IOS-XR automatically selects the highest IP address on a loopback interface, or if no loopback exists, the highest IP on any active interface. This automatic selection can lead to instability if interfaces go down or IP addresses change, causing OSPF adjacencies to reset. Therefore, it is a best practice to manually set a stable router ID, often using a loopback interface IP. The command is configured in OSPF config mode (router ospf [process-id]). After changing the router ID, the OSPF process must be restarted using 'clear ospf process' to apply the new ID. This command is essential for network engineers to ensure OSPF stability and predictability, especially in large networks with redundant links. In troubleshooting workflows, verifying the router ID with 'show ospf' helps identify misconfigurations or duplicate IDs that can cause adjacency problems.

Syntax·OSPF Config
router-id [ip-address]

When to Use This Command

  • Stabilizing OSPF adjacencies by assigning a fixed router ID instead of relying on the highest loopback IP.
  • Ensuring consistent router ID after interface IP changes to prevent OSPF neighbor resets.
  • Setting a router ID that matches the loopback0 IP for easier network management and troubleshooting.
  • Configuring a specific router ID for OSPF when multiple OSPF processes exist on the same router.

Parameters

ParameterSyntaxDescription
ip-addressA.B.C.DThe router ID in dotted decimal format. It must be a unique 32-bit value within the OSPF domain. Typically, it is set to a loopback interface IP address for stability.

Command Examples

Setting OSPF Router ID

router ospf 100 router-id 10.1.1.1

Configures OSPF process 100 with router ID 10.1.1.1. No output is shown upon successful configuration.

Verifying OSPF Router ID

show ospf 100
Routing Process "ospf 100" with ID 10.1.1.1
 Supports only single TOS(TOS0) routes
 Supports opaque LSA
 It is an autonomous system boundary router
 Redistributing External Routes from,
  connected
 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
 Area BACKBONE(0)
     Number of interfaces in this area is 2
     SPF algorithm executed 5 times
     Number of LSA 10. 10 checksum 0x123456

The first line shows the OSPF process number and the configured router ID (10.1.1.1). Other lines provide OSPF process statistics.

Understanding the Output

The 'show ospf [process-id]' command displays the OSPF process details. The first line shows the OSPF process ID and the router ID. The router ID is a 32-bit number expressed in dotted decimal format, typically the highest loopback IP or manually configured. A healthy router ID should be unique within the OSPF domain and reachable. If the router ID is 0.0.0.0, it indicates that OSPF is not running or the router ID has not been set. The output also includes area information, number of interfaces, SPF algorithm runs, and LSA counts. A high number of SPF runs may indicate network instability. The checksum field helps verify LSA integrity.

Configuration Scenarios

Basic OSPF Router ID Configuration

A single OSPF process with a fixed router ID for stability.

Topology

Router R1 with loopback0 10.1.1.1/32 connected to a switch.

Steps

  1. 1.Enter global configuration mode.
  2. 2.Configure OSPF process 100.
  3. 3.Set the router ID to 10.1.1.1.
  4. 4.Exit configuration mode and clear OSPF process.
Configuration
!
router ospf 100
 router-id 10.1.1.1
!

Verify: Use 'show ospf 100' to confirm the router ID is 10.1.1.1.

Watch out: After configuring, you must clear the OSPF process with 'clear ospf 100 process' for the new router ID to take effect.

Troubleshooting with This Command

When troubleshooting OSPF adjacency issues on Cisco IOS-XR, the first step is to verify the router ID using 'show ospf [process-id]'. A common problem is duplicate router IDs, which cause OSPF neighbors to reject each other. Use 'show ospf neighbor' to see if neighbors are in EXSTART/EXCHANGE state, indicating a router ID conflict. If the router ID is 0.0.0.0, OSPF is not running. Check if the OSPF process is configured and interfaces are in the correct area. If the router ID changes unexpectedly, it may be due to interface flapping; manually set a loopback-based router ID to prevent this. After changing the router ID, always clear the OSPF process. Use 'debug ospf adj' to monitor adjacency changes. In multi-area OSPF, ensure the router ID is reachable from all areas. For IOS-XR, the router ID is also used in LSA generation; a stable router ID reduces LSA churn. If OSPF routes are missing, verify the router ID is not conflicting with another router's ID using 'show ospf database router'.

CCNA Exam Tips

1.

Remember that the router ID must be unique across the OSPF domain to avoid adjacency issues.

2.

On IOS-XR, the router-id command is configured under the OSPF process, not under router-id mode like in IOS.

3.

If you change the router ID, you must clear the OSPF process (clear ospf process) for the change to take effect.

Common Mistakes

Forgetting to clear the OSPF process after changing the router ID, causing the old ID to persist.

Using an IP address that is already in use by another router, leading to duplicate router ID conflicts.

Not configuring a router ID and relying on the highest loopback IP, which can change if loopbacks are added/removed.

Platform Notes

On Cisco IOS-XR, the 'router-id' command is configured under the OSPF process (router ospf [process-id]), similar to IOS. However, IOS-XR requires the OSPF process to be cleared after changing the router ID, whereas IOS may apply the change dynamically after a few seconds. In IOS, the router ID can also be set using 'router-id' under the OSPF process, but IOS also allows setting it globally with 'router-id' under 'router ospf'. IOS-XR does not have a global router-id command. The equivalent command on Juniper Junos is 'router-id' under 'protocols ospf', and on Arista EOS, it is 'router-id' under 'router ospf'. In IOS-XR, the router ID is also used for OSPFv3 (IPv6) if configured. Version differences: In IOS-XR 6.0 and later, the router ID can be set to an IPv4 address only; IPv6 is not supported. The router ID must be unique across all OSPF processes on the same router if they are in the same OSPF domain.

Practice for the CCNA 200-301

Test your knowledge with hundreds of CCNA practice questions covering all exam domains.

Practice CCNA Questions