Single-Area OSPF Configuration – Complete Guide with Examples
1. What Is Single-Area OSPF?
Single-area OSPF places all routers in a single OSPF area — almost always Area 0 (the backbone). It is the simplest OSPF deployment: there are no Area Border Routers (ABRs), no inter-area summarisation, and the entire OSPF domain shares one Link-State Database (LSDB). Every router runs a full SPF calculation against the same topology.
- Simple to configure and manage — only two LSA types (Type 1 and Type 2) are present
- Fast convergence — fewer LSAs mean a smaller LSDB and quicker SPF runs
- No inter-area summarisation overhead — no Type 3/4/5 LSAs to manage
- Ideal for small to medium networks — up to roughly 50 routers before multi-area is recommended
Typical deployment scenarios: campus networks, small branch office networks, test labs, and any environment where all routers are under the same administrative control and the network diameter is manageable.
Related pages: OSPF Overview | OSPF Areas & LSAs | OSPF DR/BDR | OSPF Neighbor States | Wildcard Masks | Routing Metrics | Default Routes | show ip route | show ip protocols | Step-by-Step: OSPF Lab
2. Key OSPF Terminology
| Term | Description |
|---|---|
| Router ID (RID) | Unique 32-bit identifier written in dotted-decimal (e.g., 1.1.1.1). Selected in order: manually configured → highest loopback IP → highest active interface IP. Must be unique across the OSPF domain. |
| OSPF Process ID | Locally significant integer (1–65535) that identifies the OSPF instance on a router. Does not need to match between neighbouring routers. |
| Area ID | 32-bit number written in decimal (e.g., 0) or dotted-decimal (e.g., 0.0.0.0). All routers sharing an adjacency must use the same area ID on that link. |
| Wildcard Mask | Bitwise inverse of the subnet mask. Used in network statements. A ‘0’ bit = must match; a ‘1’ bit = ignored. Example: /24 subnet → wildcard 0.0.0.255. See: Wildcard Masks Explained |
| OSPF Cost | Interface metric = Reference BW ÷ Interface BW. Default reference = 100 Mbps. Lower cost = preferred path. Raise the reference with auto-cost reference-bandwidth on modern networks. |
| LSDB | Link-State Database — the topology map built from LSAs. All routers in the same area must have identical LSDBs before SPF can run. |
3. OSPF Network Types in Single Area
| Network Type | DR/BDR? | Hello / Dead Timers | Description | Example Links |
|---|---|---|---|---|
| Broadcast | Yes | 10 s / 40 s | Multiple routers on same segment; DR/BDR elected to reduce adjacencies | Ethernet LANs, Wi-Fi |
| Point-to-Point | No | 10 s / 40 s | Exactly two routers; no DR/BDR; simplest and fastest adjacency formation | Serial (HDLC/PPP), GRE tunnels |
| NBMA | Yes | 30 s / 120 s | No broadcast support; manual neighbour configuration required | Frame Relay hub-and-spoke, ATM |
| Point-to-Multipoint | No | 30 s / 120 s | Each connection treated as a separate point-to-point; avoids DR/BDR complexity | Frame Relay partial-mesh |
4. Enabling OSPF – Two Methods
Method A: Network Statement (Global Config Mode)
router ospf 1
router-id 1.1.1.1
network 192.168.1.0 0.0.0.255 area 0 ! matches any interface in 192.168.1.0/24
network 10.0.12.0 0.0.0.3 area 0 ! matches the /30 link to R2 precisely
The network statement activates OSPF on any interface whose IP
falls within the specified range. Use the most specific wildcard possible to
avoid accidentally enabling OSPF on unintended interfaces.
Method B: Interface-Level (More Precise — Preferred)
interface GigabitEthernet0/0
ip ospf 1 area 0 ! enables OSPF process 1 directly on this interface
Method B is the preferred approach on modern Cisco IOS and IOS-XE. It is explicit, readable, and eliminates the risk of a broad wildcard mask activating OSPF on unintended interfaces.
5. Router ID Configuration
Always set the Router ID manually. If OSPF determines the RID automatically and an interface IP later changes or goes down, the RID may change — resetting all adjacencies and causing a full SPF recalculation.
! Set Router ID manually (under router ospf)
router ospf 1
router-id 1.1.1.1
! After changing the RID on a live router, reset the OSPF process to apply it:
Router# clear ip ospf process
! Verify the active RID:
Router# show ip ospf | include Router ID
! Output: Router ID 1.1.1.1
Automatic RID selection order (when not manually set): highest IP on any loopback interface → if no loopback, highest IP on any active physical interface. A dedicated loopback with a /32 mask is a stable RID source if manual configuration is not feasible.
6. Wildcard Mask Calculation
A wildcard mask is the bitwise inverse of the subnet mask. Subtract each octet of the subnet mask from 255 to get the wildcard.
| Prefix | Subnet Mask | Wildcard Mask | OSPF network statement example |
|---|---|---|---|
| /32 | 255.255.255.255 | 0.0.0.0 | network 1.1.1.1 0.0.0.0 area 0 — matches exactly one IP (loopback) |
| /30 | 255.255.255.252 | 0.0.0.3 | network 10.0.12.0 0.0.0.3 area 0 — matches 10.0.12.0–10.0.12.3 |
| /24 | 255.255.255.0 | 0.0.0.255 | network 192.168.1.0 0.0.0.255 area 0 — matches /24 range |
| /23 | 255.255.254.0 | 0.0.1.255 | network 10.1.0.0 0.0.1.255 area 0 — matches 10.1.0.0–10.1.1.255 |
| /16 | 255.255.0.0 | 0.0.255.255 | network 10.0.0.0 0.0.255.255 area 0 — matches entire 10.0.x.x range |
7. OSPF Cost and Reference Bandwidth
OSPF cost = Reference Bandwidth ÷ Interface Bandwidth. The default reference bandwidth is 100 Mbps, which means GigabitEthernet (1000 Mbps) and FastEthernet (100 Mbps) both calculate to cost 1 — making them indistinguishable to OSPF. Always raise the reference bandwidth on every router in the domain.
! Raise reference bandwidth to 10 Gbps on ALL routers in the domain
! (must be consistent; change causes SPF recalculation)
router ospf 1
auto-cost reference-bandwidth 10000 ! 10GigE=cost 1; 1GigE=cost 10; 100Mbps=cost 100
! Override cost on a specific interface (takes precedence over auto-cost)
interface GigabitEthernet0/1
ip ospf cost 5
! Verify per-interface OSPF cost and timers
Router# show ip ospf interface GigabitEthernet0/1
8. Passive Interfaces
A passive interface still has its network advertised into OSPF, but Hello packets are suppressed — so no OSPF neighbours can form on that port. Use it on LAN-facing ports connected to end hosts, not to other routers.
! Suppress Hellos on a specific interface
router ospf 1
passive-interface GigabitEthernet0/1
! Best practice: make all interfaces passive by default, then selectively enable
router ospf 1
passive-interface default
no passive-interface GigabitEthernet0/0 ! enable Hellos toward R2
no passive-interface GigabitEthernet0/2 ! enable Hellos toward R3
9. Default Route Advertisement
! Step 1: Static default route toward the Internet
ip route 0.0.0.0 0.0.0.0 203.0.113.1
! Step 2: Redistribute it into OSPF as a Type 5 External LSA
router ospf 1
default-information originate
! Optional: always advertise even if no local default route exists
router ospf 1
default-information originate always
Without always, the default is only advertised when a default
route exists in the routing table. The always keyword is useful
for edge routers that must continuously inject a default, but use it carefully
— it can black-hole traffic if the upstream link goes down.
See also: Default Routes
10. OSPF Timers
Hello and Dead intervals must match exactly on both sides of an adjacency. A mismatch prevents the neighbour relationship from forming and is one of the most common OSPF troubleshooting scenarios.
| Timer | Default (Broadcast / P2P) | Default (NBMA) | Purpose |
|---|---|---|---|
| Hello interval | 10 seconds | 30 seconds | How often Hello packets are sent to maintain neighbour relationships |
| Dead interval | 40 seconds (4 × Hello) | 120 seconds | Time without a Hello before the neighbour is declared down |
! Change timers on an interface (must match the remote side)
interface GigabitEthernet0/0
ip ospf hello-interval 5
ip ospf dead-interval 20
11. LSA Types in Single-Area OSPF
| LSA Type | Name | Generated By | Description | Flooding Scope |
|---|---|---|---|---|
| Type 1 | Router LSA | Every OSPF router | Describes the router’s own links, their states, and costs within the area | Within originating area only |
| Type 2 | Network LSA | DR on multi-access (Ethernet) segments | Describes the multi-access segment and all OSPF routers attached to it; only present when a DR exists | Within originating area only |
In single-area OSPF you will only ever see Type 1 and Type 2 LSAs unless external routes are redistributed (which generates Type 5 External LSAs from an ASBR). Type 3, 4, and 5 LSAs only appear in multi-area designs. See also: OSPF Areas & LSAs – Complete Guide
12. Verification Commands
! Confirm OSPF is running: shows Router ID, area, and SPF statistics
Router# show ip ospf
! List all OSPF neighbours and their adjacency state (goal: FULL)
Router# show ip ospf neighbor
! Show per-interface OSPF detail: cost, timers, DR/BDR, Hello/Dead intervals
Router# show ip ospf interface GigabitEthernet0/0
! Show routes learned via OSPF (marked O in the routing table)
Router# show ip route ospf
! Sample routing table OSPF entry:
! O 10.2.0.0/24 [110/2] via 10.0.12.2, 00:05:33, GigabitEthernet0/0
! ^^^ ^
! AD cost (sum of outgoing interface costs)
! Show the full Link-State Database
Router# show ip ospf database
13. Troubleshooting Single-Area OSPF
| Problem | Likely Cause | Resolution |
|---|---|---|
No neighbour in show ip ospf neighbor |
Mismatched area ID; Hello/Dead mismatch; ACL blocking OSPF (IP protocol 89); passive-interface on wrong port; stub flag mismatch | Verify area IDs, timers; use debug ip ospf hello to see received Hellos |
| Neighbour stuck in ExStart or Exchange | MTU mismatch; duplicate Router IDs on the segment | Match MTUs or add ip ospf mtu-ignore; set unique RIDs with router-id |
| Route missing from routing table | Interface not matched by network statement; passive-interface set incorrectly; wildcard too narrow |
Check show ip ospf interface; confirm all intended interfaces show OSPF enabled |
| Wrong path selected | Default reference bandwidth too low (GigE and FastEthernet both = cost 1) | Set auto-cost reference-bandwidth consistently on all routers; or tune with ip ospf cost |
| Router ID conflict | Two routers share the same RID; adjacency instability results | Set unique router-id on each router then clear ip ospf process |
! Debug adjacency events (use with caution in production)
Router# debug ip ospf adj
! Test basic reachability to neighbour
Router# ping 10.0.12.2
! Trace path to verify routing
Router# traceroute 10.2.0.1
14. Complete Two-Router Configuration Example
Internet
|
[R1] Gi0/0: 10.0.12.1/30 ——— Gi0/0: 10.0.12.2/30 [R2]
| |
Gi0/1: 192.168.1.0/24 Gi0/1: 172.16.1.0/24
(passive, LAN) (passive, LAN)
! ===== R1 =====
router ospf 10
router-id 1.1.1.1
auto-cost reference-bandwidth 10000
passive-interface default
no passive-interface GigabitEthernet0/0 ! router link to R2
network 10.0.12.0 0.0.0.3 area 0
network 192.168.1.0 0.0.0.255 area 0
default-information originate ! advertise default route to R2
ip route 0.0.0.0 0.0.0.0 203.0.113.1 ! static default to Internet
! ===== R2 =====
router ospf 10
router-id 2.2.2.2
auto-cost reference-bandwidth 10000
passive-interface default
no passive-interface GigabitEthernet0/0 ! router link to R1
network 10.0.12.0 0.0.0.3 area 0
network 172.16.1.0 0.0.0.255 area 0
! ===== Verification on R2 =====
R2# show ip ospf neighbor
! Neighbor ID Pri State Dead Time Address Interface
! 1.1.1.1 1 FULL/- 00:00:38 10.0.12.1 GigabitEthernet0/0
R2# show ip route ospf
! O*E2 0.0.0.0/0 [110/1] via 10.0.12.1 (default route from R1)
! O 192.168.1.0/24 [110/2] via 10.0.12.1 (R1 LAN)
15. Summary Command Reference
| Task | Command | Mode |
|---|---|---|
| Enable OSPF process | router ospf <process-id> |
Global config |
| Set Router ID manually | router-id <X.X.X.X> |
Router OSPF config |
| Assign network to area | network <IP> <wildcard> area <ID> |
Router OSPF config |
| Enable OSPF on interface (alternate) | ip ospf <process-id> area <ID> |
Interface config |
| Raise reference bandwidth | auto-cost reference-bandwidth <Mbps> |
Router OSPF config |
| Override interface cost | ip ospf cost <value> |
Interface config |
| Suppress Hellos on interface | passive-interface <int> |
Router OSPF config |
| Advertise default route | default-information originate |
Router OSPF config |
| Verify neighbours | show ip ospf neighbor |
Privileged EXEC |
| Verify interface details / cost | show ip ospf interface <int> |
Privileged EXEC |
| Show OSPF-learned routes | show ip route ospf |
Privileged EXEC |
| Show LSDB | show ip ospf database |
Privileged EXEC |
16. Key Points & CCNA Exam Tips
- Single-area OSPF uses Area 0; only Type 1 (Router) and Type 2 (Network) LSAs are present unless redistribution adds Type 5 External LSAs
- Enable with
router ospf <process-id>thennetwork <IP> <wildcard> area 0, or use interface-levelip ospf <pid> area 0 - Wildcard mask = inverse of subnet mask; ‘0’ bits must match, ‘1’ bits are ignored
- Always set
router-idmanually — automatic RID selection can change when interfaces go up/down, resetting all adjacencies - Always set
auto-cost reference-bandwidthto match your fastest link; the default 100 Mbps makes GigE and FastEthernet both calculate to cost 1 passive-interfacestops OSPF Hellos on a port while still advertising its network into OSPFdefault-information originateadvertises a default route as a Type 5 External LSA; requires a local default route unlessalwaysis added- Hello / Dead timers must match on both sides; default 10 s / 40 s on Ethernet and P2P; 30 s / 120 s on NBMA
- OSPF process IDs are locally significant and do not need to match between routers
- Verify adjacency with
show ip ospf neighbor; the goal state is FULL - OSPF routes appear as
[110/cost]in the routing table — AD = 110, second number = cumulative interface cost along the path