How to Configure Single-Area OSPF on Cisco Routers (Step-by-Step)

A full R1/R2/R3 single-area OSPF lab with IP plan, router ospf config, and the show commands that prove neighbors are Full and routes are installed.

How to Configure Single-Area OSPF on Cisco Routers (Step-by-Step) - PingLabz OSPF article title card
Topology diagram: R1, R2 and R3 in OSPF Area 0, R1 Et0/1 10.1.12.1 to R2 Et0/1 10.1.12.2 on 10.1.12.0/30 and R2 Et0/2 10.1.23.2 to R3 Et0/2 10.1.23.1 on 10.1.23.0/30, cost 10 each, with R2 Loopback1 192.168.1.1/24 advertised as 192.168.1.0/24.
Lab Topology - R1, R2, R3 connected in a line via Area 0

Step 1: Configure IP Addresses

R1

R1(config)# interface loopback 0
R1(config-if)# ip address 1.1.1.1 255.255.255.255
R1(config-if)# description Router ID

R1(config)# interface ethernet0/1
R1(config-if)# ip address 10.1.12.1 255.255.255.252
R1(config-if)# no shutdown

R2

R2(config)# interface loopback 0
R2(config-if)# ip address 2.2.2.2 255.255.255.255

R2(config)# interface loopback 1
R2(config-if)# ip address 192.168.1.1 255.255.255.0
R2(config-if)# description User Network
R2(config-if)# ip ospf network point-to-point

R2(config)# interface ethernet0/1
R2(config-if)# ip address 10.1.12.2 255.255.255.252
R2(config-if)# no shutdown

R2(config)# interface ethernet0/2
R2(config-if)# ip address 10.1.23.2 255.255.255.252
R2(config-if)# no shutdown

R3

R3(config)# interface loopback 0
R3(config-if)# ip address 3.3.3.3 255.255.255.255

R3(config)# interface ethernet0/2
R3(config-if)# ip address 10.1.23.1 255.255.255.252
R3(config-if)# no shutdown

These configs come from a rerun built in my home lab on Cisco IOL 17.18.2 in Containerlab. IOL keeps Ethernet0/0 for management, so the links use Ethernet0/1 and Ethernet0/2: R1 Et0/1 to R2 Et0/1 on 10.1.12.0/30, and R2 Et0/2 to R3 Et0/2 on 10.1.23.0/30. R3 uses 10.1.23.1; an earlier version of this post gave it 10.1.23.3, which is the broadcast address of a /30 and can't be assigned to a host.

Verify connectivity:

(This article is part of the PingLabz OSPF series - the full OSPF guide maps the whole cluster in reading order.)

R1# ping 10.1.12.2
R2# ping 10.1.23.1

Step 2: Enable OSPF and Configure Router ID

R1

R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1

R2

R2(config)# router ospf 1
R2(config-router)# router-id 2.2.2.2

R3

R3(config)# router ospf 1
R3(config-router)# router-id 3.3.3.3

What we did:

  • router ospf 1 - Start OSPF process 1 (number is locally significant)
  • router-id x.x.x.x - Manually set Router ID

Step 3: Advertise Networks with Network Statements

Understanding Network Statements

Format:

network [network-address] [wildcard-mask] area [area-id]

What it does:

  • Matches interfaces whose IP addresses fall within the specified range
  • Enables OSPF on those interfaces
  • Assigns them to the specified area

Wildcard Masks Explained

A wildcard mask is the inverse of a subnet mask.

Rule:

  • 0 = must match
  • 255 = don't care

Examples:

10.1.12.0/30
Subnet Mask255.255.255.252
Wildcard Mask0.0.0.3
Meaning
Match 10.1.12.0 - 10.1.12.3
192.168.1.0/24
Subnet Mask255.255.255.0
Wildcard Mask0.0.0.255
Meaning
Match 192.168.1.0 - 192.168.1.255
10.0.0.0/8
Subnet Mask255.0.0.0
Wildcard Mask0.255.255.255
Meaning
Match 10.0.0.0 - 10.255.255.255
Any interface
Subnet MaskN/A
Wildcard Mask
0.0.0.0 255.255.255.255
MeaningMatch any IP

