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.
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.
Command Examples
Basic OSPF Configuration with Network Statements
router ospf 1Router(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/1Router(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.
CCNA Exam Tips
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).
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.
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.
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.
Related Commands
show ip ospf
Displays general information about OSPF routing process, including router ID, areas, and LSDB statistics, used to verify OSPF configuration and operational status.
show ip ospf neighbor
Displays OSPF neighbor information to verify adjacency formation and troubleshoot OSPF neighbor relationships.
show ip route
Displays the current IP routing table on a Cisco router, used to verify routes, check next-hop addresses, and troubleshoot connectivity issues.
Practice for the CCNA 200-301
Test your knowledge with hundreds of CCNA practice questions covering all exam domains.
Practice CCNA Questions