Courseiva
OSPFGlobal Config

router ospf [process-id]

Enable OSPF routing on the router and enter OSPF router configuration mode for a specific process, allowing you to configure OSPF parameters such as network statements, router ID, and area assignments.

Definition: router ospf [process-id] is a Cisco IOS global config command. Enable OSPF routing on the router and enter OSPF router configuration mode for a specific process, allowing you to configure OSPF parameters such as network statements, router ID, and area assignments.

Overview

The `router ospf [process-id]` command is the gateway to configuring OSPF (Open Shortest Path First) on a Cisco router. OSPF is a link-state routing protocol that uses the Shortest Path First (SPF) algorithm to compute the best path to each destination. It is widely used in enterprise and service provider networks due to its fast convergence, scalability, and support for hierarchical design through areas.

This command enables OSPF routing and enters OSPF router configuration mode for a specific process ID, allowing you to define network statements, set the router ID, configure area assignments, and tune OSPF parameters like timers, authentication, and route summarization. The process ID is locally significant and does not need to match between routers; it simply identifies a separate OSPF process on the same router. You would use this command when you need to enable OSPF on a router, typically after deciding that OSPF is the appropriate routing protocol for your network—often chosen over EIGRP for multivendor environments or over static routing for dynamic, scalable topologies.

In a typical configuration workflow, you first assign IP addresses to interfaces, then enable OSPF with this command, followed by network statements under the OSPF process to advertise directly connected networks. Alternatively, you can use the `ip ospf` interface command for more granular control. The command requires privileged EXEC mode (enable) and modifies the running configuration immediately.

It is important to note that OSPF will not start until at least one interface is enabled for OSPF via a network statement or the `ip ospf` command. The process ID can range from 1 to 65535, and multiple OSPF processes can run on the same router, though this is rare in practice. Understanding this command is foundational for CCNA and CCNP candidates as it underpins OSPF configuration and troubleshooting.

Syntax·Global Config
router ospf [process-id]

When to Use This Command

  • Setting up OSPF as the dynamic routing protocol on a router in a multi-area OSPF network.
  • Configuring OSPF on a router that connects to an ISP using a single-area OSPF design.
  • Enabling OSPF to advertise directly connected networks into the OSPF domain.
  • Modifying OSPF parameters like reference bandwidth or timers for an existing OSPF process.

Parameters

ParameterSyntaxDescription
process-id<1-65535>A locally significant numeric identifier for the OSPF process. Valid values range from 1 to 65535. This ID does not need to match between neighboring routers. A common mistake is using the same process ID across routers expecting it to affect adjacency; it does not. The process ID is only used to distinguish multiple OSPF processes on the same router.

Command Examples

Basic OSPF Configuration with Network Statements

router ospf 1
Router(config-router)#

The command enters OSPF router configuration mode for process ID 1. The prompt changes to indicate you are now configuring OSPF. From here, you can add network statements, set the router ID, and adjust OSPF parameters.

Configuring OSPF with Router ID and Passive Interface

router ospf 10 router-id 1.1.1.1 network 192.168.1.0 0.0.0.255 area 0 passive-interface GigabitEthernet0/1
Router(config-router)#
Router(config-router)#
Router(config-router)#
Router(config-router)#

After entering OSPF configuration mode, the router-id command sets the OSPF router ID to 1.1.1.1. The network command advertises the 192.168.1.0/24 network in area 0. The passive-interface command prevents OSPF from sending hello packets on GigabitEthernet0/1, typically used for a LAN segment where no OSPF neighbors exist.

Understanding the Output

The command itself does not produce output; it changes the CLI prompt to indicate OSPF configuration mode. The prompt changes from 'Router(config)#' to 'Router(config-router)#'. This indicates that subsequent commands will configure the OSPF routing process.

To verify OSPF configuration, use 'show ip ospf' or 'show ip ospf interface'. In 'show ip ospf', look for the process ID, router ID, and area information. A correctly configured OSPF process will show the router ID (often the highest loopback or interface IP), the number of areas, and the SPF algorithm statistics.

If the router ID is 0.0.0.0, OSPF is not properly initialized. In 'show ip ospf interface', each interface participating in OSPF will display its state (e.g., DR/BDR, neighbor count). A good state is 'FULL' for neighbor adjacencies; 'DOWN' or 'INIT' indicates problems.

Configuration Scenarios

Configure OSPF between two branch routers