Shortcut:
Subtract each octet of the subnet mask from 255 to get the wildcard mask.

Example: 255.255.255.0

  • 255 - 255 = 0
  • 255 - 255 = 0
  • 255 - 255 = 0
  • 255 - 0 = 255
  • Wildcard = 0.0.0.255

Configure Network Statements

R1

R1(config-router)# network 1.1.1.1 0.0.0.0 area 0
R1(config-router)# network 10.1.12.0 0.0.0.3 area 0

What this does:

  • First statement: Enable OSPF on Loopback0 (exact match for 1.1.1.1)
  • Second statement: Enable OSPF on Et0/1 (10.1.12.1 falls in 10.1.12.0/30 range)

R2

R2(config-router)# network 2.2.2.2 0.0.0.0 area 0
R2(config-router)# network 192.168.1.0 0.0.0.255 area 0
R2(config-router)# network 10.1.12.0 0.0.0.3 area 0
R2(config-router)# network 10.1.23.0 0.0.0.3 area 0

R3

R3(config-router)# network 3.3.3.3 0.0.0.0 area 0
R3(config-router)# network 10.1.23.0 0.0.0.3 area 0

Alternative: Match All Interfaces

If you want to enable OSPF on all interfaces:

Router(config-router)# network 0.0.0.0 255.255.255.255 area 0

⚠️ Warning: This enables OSPF on every interface. Use carefully.

Step 4: Verify OSPF Neighbors

Check neighbor adjacencies:

R1# show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:35    10.1.12.2       Ethernet0/1
R2# show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/DR         00:00:33    10.1.23.1       Ethernet0/2
1.1.1.1           1   FULL/BDR        00:00:32    10.1.12.1       Ethernet0/1
R3# show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/BDR        00:00:37    10.1.23.2       Ethernet0/2

What to look for:

  • State: FULL - Adjacency is formed
  • FULL/DR or FULL/BDR - Ethernet defaults to the BROADCAST network type, so even these /30 links elect a DR and BDR. FULL/ - only appears on point-to-point network types
  • Dead Time - Counting down from 40 seconds (default)

✅ Success! All neighbors are in FULL state.

Adjacency diagram: both /30 links are FULL; R2 is DR and R1 is BDR on 10.1.12.0/30, and R3 is DR and R2 is BDR on 10.1.23.0/30.
OSPF Neighbor Adjacencies - both links in FULL state

Step 5: Verify OSPF Routes

Check Routing Table

R1:

R1# show ip route ospf
      2.0.0.0/32 is subnetted, 1 subnets
O        2.2.2.2 [110/11] via 10.1.12.2, 00:01:09, Ethernet0/1
      3.0.0.0/32 is subnetted, 1 subnets
O        3.3.3.3 [110/21] via 10.1.12.2, 00:00:55, Ethernet0/1
      10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
O        10.1.23.0/30 [110/20] via 10.1.12.2, 00:01:00, Ethernet0/1
O     192.168.1.0/24 [110/11] via 10.1.12.2, 00:00:23, Ethernet0/1

Understanding the output:

  • O = OSPF route
  • [110/11] = [Administrative Distance / Metric]
  • 110 = OSPF's AD
  • 11 = Cost to reach 2.2.2.2: 10 for R1's Ethernet0/1 plus 1 for R2's Loopback0. IOL reports its Ethernet ports at 10 Mbps, so each one costs 10 with the default 100 Mbps reference bandwidth
  • via 10.1.12.2 = Next-hop IP
  • Ethernet0/1 = Exit interface

Why R2's Loopback1 needs ip ospf network point-to-point: without it, IOS advertises a loopback as a /32 host route whatever mask you configure. Before I added the command, R1 learned the user network like this:

R1# show ip route ospf
      192.168.1.0/32 is subnetted, 1 subnets
