OSPF Single-Area Configuration
Static routes require manual updates every time the network changes — a time-consuming and error-prone process in larger networks. OSPF (Open Shortest Path First) is a link-state routing protocol that automatically discovers neighbors, shares network topology information, and calculates the best path to every known network using Dijkstra's Shortest Path First (SPF) algorithm. When a link fails or a new network is added, OSPF automatically updates all routers in the area within seconds.
OSPFv2 operates over IPv4 and is organised into areas — logical groupings of routers that share a common link-state database. All areas must connect to Area 0 (the backbone area). In a single-area deployment — the most common CCNA scenario — all routers belong to Area 0, share a complete map of the topology, and independently run SPF to build their routing tables.
Before starting, complete Hostname, Banner & Password Configuration and Static Route Configuration to understand routing fundamentals and Administrative Distance. For an OSPF conceptual overview see OSPF Overview.
1. How OSPF Works — The Three Tables
Every OSPF router builds and maintains three separate databases before it can forward traffic. Understanding these tables is essential for troubleshooting:
| Table | Command to View | What It Contains | Populated By |
|---|---|---|---|
| Neighbor Table | show ip ospf neighbor |
All directly connected OSPF routers that have formed adjacency | Hello packets exchanged on connected interfaces |
| Topology Table (LSDB) | show ip ospf database |
Complete map of all links and routers in the area — Link State Database. See OSPF Areas & LSAs | LSAs (Link State Advertisements) flooded by all routers |
| Routing Table | show ip route ospf |
Best paths calculated by SPF from the LSDB — routes marked O | SPF algorithm run locally on the LSDB |
OSPF Neighbor Adjacency — Hello Protocol
OSPF routers discover each other by sending Hello packets to the multicast address 224.0.0.5 every 10 seconds on Ethernet links (Hello interval). A neighbor is declared dead if no Hello is received within 40 seconds (Dead interval = 4 × Hello interval). For two routers to become full neighbors, the following parameters must match:
| Parameter | Must Match? | Default Value (Ethernet) | Notes |
|---|---|---|---|
| Area ID | ✅ Yes | — | Both interfaces must be in the same OSPF area |
| Hello interval | ✅ Yes | 10 seconds | Mismatch prevents adjacency forming |
| Dead interval | ✅ Yes | 40 seconds | Must match on both sides |
| Subnet & mask | ✅ Yes | — | Both interfaces must be on the same subnet |
| Authentication | ✅ Yes | None | If configured, type and password must match |
| MTU | ⚠️ Effectively | 1500 bytes | MTU mismatch causes stuck in EXSTART/EXCHANGE state |
| Router ID | ❌ No | — | Must be unique per router but does not need to match neighbors |
| Process ID | ❌ No | — | Locally significant only — neighbors can use different process IDs |
OSPF Router ID
Every OSPF router must have a unique Router ID (RID) — a 32-bit value written in dotted decimal notation (like an IP address). IOS selects the Router ID in this order:
| Priority | Source | Notes |
|---|---|---|
| 1 (Highest) | Manually configured: router-id [IP] |
✅ Always use this — predictable and stable |
| 2 | Highest IP address on any active loopback interface | Stable — loopbacks never go down |
| 3 (Lowest) | Highest IP address on any active physical interface | ⚠️ Unstable — changes if the interface goes down |
router-id [IP] before adding network statements.
If the RID changes after OSPF starts (due to a new loopback being added),
all adjacencies drop and OSPF reconverges — causing a network outage.
After changing the RID, run clear ip ospf process to force
IOS to adopt the new value.
OSPF Cost — How the Best Path Is Chosen
OSPF selects the best path based on cost — the lower the cost, the better the path. Cost is calculated as: Cost = 100 Mbps / Interface Bandwidth (Cisco default reference bandwidth).
| Interface Type | Bandwidth | Default Cost | Problem? |
|---|---|---|---|
| Serial (T1) | 1.544 Mbps | 64 | — |
| FastEthernet | 100 Mbps | 1 | — |
| GigabitEthernet | 1000 Mbps | 1 | ⚠️ Same cost as FastEthernet — OSPF cannot distinguish |
| 10 GigabitEthernet | 10,000 Mbps | 1 | ⚠️ Same cost — adjust reference bandwidth |
auto-cost reference-bandwidth 1000 (sets reference to 1 Gbps).
This must be configured consistently on all routers in the area.
2. Lab Topology & IP Addressing
Three routers in a triangle topology — every router connects to the others, giving OSPF multiple paths to evaluate. All routers will be in OSPF Area 0.
192.168.10.0/24
(LAN — PC1)
|
Gi0/0
┌──────────────┐
│ NetsTuts_R1 │ RID: 1.1.1.1
│ │
└──────────────┘
Gi0/1 Gi0/2
10.0.12.1 10.0.13.1
| |
10.0.12.0/30 10.0.13.0/30
| |
10.0.12.2 10.0.13.2
Gi0/0 Gi0/1
┌──────────────┐ ┌──────────────┐
│ NetsTuts_R2 │ │ NetsTuts_R3 │
│ RID: 2.2.2.2 │ │ RID: 3.3.3.3 │
└──────────────┘ └──────────────┘
Gi0/1 Gi0/0
10.0.23.1 10.0.23.2
| |
└───────────────┘
10.0.23.0/30
|
Gi0/0
192.168.30.0/24
(LAN — PC3, on R3)
| Device | Interface | IP Address | OSPF Network | Area |
|---|---|---|---|---|
| NetsTuts_R1 | Gi0/0 | 192.168.10.1 /24 | 192.168.10.0 /24 | 0 |
| NetsTuts_R1 | Gi0/1 | 10.0.12.1 /30 | 10.0.12.0 /30 | 0 |
| NetsTuts_R1 | Gi0/2 | 10.0.13.1 /30 | 10.0.13.0 /30 | 0 |
| NetsTuts_R2 | Gi0/0 | 10.0.12.2 /30 | 10.0.12.0 /30 | 0 |
| NetsTuts_R2 | Gi0/1 | 10.0.23.1 /30 | 10.0.23.0 /30 | 0 |
| NetsTuts_R3 | Gi0/0 | 192.168.30.1 /24 | 192.168.30.0 /24 | 0 |
| NetsTuts_R3 | Gi0/0 | 10.0.23.2 /30 | 10.0.23.0 /30 | 0 |
| NetsTuts_R3 | Gi0/1 | 10.0.13.2 /30 | 10.0.13.0 /30 | 0 |
3. Step 1 — Configure OSPF on NetsTuts_R1
The correct sequence is: enable the OSPF process with a process ID, set the
Router ID, adjust reference bandwidth, then advertise networks with
network statements. Finally, suppress Hello packets on LAN interfaces
using passive-interface.
NetsTuts_R1>en NetsTuts_R1#conf t Enter configuration commands, one per line. End with CNTL/Z. ! ── Start OSPF process 1 ────────────────────────────────── NetsTuts_R1(config)#router ospf 1 ! ── Set Router ID manually (best practice) ─────────────── NetsTuts_R1(config-router)#router-id 1.1.1.1 ! ── Adjust reference bandwidth for GigabitEthernet ─────── NetsTuts_R1(config-router)#auto-cost reference-bandwidth 1000 ! ── Advertise networks in Area 0 ───────────────────────── NetsTuts_R1(config-router)#network 192.168.10.0 0.0.0.255 area 0 NetsTuts_R1(config-router)#network 10.0.12.0 0.0.0.3 area 0 NetsTuts_R1(config-router)#network 10.0.13.0 0.0.0.3 area 0 ! ── Passive interface — no OSPF Hellos on LAN ──────────── NetsTuts_R1(config-router)#passive-interface GigabitEthernet0/0 NetsTuts_R1(config-router)#exit NetsTuts_R1(config)#end NetsTuts_R1#wr Building configuration... [OK] NetsTuts_R1#
network Command — Wildcard Mask Explained
The network command uses a wildcard mask
(inverse of the subnet mask) to match interfaces. Any interface whose IP address
falls within the matched range is added to OSPF and begins sending Hellos:
| network Statement | Wildcard | Matches Interface | Meaning |
|---|---|---|---|
network 10.0.12.0 0.0.0.3 area 0 |
0.0.0.3 | Gi0/1 (10.0.12.1) | Match any IP from 10.0.12.0 to 10.0.12.3 |
network 192.168.10.0 0.0.0.255 area 0 |
0.0.0.255 | Gi0/0 (192.168.10.1) | Match any IP from 192.168.10.0 to 192.168.10.255 |
network 0.0.0.0 255.255.255.255 area 0 |
255.255.255.255 | All interfaces | Match any IP — advertise all interfaces in one command |
network 0.0.0.0 255.255.255.255 area 0
matches every interface on the router — useful in labs to avoid calculating
individual wildcard masks. In production, use specific network statements for
better control over which interfaces participate in OSPF.
4. Step 2 — Configure OSPF on NetsTuts_R2 and NetsTuts_R3
NetsTuts_R2
NetsTuts_R2>en NetsTuts_R2#conf t Enter configuration commands, one per line. End with CNTL/Z. NetsTuts_R2(config)#router ospf 1 NetsTuts_R2(config-router)#router-id 2.2.2.2 NetsTuts_R2(config-router)#auto-cost reference-bandwidth 1000 NetsTuts_R2(config-router)#network 10.0.12.0 0.0.0.3 area 0 NetsTuts_R2(config-router)#network 10.0.23.0 0.0.0.3 area 0 NetsTuts_R2(config-router)#exit NetsTuts_R2(config)#end NetsTuts_R2#wr Building configuration... [OK] NetsTuts_R2# %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on GigabitEthernet0/0 from LOADING to FULL, Loading Done
NetsTuts_R3
NetsTuts_R3>en NetsTuts_R3#conf t Enter configuration commands, one per line. End with CNTL/Z. NetsTuts_R3(config)#router ospf 1 NetsTuts_R3(config-router)#router-id 3.3.3.3 NetsTuts_R3(config-router)#auto-cost reference-bandwidth 1000 NetsTuts_R3(config-router)#network 192.168.30.0 0.0.0.255 area 0 NetsTuts_R3(config-router)#network 10.0.23.0 0.0.0.3 area 0 NetsTuts_R3(config-router)#network 10.0.13.0 0.0.0.3 area 0 NetsTuts_R3(config-router)#passive-interface GigabitEthernet0/0 NetsTuts_R3(config-router)#exit NetsTuts_R3(config)#end NetsTuts_R3#wr Building configuration... [OK] NetsTuts_R3# %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on GigabitEthernet0/0 from LOADING to FULL, Loading Done %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on GigabitEthernet0/1 from LOADING to FULL, Loading Done
5. Step 3 — Passive Interface & Default Route
passive-interface — Best Practice for LAN Ports
The passive-interface command tells OSPF to include the interface's
network in its advertisements but stop sending and receiving Hello packets on it.
This is essential for access-facing interfaces where no OSPF neighbor ever exists:
| Behavior | Normal OSPF Interface | Passive Interface |
|---|---|---|
| Sends Hello packets | ✅ Yes — every 10 seconds | ❌ No |
| Receives Hello packets | ✅ Yes | ❌ No |
| Network advertised in OSPF | ✅ Yes | ✅ Yes — still included in LSAs |
| Forms neighbor adjacency | ✅ Yes (if neighbor present) | ❌ No — by design |
Global Passive with Selective Exceptions
In networks where most interfaces are LAN-facing, it is cleaner to make all interfaces passive by default, then selectively enable OSPF hellos only on inter-router links:
NetsTuts_R1(config)#router ospf 1 NetsTuts_R1(config-router)#passive-interface default NetsTuts_R1(config-router)#no passive-interface GigabitEthernet0/1 NetsTuts_R1(config-router)#no passive-interface GigabitEthernet0/2
Advertising a Default Route via OSPF
If R1 has a default route to the internet (or an upstream router), it can share it with all OSPF neighbors so they automatically learn where to send unknown destinations:
NetsTuts_R1(config)#ip route 0.0.0.0 0.0.0.0 203.0.113.1 NetsTuts_R1(config)#router ospf 1 NetsTuts_R1(config-router)#default-information originate
default-information originate causes R1 to generate an
External Type 2 LSA for the default route — all OSPF routers in Area 0
automatically install R1 as their Gateway of Last Resort. The route
appears as O*E2 on neighboring routers.
6. Verification
show ip ospf neighbor
NetsTuts_R1#show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 1 FULL/DR 00:00:31 10.0.12.2 GigabitEthernet0/1 3.3.3.3 1 FULL/DR 00:00:38 10.0.13.2 GigabitEthernet0/2
show ip ospf neighbor — State Field Reference
| State | Meaning | Normal? |
|---|---|---|
| FULL | LSDB fully synchronized — neighbor relationship complete | ✅ Yes — goal state |
| 2WAY | Hello received and sent — normal for non-DR/BDR routers on multi-access networks | ✅ Yes — normal for DROther peers |
| EXSTART | Negotiating master/slave for database exchange | ⚠️ Transitional — if stuck, check MTU |
| EXCHANGE | Exchanging DBD (Database Description) packets | ⚠️ Transitional — if stuck, check MTU |
| LOADING | Requesting missing LSAs from neighbor | ⚠️ Transitional — should quickly move to FULL |
| INIT | Hello received but own Router ID not in the Hello — one-way communication | ❌ Problem — check area ID, subnet mismatch |
| DOWN | No Hellos received within Dead interval | ❌ Problem — check interface, connectivity, timers |
| ATTEMPT | Attempting to contact neighbor (NBMA networks only) | ⚠️ Only on non-broadcast networks |
show ip route ospf
NetsTuts_R1#show ip route ospf
Codes: O - OSPF
O 10.0.23.0/30 [110/2] via 10.0.12.2, 00:05:44, GigabitEthernet0/1
[110/2] via 10.0.13.2, 00:05:44, GigabitEthernet0/2
O 192.168.30.0/24 [110/2] via 10.0.12.2, 00:05:44, GigabitEthernet0/1
[110/2] via 10.0.13.2, 00:05:44, GigabitEthernet0/2
show ip ospf — Process Information
NetsTuts_R1#show ip ospf
Routing Process "ospf 1" with ID 1.1.1.1
Start time: 00:10:34.123, Time elapsed: 00:05:52.456
Supports only single TOS(TOS0) routes
Supports opaque LSA
Supports Link-local Signaling (LLS)
Supports area transit capability
Router is not originating router-LSAs with maximum metric
Initial SPF schedule delay 5000 msecs
Minimum hold time between two consecutive SPFs 10000 msecs
Maximum wait time between two consecutive SPFs 10000 msecs
Number of external LSA 0. Checksum Sum 0x000000
Number of opaque AS LSA 0. Checksum Sum 0x000000
Number of DCbitless external and opaque AS LSA 0
Number of DoNotAge external and opaque AS LSA 0
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Number of areas transit capable is 0
External flood list length 0
IETF NSF helper support enabled
Cisco NSF helper support enabled
Reference bandwidth unit is 1000 mbps
Area BACKBONE(0)
Number of interfaces in this area is 3 (1 passive)
Area has no authentication
SPF algorithm last executed 00:04:21.456 ago
SPF algorithm executed 3 times
Area ranges are
Number of LSA 7. Checksum Sum 0x03A210
Number of opaque link LSA 0. Checksum Sum 0x000000
Number of DCbitless LSA 0
show ip ospf interface brief
NetsTuts_R1#show ip ospf interface brief Interface PID Area IP Address/Mask Cost State Nbrs F/C Gi0/0 1 0 192.168.10.1/24 1 DROTH 0/0 Gi0/1 1 0 10.0.12.1/30 1 DR 1/1 Gi0/2 1 0 10.0.13.1/30 1 DR 1/1
show ip ospf database
NetsTuts_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 367 0x80000004 0x00A210 3
2.2.2.2 2.2.2.2 362 0x80000003 0x00B312 2
3.3.3.3 3.3.3.3 359 0x80000003 0x00C414 3
Verification Command Summary
| Command | What It Shows | Primary Use |
|---|---|---|
show ip ospf neighbor |
All OSPF neighbors, their state, dead timer, and interface | First check — confirm FULL adjacency |
show ip route ospf |
Only OSPF-learned routes with AD and metric | Confirm routes are being learned correctly |
show ip ospf |
OSPF process details — Router ID, timers, area info, SPF count | Verify RID, reference bandwidth, area configuration |
show ip ospf interface brief |
Per-interface OSPF state, cost, DR/BDR role, neighbor counts | Confirm interfaces are participating in correct area |
show ip ospf database |
The Link State Database — all LSAs in the area | Verify all routers are present and LSDB is synchronized |
show ip route |
Full routing table — OSPF routes shown as O or O*E2 | Final end-to-end route verification |
show ip ospf interface [int] |
Detailed interface parameters — Hello/Dead timers, area, cost, DR/BDR | Troubleshoot timer mismatches or adjacency issues |
7. Troubleshooting OSPF Adjacency Issues
| Problem | Symptom | Cause | Fix |
|---|---|---|---|
| Neighbor stays in INIT state | show ip ospf neighbor shows INIT — never reaches FULL |
Area ID mismatch — one side uses area 0, other uses area 1. Or subnet/mask mismatch on the link. | Verify show ip ospf interface [int] on both sides — confirm area ID and subnet match |
| Neighbor stuck in EXSTART or EXCHANGE | State bounces between EXSTART and EXCHANGE — never reaches LOADING or FULL | MTU mismatch between interfaces — DBD packets are too large for one side | Match MTU on both interfaces: ip mtu [value], or add ip ospf mtu-ignore as a workaround |
| No neighbor appears at all | show ip ospf neighbor is empty — no neighbors discovered |
Interface not participating in OSPF — network statement missing or wrong wildcard, or passive-interface set on inter-router link |
Check show ip ospf interface brief — confirm both interfaces are in OSPF. Verify no passive-interface on the inter-router link |
| OSPF route missing from routing table | Neighbor is FULL but a specific network is not in show ip route |
Network statement on the remote router does not include that interface — it is not being advertised | Check the remote router's show ip ospf interface brief — confirm all required interfaces are listed |
| Hello/Dead timer mismatch | Neighbor appears briefly then disappears — Dead timer expires | Hello or Dead timers differ between the two sides (one customised, other default) | Use show ip ospf interface [int] on both sides to compare timers. Set them equal with ip ospf hello-interval and ip ospf dead-interval |
| Duplicate Router ID | Adjacency forms then drops — log shows "Duplicate Router ID" warning | Two routers have the same Router ID — OSPF cannot distinguish them | Change the RID on one router: router-id [unique-IP], then clear ip ospf process to apply |
Key Points & Exam Tips
- OSPF uses three tables: Neighbor table (adjacencies), LSDB (topology map), and Routing table (best paths). All three must be healthy for OSPF to work.
- OSPF process ID (
router ospf 1) is locally significant only — neighbors can use different process IDs and still form adjacency. - Always configure the Router ID manually with
router-idbefore addingnetworkstatements. The RID must be unique across all routers in the OSPF domain. - The
networkcommand uses a wildcard mask (not a subnet mask). To match a /30 subnet (255.255.255.252), the wildcard is 0.0.0.3. - Parameters that must match for adjacency: Area ID, Hello interval, Dead interval, subnet and mask. Process ID and Router ID do not need to match.
- passive-interface advertises the network in OSPF but suppresses Hello packets — use it on all LAN-facing interfaces where no OSPF neighbor will ever exist.
- OSPF cost = Reference bandwidth / Interface bandwidth. Default reference is 100 Mbps — change to 1000 Mbps (
auto-cost reference-bandwidth 1000) so GigabitEthernet gets a lower cost than FastEthernet. - The goal neighbor state is FULL. Stuck in EXSTART or EXCHANGE usually means an MTU mismatch. Stuck in INIT means area ID or subnet mismatch.
default-information originateunder the OSPF process advertises the router's static default route to all OSPF neighbors — they learn it as O*E2.- OSPF AD is 110. OSPF routes appear as O in the routing table, with equal-cost paths automatically load-balanced (ECMP up to 4 paths by default).