Back to Blog
Tutorial6 min

CCNA Lab Guide: OSPF Configuration Step by Step

Learn OSPF configuration with a hands-on lab. Build a multi-router OSPF topology, verify adjacencies, and troubleshoot common issues.

S
Sarah Chen
Network Engineer

OSPF is one of the most tested topics on the CCNA 200-301. It's also one of the most common protocols you'll configure in real enterprise networks.

This guide walks through building an OSPF lab from scratch — topology design, configuration, verification, and troubleshooting. You can follow along by generating this lab with AI or building it manually.

The Lab Topology

We're building a 3-router OSPF network in a single area:

  • R1 — connects to R2 and R3, plus a LAN (192.168.1.0/24)
  • R2 — connects to R1 and R3, plus a LAN (192.168.2.0/24)
  • R3 — connects to R1 and R2, plus a LAN (192.168.3.0/24)
  • All point-to-point links use 10.0.x.0/30 subnets
  • All routers in OSPF area 0

To generate this lab instantly in NetPilot:

Build an OSPF lab with 3 routers in area 0, fully meshed.
Each router has a LAN interface (192.168.1.0/24, 192.168.2.0/24, 192.168.3.0/24).
Point-to-point links use 10.0.1.0/30, 10.0.2.0/30, 10.0.3.0/30.

Step 1: Configure Interfaces

Before enabling OSPF, each router needs IP addresses on all interfaces.

R1 configuration:

hostname R1
!
interface GigabitEthernet0/0
 description Link to R2
 ip address 10.0.1.1 255.255.255.252
 no shutdown
!
interface GigabitEthernet0/1
 description Link to R3
 ip address 10.0.2.1 255.255.255.252
 no shutdown
!
interface GigabitEthernet0/2
 description LAN
 ip address 192.168.1.1 255.255.255.0
 no shutdown

R2 configuration:

hostname R2
!
interface GigabitEthernet0/0
 description Link to R1
 ip address 10.0.1.2 255.255.255.252
 no shutdown
!
interface GigabitEthernet0/1
 description Link to R3
 ip address 10.0.3.1 255.255.255.252
 no shutdown
!
interface GigabitEthernet0/2
 description LAN
 ip address 192.168.2.1 255.255.255.0
 no shutdown

R3 configuration:

hostname R3
!
interface GigabitEthernet0/0
 description Link to R1
 ip address 10.0.2.2 255.255.255.252
 no shutdown
!
interface GigabitEthernet0/1
 description Link to R2
 ip address 10.0.3.2 255.255.255.252
 no shutdown
!
interface GigabitEthernet0/2
 description LAN
 ip address 192.168.3.1 255.255.255.0
 no shutdown

Verify interfaces are up before moving on:

R1# show ip interface brief

Every interface should show up/up. If not, check the no shutdown command.

Step 2: Enable OSPF

Now configure OSPF on all three routers. We'll use process ID 1 and put everything in area 0.

R1:

router ospf 1
 router-id 1.1.1.1
 network 10.0.1.0 0.0.0.3 area 0
 network 10.0.2.0 0.0.0.3 area 0
 network 192.168.1.0 0.0.0.255 area 0

R2:

router ospf 1
 router-id 2.2.2.2
 network 10.0.1.0 0.0.0.3 area 0
 network 10.0.3.0 0.0.0.3 area 0
 network 192.168.2.0 0.0.0.255 area 0

R3:

router ospf 1
 router-id 3.3.3.3
 network 10.0.2.0 0.0.0.3 area 0
 network 10.0.3.0 0.0.0.3 area 0
 network 192.168.3.0 0.0.0.255 area 0

Key things to understand:

  • Router ID — uniquely identifies each router in OSPF. Set it explicitly to avoid confusion.
  • Network command — uses wildcard masks (inverse of subnet mask). 0.0.0.3 matches a /30, 0.0.0.255 matches a /24.
  • Area 0 — the backbone area. All OSPF networks must have an area 0, and in single-area OSPF, everything goes here.

Step 3: Verify OSPF Adjacencies

After configuring all three routers, verify that OSPF neighbors are forming:

R1# show ip ospf neighbor
 
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           0   FULL/  -        00:00:33    10.0.1.2        Gi0/0
3.3.3.3           0   FULL/  -        00:00:37    10.0.2.2        Gi0/1

What you're looking for:

  • State: FULL — the adjacency is fully established and databases are synchronized
  • Two neighbors on R1 — one for each point-to-point link (R2 and R3)
  • Dead Time counting down — this resets every time a Hello packet is received (default 40 seconds)

If a neighbor shows INIT or 2WAY instead of FULL, there's a problem. See the troubleshooting section below.

If OSPF neighbors aren't forming, check hello timers, area IDs, and subnet masks — in that order. These three mismatches cause 90% of OSPF adjacency failures.

Step 4: Check the Routing Table

With OSPF running, each router should learn routes to the other routers' LANs:

R1# show ip route ospf
 
      192.168.2.0/24 [110/2] via 10.0.1.2, 00:02:15, GigabitEthernet0/0
      192.168.3.0/24 [110/2] via 10.0.2.2, 00:02:10, GigabitEthernet0/1

What this tells you:

  • [110/2] — 110 is the administrative distance for OSPF, 2 is the metric (cost)
  • via 10.0.1.2 — the next-hop IP to reach that network
  • R1 learned about 192.168.2.0/24 (R2's LAN) and 192.168.3.0/24 (R3's LAN)

Test end-to-end connectivity:

R1# ping 192.168.3.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5)

Step 5: Explore OSPF Details

These commands help you understand what OSPF is doing under the hood — useful for the exam and real troubleshooting.

View the OSPF database:

R1# show ip ospf database
 
            OSPF Router with ID (1.1.1.1) (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         245         0x80000004 0x00B3C1 5
2.2.2.2         2.2.2.2         241         0x80000004 0x009ACA 5
3.3.3.3         3.3.3.3         238         0x80000004 0x0081D3 5

Each router generates a Router LSA (Type 1) describing its links. All three routers should appear in every router's database.

Check OSPF interface details:

R1# show ip ospf interface brief
 
Interface    PID   Area   IP Address/Mask    Cost  State Nbrs F/C
Gi0/0        1     0      10.0.1.1/30        1     P2P   1/1
Gi0/1        1     0      10.0.2.1/30        1     P2P   1/1
Gi0/2        1     0      192.168.1.1/24     1     DR    0/0
  • Cost — default is 1 for GigabitEthernet (reference bandwidth / interface bandwidth)
  • State: P2P — point-to-point, no DR/BDR election needed
  • Nbrs F/C — Full neighbors / total neighbors on that interface

Common OSPF Troubleshooting

If your neighbors aren't forming, check these in order:

1. Mismatched Hello/Dead timers

R1# show ip ospf interface GigabitEthernet0/0 | include Timer
  Timer intervals configured, Hello 10, Dead 40

Both sides must match. Default: Hello 10s, Dead 40s.

2. Mismatched area IDs

If R1 has an interface in area 0 but R2 has the same link in area 1, they won't form an adjacency. Check with show ip ospf interface.

3. Mismatched subnet masks

If R1's interface is configured as /30 but R2's is /24, OSPF will reject the Hello packets. Both ends of a link must be in the same subnet.

4. Missing network statement

The network command must match the interface IP. A common mistake:

! Wrong — this won't match 10.0.1.1
network 10.0.0.0 0.0.0.3 area 0
 
! Correct
network 10.0.1.0 0.0.0.3 area 0

5. Interface is down

Always verify with show ip interface brief first. A down/down interface can't form OSPF adjacencies.

What's Next

Once you're comfortable with single-area OSPF, the next steps for CCNP study are:

  • Multi-area OSPF — area types (stub, NSSA, totally stubby), inter-area route summarization
  • OSPF cost manipulation — changing reference bandwidth, per-interface cost
  • OSPF authentication — MD5 and SHA authentication between neighbors

You can practice all of these in CCNP-level labs or build a VLAN lab to combine routing with switching concepts.


Ready to practice? Get started with NetPilot — describe your OSPF topology and get a working lab in under 2 minutes.

Try NetPilot Free

Build enterprise-grade network labs in seconds with AI assistance

Get Started Free