O        192.168.1.1 [110/11] via 10.1.12.2, 00:00:26, Ethernet0/1

With the command under interface loopback 1, R1 learns 192.168.1.0/24, as in the table above.

Test Connectivity

Ping all loopbacks from R1:

R1# ping 2.2.2.2 source 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms

R1# ping 3.3.3.3 source 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 3/6/20 ms

R1# ping 192.168.1.1 source 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/2/2 ms

✅ Full connectivity achieved!

Step 6: Verify OSPF Configuration

Check OSPF Process

R2# show ip ospf
 Routing Process "ospf 1" with ID 2.2.2.2
 Start time: 00:03:48.485, Time elapsed: 00:01:55.465
 Supports only single TOS(TOS0) routes
...
 Number of areas in this router is 1. 1 normal 0 stub 0 nssa
 Reference bandwidth unit is 100 mbps
    Area BACKBONE(0)
        Number of interfaces in this area is 4 (2 loopback)
        Area has no authentication
        SPF algorithm last executed 00:00:27.724 ago
        SPF algorithm executed 11 times

Key fields:

  • Router ID: 2.2.2.2
  • Number of areas: 1 (Area 0)
  • Number of interfaces: 4 (Et0/1, Et0/2, Lo0, Lo1), two of them loopbacks

Check OSPF Interfaces

R2# show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo0          1     0               2.2.2.2/32         1     LOOP  0/0
Lo1          1     0               192.168.1.1/24     1     P2P   0/0
Et0/2        1     0               10.1.23.2/30       10    BDR   1/1
Et0/1        1     0               10.1.12.2/30       10    DR    1/1

Key fields:

  • State: LOOP for Lo0, P2P for Lo1 (because of ip ospf network point-to-point), and DR or BDR on the Ethernet links
  • Nbrs F/C: Neighbors Full / Total (e.g., 1/1 = 1 full neighbor out of 1 total)

Check Detailed Interface Info

R2# show ip ospf interface Ethernet0/1
Ethernet0/1 is up, line protocol is up
  Internet Address 10.1.12.2/30, Interface ID 3, Area 0
  Attached via Network Statement
  Process ID 1, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 10
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           10        no          no            Base
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 2.2.2.2, Interface address 10.1.12.2
  Backup Designated router (ID) 1.1.1.1, Interface address 10.1.12.1
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:01
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  Can be protected by per-prefix Loop-Free FastReroute
  Can be used for per-prefix Loop-Free FastReroute repair paths
  Not Protected by per-prefix TI-LFA
  Index 1/3/3, flood queue length 0
  Next 0x0(0)/0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 2
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 1.1.1.1  (Backup Designated Router)
  Suppress hello for 0 neighbor(s)

Key fields:

  • Area: 0
  • Network Type: BROADCAST (the Ethernet default)
  • Cost: 10
  • State: DR, with R1 (1.1.1.1) as BDR
  • Hello timer: 10 seconds
  • Dead timer: 40 seconds
  • Neighbor Count: 1 (R1)

Step 7: Check OSPF Database (LSDB)

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         67          0x80000006 0x008A4C 2
2.2.2.2         2.2.2.2         28          0x8000000B 0x0010D8 4
3.3.3.3         3.3.3.3         48          0x80000005 0x001E8C 2

                Net Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum
10.1.12.2       2.2.2.2         74          0x80000001 0x00A06F
10.1.23.1       3.3.3.3         65          0x80000001 0x006792

What you see:

  • Each router advertises a Type 1 Router LSA
  • All three routers are in the LSDB
  • Each /30 link also has a Type 2 Network LSA, originated by its DR (R2 on 10.1.12.0/30, R3 on 10.1.23.0/30)
  • LSDBs are synchronized (same LSAs on all routers)

Get the OSPF Field Reference - 9 pages, free

Everything you'd want to remember about OSPF on nine printable pages. State machine diagram, LSA types, troubleshooting decision tree, copy-paste IOS XE templates, and real lab captures. Free for PingLabz members - just sign up with your email.

