Configure Single Area OSPFv2 on Cisco Routers: Complete Lab Guide

Learn to configure and verify single-area OSPFv2 on Cisco routers with complete Router ID setup, network commands, and wildcard masks. Includes hands-on Cisco CML lab with full verification outputs and troubleshooting steps.

Configure Single Area OSPFv2 on Cisco Routers: Complete Lab Guide - PingLabz OSPF article title card
💡
You'll configure single-area OSPFv2 by entering global configuration mode and executing router ospf 1 to initiate the process. Set your Router ID with router-id 1.1.1.1 for topology stability, then enable OSPF on interfaces using network 192.168.1.0 0.0.0.255 area 0 with appropriate wildcard masks. Verify adjacencies with show ip ospf neighbor and check OSPF routes using show ip route. Proper area assignment and Router ID configuration guarantee successful neighbor formation and ideal path selection.

Understanding OSPF Fundamentals

OSPF serves as your gateway to scalable, efficient routing within enterprise networks. You'll leverage this link-state protocol to manage routing information across complex topologies while maintaining ideal path selection through Dijkstra's algorithm.

For where this topic sits in the wider picture, see the OSPF complete guide.

Your OSPF implementation requires each router to maintain a unique Router ID (RID). You can manually configure this identifier or let the router automatically derive it from the highest loopback or active interface IP address.

Within your network's hierarchical structure, you'll typically deploy Area 0 as the backbone, connecting all other areas to facilitate route summarization.

OSPF routers exchange Link State Advertisements (LSAs) to construct a thorough topology database. This process enables each router to calculate the shortest path independently, ensuring consistent routing decisions across your autonomous system without routing loops or suboptimal paths.

Five-step OSPF routing process: configure router IDs, establish Area 0, exchange LSAs, calculate shortest paths with Dijkstra's algorithm, and keep routing consistent.

Required Configuration Steps for Single-Area OSPFv2

Navigate to global configuration mode and initiate the OSPF routing process with the command router ospf [process-id], where you'll assign a locally significant process ID between 1 and 65535.

Next, configure a stable Router ID using router-id [ip-address] to prevent topology disruptions during network changes.

Enable OSPFv2 on specific interfaces with the network command:

  • network [ip-address] [wildcard-mask] area [area-id] - activates OSPF on matching interfaces
  • Wildcard masks determine which interfaces participate in the routing process
  • All routers must share the same area designation for proper adjacency formation

For single-area deployments, you'll typically use Area 0 as the backbone. The network statement doesn't advertise networks; it identifies which interfaces run OSPF. Verify your wildcard mask accurately matches the intended interfaces to avoid configuration errors.

OSPF Router ID and Interface Selection

After establishing the OSPF process and network statements, you'll need to understand how routers select their Router ID and determine which interfaces participate in OSPF operations.

The OSPF Router ID uniquely identifies each router in the topology. Without explicit configuration, it's chosen from the highest loopback address or the highest IP on any active interface. You should explicitly configure it using router-id [x.x.x.x] to prevent recalculations during network changes.

For interface selection, you'll use the network command with wildcard masks. A mask of 0.0.0.0 matches exactly one address, while 0.0.255.255 matches addresses sharing the first two octets.

Alternatively, you can enable OSPF directly on interfaces using ip ospf [process-id] area [area-id], providing more precise control over which interfaces participate in OSPF operations.

Step-by-Step OSPFv2 Configuration in Cisco CML (Area 0 Lab)

In this section, you'll configure and verify single-area OSPFv2 using Cisco Modeling Labs (CML). This hands-on example demonstrates the commands you've learned and ties them to real device outputs and verification steps.

Lab Topology Overview

Topology diagram: R1, R2 and R3 in OSPF Area 0 in CML, R1 Gi0/0 192.168.12.1 to R2 Gi0/0 192.168.12.2 and R2 Gi0/1 192.168.23.2 to R3 Gi0/1 192.168.23.3, cost 1 per link; R2 is DR on Gi0/0 and BDR on Gi0/1, both adjacencies are FULL, and R3 learns 192.168.12.0/24 at [110/2].
Single-area OSPFv2 lab topology showing router IDs, interfaces, and Area 0 adjacencies.

For this example, we'll use three routers: R1, R2, and R3 all operating within Area 0.

Cisco Modeling Labs workbench for the OSPFv2 lab: R1 G0/0 to R2 G0/0 and R2 G0/1 to R3 G0/1, with all three routers running.
OSPFv2 lab topology in Cisco Modeling Labs: R1, R2 and R3 in Area 0

