ip router ospf [pid] area [area-id]
Enables OSPF routing on an interface and assigns it to a specific OSPF process and area.
Overview
The 'ip router ospf [pid] area [area-id]' command is used in Cisco NX-OS to enable OSPF routing on a specific interface and assign it to an OSPF area. OSPF (Open Shortest Path First) is a link-state routing protocol that calculates the shortest path to each destination using the Dijkstra algorithm. On Nexus switches, OSPF configuration differs from classic IOS: instead of using 'network' statements under router OSPF, NX-OS requires enabling OSPF per interface. This provides granular control and aligns with the interface-centric configuration model of NX-OS. The command is applied in interface configuration mode, and the OSPF process must be created globally with 'feature ospf' and 'router ospf [pid]'. The area ID can be specified in decimal (e.g., 0) or dotted-decimal (e.g., 0.0.0.0) format. This command is essential for building OSPF adjacencies and exchanging routing information. In troubleshooting workflows, verifying that the correct interfaces are enabled under OSPF is a first step when OSPF routes are missing. Use 'show ip ospf interface' to confirm the configuration. NX-OS supports OSPFv2 for IPv4 and OSPFv3 for IPv6, with similar interface commands.
ip router ospf [pid] area [area-id]When to Use This Command
- Enable OSPF on a routed interface connecting to an OSPF backbone area (area 0).
- Assign a loopback interface to a specific OSPF area for router-id stability.
- Configure OSPF on a point-to-point link between two Nexus switches in a non-backbone area.
- Enable OSPF on a VLAN interface in a multi-area OSPF design.
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| pid | process-id | The OSPF process ID (1-65535). This is locally significant and must match the process ID configured under 'router ospf [pid]'. |
| area-id | area-id | The OSPF area to which the interface belongs. Can be specified as a decimal integer (0-4294967295) or in dotted-decimal format (e.g., 0.0.0.0). All routers in the same link must share the same area ID. |
Command Examples
Enable OSPF on Ethernet interface in area 0
interface ethernet 1/1
ip router ospf 100 area 0.0.0.0This command enables OSPF process 100 on interface Ethernet 1/1 and assigns it to area 0 (backbone). No output is displayed upon successful configuration.
Assign loopback interface to OSPF area 1
interface loopback 0
ip router ospf 100 area 1Configures loopback0 under OSPF process 100 in area 1. Loopback interfaces are often used for router-id or as a stable network advertisement.
Understanding the Output
The 'ip router ospf' command itself does not produce output; it is a configuration command. To verify OSPF interface status, use 'show ip ospf interface'. That output displays the interface name, OSPF process ID, area, state (e.g., DR, BDR, DROTHER), neighbor count, and timers. A healthy interface shows state as 'DR' or 'BDR' on broadcast networks, or 'P2P' on point-to-point links. Problem values include 'DOWN' or 'WAITING' indicating adjacency issues. The 'show ip ospf neighbors' command shows neighbor relationships; a full state indicates successful adjacency.
Configuration Scenarios
Basic OSPF Configuration on a Point-to-Point Link
Two Nexus switches connected via Ethernet, both in area 0.
Topology
Nexus-A (e1/1) --- (e1/1) Nexus-BSteps
- 1.Enable OSPF feature globally on both switches.
- 2.Create OSPF process 100 on both switches.
- 3.Configure interface e1/1 with an IP address and enable OSPF in area 0.
- 4.Optionally set the network type to point-to-point for faster convergence.
! On Nexus-A feature ospf router ospf 100 interface ethernet 1/1 ip address 10.1.1.1/30 ip router ospf 100 area 0.0.0.0 ip ospf network point-to-point ! On Nexus-B feature ospf router ospf 100 interface ethernet 1/1 ip address 10.1.1.2/30 ip router ospf 100 area 0.0.0.0 ip ospf network point-to-point
Verify: Use 'show ip ospf neighbors' to see adjacency state as FULL. Use 'show ip route ospf' to see learned routes.
Watch out: If the OSPF process ID does not match between the two routers, the adjacency will not form. Ensure both use the same process ID.
Troubleshooting with This Command
When troubleshooting OSPF adjacency issues on NX-OS, start by verifying that the interface is enabled for OSPF with 'show ip ospf interface'. Check that the interface state is not DOWN. Common issues include mismatched area IDs, subnet masks, or OSPF network types. Use 'show ip ospf neighbors' to see if any neighbor is detected. If the neighbor state is stuck in INIT or EXSTART, check MTU mismatches or authentication settings. On NX-OS, the 'debug ip ospf adj' command can provide real-time adjacency formation details. Also ensure that the OSPF process is running globally with 'show ip ospf'. If the interface is in a VLAN, verify that the VLAN interface is up and has an IP address. For multi-area configurations, ensure that area 0 is contiguous and that virtual links are configured if necessary. NX-OS also supports OSPF graceful restart and non-stop routing, which can affect adjacency stability during switchovers.
CCNA Exam Tips
Remember that OSPF process ID is locally significant on NX-OS, but area ID must match between neighbors.
On NX-OS, the 'ip router ospf' command is used under interface configuration mode, not 'network' statements like IOS.
Be aware that NX-OS supports both decimal and dotted-decimal area IDs; exam questions may use either format.
Common Mistakes
Forgetting to configure 'ip ospf network point-to-point' on interfaces that should not elect DR/BDR, leading to unnecessary elections.
Using the wrong OSPF process ID, causing the interface to not participate in the intended OSPF process.
Not enabling OSPF globally with 'feature ospf' before configuring interface commands.
Platform Notes
On Cisco NX-OS, OSPF configuration is interface-centric, unlike IOS where 'network' statements under router OSPF are used. This means each interface must be explicitly enabled with 'ip router ospf'. NX-OS also supports OSPFv3 for IPv6 with the 'ipv6 router ospf' command. The default OSPF network type on broadcast interfaces is 'broadcast', which requires DR/BDR election; for point-to-point links, it is recommended to set 'ip ospf network point-to-point' to avoid election delays. NX-OS allows up to 32 OSPF processes. The 'area' parameter can be entered as a decimal or dotted-decimal; both are valid. In earlier NX-OS versions, the command syntax was slightly different, but current versions use the format described. For comparison, on Arista EOS, the equivalent command is 'ip ospf area [area-id]' under interface, while Juniper uses 'protocols ospf area [area-id]' with interface statements.
Related Commands
Practice for the CCNA 200-301
Test your knowledge with hundreds of CCNA practice questions covering all exam domains.
Practice CCNA Questions