Get the OSPF cheat-sheet

Common Configuration Mistakes

Mistake 1: Wrong Wildcard Mask

Problem:

R1(config-router)# network 10.1.12.0 0.0.0.255 area 0

Impact:
This matches 10.1.12.0 - 10.1.12.255 (256 IPs). If the interface is 10.1.12.1/30, it still matches, but it's sloppy and can cause issues in more complex configs.

Fix:

R1(config-router)# network 10.1.12.0 0.0.0.3 area 0

Mistake 2: Forgetting to Include Loopbacks

Problem:
Loopback networks aren't advertised because there's no network statement for them.

Symptom:
show ip route ospf on other routers doesn't show the loopback networks.

Fix:
Add network statements for loopbacks:

R1(config-router)# network 1.1.1.1 0.0.0.0 area 0

Mistake 3: Different Area IDs

Problem:

R1(config-router)# network 10.1.12.0 0.0.0.3 area 0
R2(config-router)# network 10.1.12.0 0.0.0.3 area 1  ← Wrong area

Impact:
Neighbors won't form. Area ID mismatch prevents adjacencies.

Fix:
Ensure both sides of a link are in the same area.

Mistake 4: Wrong OSPF Process Number

Common question:
"Does the OSPF process number need to match on all routers?"

Answer:
No.
The process number is locally significant. It doesn't need to match.

Example (this works):

  • R1: router ospf 1
  • R2: router ospf 100
  • R3: router ospf 42

Neighbors will still form as long as area IDs match.

Troubleshooting OSPF Neighbors Not Forming

OSPF Neighbor State Machine - the 7-state progression to FULL
OSPF Neighbor State Machine - the 7-state progression to FULL

If neighbors aren't forming, check:

✅ IP connectivity - Can you ping the neighbor's IP?
✅ Area ID match - show ip ospf interface
✅ Subnet mask match - Mismatched masks prevent adjacency
✅ Hello/Dead timers match - show ip ospf interface
✅ Authentication - If enabled, configs must match
✅ Network statements - Are interfaces included in OSPF?
✅ Passive interfaces - Passive interfaces don't send Hellos

Debug OSPF adjacencies:

R1# debug ip ospf adj

⚠️ Turn off debug when done:

R1# undebug all

Learn more: OSPF Neighbors Not Forming Troubleshooting Guide

Best Practices for Single-Area OSPF

1. Use Specific Network Statements

Don't be lazy with wildcard masks. Use precise matches:

Good:

network 10.1.12.0 0.0.0.3 area 0

Bad:

network 0.0.0.0 255.255.255.255 area 0

2. Always Set Router ID Manually

Don't rely on automatic selection:

router-id 1.1.1.1

3. Use Passive Interfaces for User-Facing Networks

If a network has no other OSPF routers (e.g., user VLANs), make it passive:

R2(config-router)# passive-interface loopback 1

Learn more: OSPF Passive Interfaces

4. Adjust Reference Bandwidth

If you have GigabitEthernet or faster links:

Router(config-router)# auto-cost reference-bandwidth 10000

Learn more: How OSPF Calculates Cost

5. Document Your Config

Add descriptions to interfaces and document the OSPF design.

Summary: Configuration Checklist

Now you know how to:

✅ Enable OSPF with router ospf [process-id]
✅ Set Router ID with router-id
✅ Advertise networks with network statements
✅ Use wildcard masks correctly
✅ Verify neighbors with show ip ospf neighbor
✅ Check routes with show ip route ospf
✅ Troubleshoot common issues

Next Step:
Now that you can configure basic OSPF, learn about passive interfaces - a critical security and optimization feature. Read OSPF Passive Interfaces: When and How to Use Them next.

Internal Links:

Take the OSPF reference with you
The free OSPF field-reference PDF: neighbor states, LSA types, and the show commands you will actually run. Delivered by email, no card required.
Get the free PDF

Read next