IP Addressing Table

Gig0/0
DeviceR1
IP Address192.168.12.1
Subnet/24
Area0
Gig0/0
DeviceR2
IP Address192.168.12.2
Subnet/24
Area0
Gig0/1
DeviceR2
IP Address192.168.23.2
Subnet/24
Area0
Gig0/1
DeviceR3
IP Address192.168.23.3
Subnet/24
Area0

Router Configurations

R1 Configuration

R1(config)# interface GigabitEthernet0/0
R1(config-if)# ip address 192.168.12.1 255.255.255.0
R1(config-if)# no shutdown
!
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
R1(config-router)# network 192.168.12.0 0.0.0.255 area 0

R2 Configuration

R2(config)# interface GigabitEthernet0/0
R2(config-if)# ip address 192.168.12.2 255.255.255.0
R2(config-if)# no shutdown
!
R2(config)# interface GigabitEthernet0/1
R2(config-if)# ip address 192.168.23.2 255.255.255.0
R2(config-if)# no shutdown
!
R2(config)# router ospf 1
R2(config-router)# router-id 2.2.2.2
R2(config-router)# network 192.168.12.0 0.0.0.255 area 0
R2(config-router)# network 192.168.23.0 0.0.0.255 area 0

R3 Configuration

R3(config)# interface GigabitEthernet0/1
R3(config-if)# ip address 192.168.23.3 255.255.255.0
R3(config-if)# no shutdown
!
R3(config)# router ospf 1
R3(config-router)# router-id 3.3.3.3
R3(config-router)# network 192.168.23.0 0.0.0.255 area 0

Explanation:

  • Each router's interfaces are configured with their respective IP addresses before enabling OSPF
  • R1 connects to R2 on the 192.168.12.0/24 network
  • R2 connects to both R1 and R3, serving as the central router
  • R3 connects to R2 on the 192.168.23.0/24 network
  • After assigning Router IDs, the network commands enable OSPF on each interface under Area 0
High-level OSPFv2 control-plane flow from Hello exchange to SPF calculation and route installation.
High-level OSPFv2 control-plane flow from Hello exchange to SPF calculation and route installation.

Verification and Output

Once configuration is complete, use the following commands to confirm OSPF operation. Each command validates a specific part of your OSPF setup.

1. Verify Neighbor Adjacencies

This command ensures routers have successfully discovered one another and established full adjacencies.

R2# show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/DR         00:00:35    192.168.23.3    GigabitEthernet0/1
1.1.1.1           1   FULL/BDR        00:00:32    192.168.12.1    GigabitEthernet0/0

R2 has full adjacencies with both R1 and R3. R3 is the DR on 192.168.23.0/24 and R1 is the BDR on 192.168.12.0/24, which makes R2 the DR on Gi0/0 and the BDR on Gi0/1. The output above is transcribed from the CML screenshot below.

R2 show ip ospf neighbor in CML: 3.3.3.3 FULL/DR at 192.168.23.3 on GigabitEthernet0/1, and 1.1.1.1 FULL/BDR at 192.168.12.1 on GigabitEthernet0/0.
show ip OSPF neighbor

2. Verify OSPF Routes in the Routing Table

This confirms that routes learned via OSPF are being installed in the routing table.

Both end routers learn the far /24 through R2. The screenshot below captured R3's side:

R3# show ip route ospf
...
O     192.168.12.0/24 [110/2] via 192.168.23.2, 00:03:13, GigabitEthernet0/1

R3 learns 192.168.12.0/24 from R2 with a metric of 2: cost 1 for R3's own GigabitEthernet0/1 plus cost 1 for R2's GigabitEthernet0/0. R1's route to 192.168.23.0/24 crosses the same two links the other way.

R3 show ip route ospf in CML: 192.168.12.0/24 [110/2] via 192.168.23.2 on GigabitEthernet0/1.
show ip route OSPF

3. Verify OSPF Process and Router ID

This displays process-level information such as Router ID, SPF statistics, and interface participation. The CML screenshots don't cover this command or the LSDB, so for these two views I rebuilt the same addressing and router IDs in my home lab on Cisco IOL 17.18.2 in Containerlab (trimmed output):

R2# show ip ospf
 Routing Process "ospf 1" with ID 2.2.2.2
 Start time: 00:00:38.380, Time elapsed: 00:00:57.640
 Supports only single TOS(TOS0) routes
...
 Initial SPF schedule delay 50 msecs
 Minimum hold time between two consecutive SPFs 200 msecs
 Maximum wait time between two consecutive SPFs 5000 msecs