Two branch routers, R1 and R2, are connected via a serial link. The goal is to enable OSPF so they can exchange routes and provide dynamic failover.

Topology

R1(Gi0/0)---10.0.12.0/30---(Gi0/0)R2

Steps

  1. 1.Step 1: Enter global configuration mode on R1: R1> enable; R1# configure terminal
  2. 2.Step 2: Enable OSPF with process ID 1: R1(config)# router ospf 1
  3. 3.Step 3: Advertise the directly connected network: R1(config-router)# network 10.0.12.0 0.0.0.3 area 0
  4. 4.Step 4: Optionally set the router ID: R1(config-router)# router-id 1.1.1.1
  5. 5.Step 5: Repeat similar steps on R2 with its own router ID and network statement.
  6. 6.Step 6: Exit configuration mode and verify adjacency.
Configuration
! R1 configuration
interface GigabitEthernet0/0
 ip address 10.0.12.1 255.255.255.252
!
router ospf 1
 router-id 1.1.1.1
 network 10.0.12.0 0.0.0.3 area 0

Verify: Use 'show ip ospf neighbor' to see adjacency state. Expected output: R1# show ip ospf neighbor; Neighbor ID Pri State Dead Time Address Interface; 2.2.2.2 1 FULL/DR 00:00:34 10.0.12.2 GigabitEthernet0/0

Watch out: Forgetting to configure the network statement with the correct wildcard mask. Using 0.0.0.0 (host mask) instead of 0.0.0.3 will only advertise the specific IP, not the subnet.

Configure OSPF with multiple areas and passive interfaces

A router connects to multiple LAN segments and a WAN link. To reduce unnecessary OSPF hello traffic on LANs, those interfaces should be set as passive.

Topology

R1(Gi0/0)---10.0.1.0/24 (LAN1); R1(Gi0/1)---10.0.2.0/24 (LAN2); R1(Se0/0)---10.0.12.0/30 (WAN to R2)

Steps

  1. 1.Step 1: Enter global configuration mode: enable; configure terminal
  2. 2.Step 2: Enable OSPF process 1: router ospf 1
  3. 3.Step 3: Advertise all networks: network 10.0.1.0 0.0.0.255 area 0; network 10.0.2.0 0.0.0.255 area 0; network 10.0.12.0 0.0.0.3 area 0
  4. 4.Step 4: Set LAN interfaces as passive: passive-interface GigabitEthernet0/0; passive-interface GigabitEthernet0/1
  5. 5.Step 5: Ensure the WAN interface is not passive (default is active).
Configuration
! R1 configuration
interface GigabitEthernet0/0
 ip address 10.0.1.1 255.255.255.0
!
interface GigabitEthernet0/1
 ip address 10.0.2.1 255.255.255.0
!
interface Serial0/0
 ip address 10.0.12.1 255.255.255.252
!
router ospf 1
 passive-interface GigabitEthernet0/0
 passive-interface GigabitEthernet0/1
 network 10.0.1.0 0.0.0.255 area 0
 network 10.0.2.0 0.0.0.255 area 0
 network 10.0.12.0 0.0.0.3 area 0

Verify: Use 'show ip ospf interface brief' to see which interfaces are passive. Expected output: Interface PID Area IP Address/Mask Cost State Nbrs F/C; Gi0/0 1 0 10.0.1.1/24 1 DR 0/0; Gi0/1 1 0 10.0.2.1/24 1 DR 0/0; Se0/0 1 0 10.0.12.1/30 64 P2P 1/1

Watch out: Setting all interfaces as passive will prevent OSPF from forming adjacencies. Ensure at least one interface is not passive to exchange routes.

Troubleshooting with This Command

When troubleshooting OSPF, the `router ospf` command itself does not provide output; it is the entry point to OSPF configuration mode. However, the configuration you apply under it directly affects OSPF behavior. Common issues include OSPF not forming adjacencies, missing routes, or incorrect area assignments.

To diagnose, start with `show ip ospf neighbor` to check if the router has formed adjacencies. A healthy output shows neighbors in FULL state. If neighbors are not seen, verify that the interfaces are up/up and that the network statements match the interface IPs with correct wildcard masks.

Use `show ip ospf interface` to see which interfaces are running OSPF and their state. If an interface is not listed, the network statement may be missing or incorrect. Another common symptom is routes not appearing in the routing table.

Check `show ip route ospf` to see OSPF-learned routes. If routes are missing, verify that the neighbor is in FULL state and that the area configuration is consistent (e.g., both ends must agree on area ID for the link). Use `debug ip ospf adj` to see adjacency formation details, but use with caution in production.

Also, check for mismatched OSPF parameters like hello/dead timers, authentication, or network type (e.g., one side broadcast, the other point-to-point). The `show ip ospf database` command reveals the link-state database; missing LSAs indicate a problem. For route redistribution issues, verify that the `redistribute` command is configured under the OSPF process.

Always correlate OSPF configuration with interface states and routing table entries. A systematic approach: 1) Verify interface IP and status, 2) Confirm OSPF is enabled on the interface, 3) Check neighbor state, 4) Examine OSPF database, 5) Check routing table. This command is the starting point for all OSPF configuration troubleshooting.

CCNA Exam Tips

1.

CCNA exam tip: The process ID is locally significant and does not need to match between routers. However, it must be consistent on the same router if multiple OSPF processes are used (rare).

2.

CCNA exam tip: The 'network' command uses a wildcard mask (inverse of subnet mask). For example, 0.0.0.255 matches a /24 network. A common mistake is using a subnet mask instead of a wildcard mask.

3.

CCNA exam tip: OSPF router ID is chosen in this order: highest IP on a loopback interface, then highest IP on a physical interface. You can manually set it with 'router-id' command to ensure stability.

4.

CCNA exam tip: The 'passive-interface' command is often tested. It prevents OSPF from sending hello packets on an interface, but the network is still advertised. Use it on LAN interfaces where no OSPF neighbors exist.

Common Mistakes

Mistake 1: Using a subnet mask instead of a wildcard mask in the network statement. For example, 'network 192.168.1.0 255.255.255.0 area 0' is incorrect; the correct wildcard mask is 0.0.0.255.

Mistake 2: Forgetting to set a router ID manually, leading to OSPF using an unstable router ID that changes if an interface goes down.

Mistake 3: Not enabling OSPF on all interfaces that should participate, resulting in incomplete routing information.

router ospf [process-id] vs show ip ospf

The commands 'router ospf [process-id]' and 'show ip ospf' are often considered together because both are fundamental to OSPF operation but serve very different roles: one enters configuration mode to enable and tune OSPF, while the other displays the current state of the OSPF process. Confusion arises when engineers mistake a show command for configuration or vice versa.

Aspectrouter ospf [process-id]show ip ospf
PurposeEnable OSPF and enter router config modeDisplay OSPF process information
Configuration ModeGlobal configuration (config)#Privileged EXEC (enable)#
PersistenceChanges are saved to running-configOutput only; no config changes
Typical UseDefine process ID, network statements, router-idVerify neighbor state, LSDB, router ID
Effect on RouterStarts OSPF process and allows configurationNo effect; reads current state
PrecedenceExecuted before OSPF can runUsed after OSPF is configured to check status

Use 'router ospf [process-id]' when you need to enable OSPF routing or modify its parameters like network statements, router ID, or area assignments.

Use 'show ip ospf' when you need to verify OSPF is running, check the router ID, list areas, or review LSDB statistics without changing the configuration.

Platform Notes

In IOS-XE, the `router ospf [process-id]` command syntax is identical to classic IOS. However, IOS-XE may support additional features like OSPFv3 for IPv6 using `router ospfv3`. The output of `show` commands may be slightly different in formatting but functionally equivalent.

On NX-OS (Cisco Nexus switches), the equivalent command is `router ospf [process-id]` as well, but NX-OS uses a different configuration hierarchy: you must first enter `configure terminal`, then `feature ospf` to enable the OSPF feature, then `router ospf [process-id]`. NX-OS also supports VRF-aware OSPF with the `vrf` keyword. On Cisco ASA firewalls, OSPF is supported in routed mode using the same command: `router ospf [process-id]`.

However, ASA uses a different configuration style for network statements: `network [ip-address] [wildcard-mask] area [area-id]`. In IOS-XR, the command is `router ospf [process-name]` (process name is a string, not numeric), and configuration is done under a separate OSPF configuration submode. IOS-XR also requires explicit interface configuration under the OSPF process using `interface [type] [instance]`.

For older IOS versions (12.x), the command is the same, but some parameters like `bfd` or `fast-reroute` may not be available. In 15.x and 16.x, additional features like OSPF TTL security and graceful restart are supported. Always check the specific platform documentation for exact syntax and capabilities.

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