...
 Number of areas in this router is 1. 1 normal 0 stub 0 nssa
    Area BACKBONE(0)
        Number of interfaces in this area is 2

Confirms that R2 is running OSPF process 1 with Router ID 2.2.2.2 and two active interfaces in Area 0.

This verifies that all routers' LSAs have been received and synchronized.

R2# show ip ospf database

            OSPF Router with ID (2.2.2.2) (Process ID 1)

                Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
1.1.1.1         1.1.1.1         55          0x80000005 0x002010 1
2.2.2.2         2.2.2.2         46          0x8000000A 0x007D85 2
3.3.3.3         3.3.3.3         45          0x80000004 0x00A265 1

                Net Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.12.2    2.2.2.2         61          0x80000001 0x008F1F
192.168.23.3    3.3.3.3         54          0x80000001 0x004254

All three routers' Router LSAs (Type 1) are present, and each /24 also has a Network LSA (Type 2) from its DR. In this rerun the DRs came out as R2 (192.168.12.2) and R3 (192.168.23.3), the same roles as in the CML lab.

5. Verify OSPF Interfaces

Use this command to confirm which interfaces are active in OSPF and their neighbor relationships.

R2# show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Gi0/1        1     0               192.168.23.2/24    1     BDR   1/1
Gi0/0        1     0               192.168.12.2/24    1     DR    1/1

Both interfaces are active in Area 0 at cost 1, each with one full neighbor: R2 is the BDR on Gi0/1 and the DR on Gi0/0.

R2 show ip ospf interface brief in CML: Gi0/1 192.168.23.2/24 is BDR and Gi0/0 192.168.12.2/24 is DR, both at cost 1 in area 0 with 1/1 neighbors.
show ip OSPF interface brief

6. End-to-End Connectivity Test

A successful ping across the network confirms OSPF's routing functionality.

R1# ping 192.168.23.3 repeat 10
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 8/12/18 ms

All 10 packets were successful, confirming end-to-end OSPF connectivity from R1 to R3.

R1 ping 192.168.23.3 repeat 10 in CML: 10 of 10 replies, round-trip min/avg/max 8/12/18 ms.
ping r1 > r3

Troubleshooting Scenario Example

Quick decision flow for diagnosing OSPF neighbor adjacency failures.
Quick decision flow for diagnosing OSPF neighbor adjacency failures.

If R2 and R3 fail to form adjacency:

  1. Verify both routers use Area 0
  2. Confirm Hello and Dead timers match (show ip ospf interface)
  3. Use debug ip ospf adj or debug ip ospf packets to observe Hello exchanges
  4. Ensure interfaces are not set to passive mode
OSPF adjacency troubleshooting flow: verify the area ID, match Hello and Dead timers, debug Hello packets, then the adjacency is established.
Troubleshoot OSPF
R2 debug ip ospf packets in CML: Hello, DBD, LSR, LSU and LSAck exchanges on Gi0/0 and Gi0/1, with neighbor 1.1.1.1 on GigabitEthernet0/0 going from LOADING to FULL.
debug ip OSPF packets

Real-World Implementation Examples

When implementing OSPFv2 in production, topology designs can vary widely:

Hub-and-Spoke: The hub router uses multiple network statements for all spokes.

Dual-Router Redundancy: Both routers use matching area configurations but have unique Router IDs.

Full Mesh: Configure OSPF systematically across all links and verify each adjacency before moving forward.

Each design relies on the same OSPFv2 fundamentals - accurate area IDs, proper Router IDs, and verified adjacencies.

Frequently Asked Questions

How Does OSPFv2 Differ From OSPFv3?

OSPFv3 is designed for IPv6 and configured directly on interfaces using ipv6 ospf process-id area area-id. It doesn't rely on the network command and allows different link-local communication mechanisms.

What Are the Default Hello and Dead Timer Values?

The default hello timer is 10 seconds on broadcast and point-to-point links, with a 40-second dead timer. On NBMA networks, hello = 30 seconds and dead = 120 seconds.

Can OSPF Process IDs Differ Between Routers?

Yes. Process IDs are locally significant and don't need to match between neighbors.

How Many Routers Can Exist in a Single OSPF Area?

Cisco recommends a practical limit of 50 routers per area for manageability, though larger designs are technically possible.

Does OSPF Support Load Balancing?

Yes - OSPF automatically performs equal-cost multipath (ECMP) load balancing and installs up to four equal-cost routes by default.

Read next