OSPFv2 Single-Area Configuration
Configuring OSPF on a Cisco router takes only three commands. The skill that earns marks is the wildcard mask and the verification that proves neighbours reached the FULL state and routes were learned.
- Enable OSPF with router ospf
and advertise networks with the network ... area 0 command. - Convert a subnet mask to its wildcard mask and match interfaces correctly.
- Stop unnecessary Hellos with passive-interface.
- Set a stable router-id.
- Verify operation with show ip ospf neighbor, show ip ospf interface brief, and show ip route ospf.
The three-step configuration
A single-area OSPF design puts every router in area 0. The configuration is:
- Enter OSPF configuration mode with a process ID:
router ospf 1. - Advertise the networks to route with
network <network> <wildcard> area 0. - (Recommended) set a stable router ID and add passive interfaces.
! R1: enable OSPF process 1 and advertise both LANs into area 0
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
R1(config-router)# network 10.0.0.0 0.0.0.255 area 0
R1(config-router)# network 10.0.1.0 0.0.0.255 area 0
R1(config-router)# passive-interface GigabitEthernet0/0
R1(config-router)# end
The process ID (here 1) is locally significant — it does not have to match on neighbouring routers. It simply distinguishes multiple OSPF instances on the same router, which is unusual in small networks. Routers only form adjacencies when they are on the same link and in the same area.
router ospf does not need to match between routers. Neighbours must
match on the area ID and the link, not on the process ID.
The network command
The network command serves two purposes at once: it tells OSPF which interfaces to run on and it advertises the matching connected networks into the area. An interface matches only if its address falls inside the network/wildcard pair. Anything matched is enabled for OSPF; anything not matched stays silent.
You do not have to enable OSPF interface-by-interface in the router configuration; a single
network statement can match several interfaces at once. There is also an interface-level
alternative:
R1(config)# interface GigabitEthernet0/1
R1(config-if)# ip ospf 1 area 0
Both methods produce the same adjacency; the network method is the classic one the exam
expects. Whichever you use, only the interfaces you intend should be included.
Wildcard masks
A wildcard mask is the inverse of a subnet mask: every mask bit is flipped, so 1 becomes 0 and 0 becomes 1. In the network command, a wildcard bit of 0 means “must match exactly” and a 1 means “ignore this bit”. To turn a subnet mask into a wildcard, subtract each octet from 255:
| Prefix | Subnet mask | Wildcard mask | Matches |
|---|---|---|---|
| /24 | 255.255.255.0 | 0.0.0.255 | All addresses in one /24 |
| /16 | 255.255.0.0 | 0.0.255.255 | All addresses in one /16 |
| /25 | 255.255.255.128 | 0.0.0.127 | The first or second half of a /24 |
| Host (/32) | 255.255.255.255 | 0.0.0.0 | Exactly one address |
| Any | — | 255.255.255.255 | Every interface |
For example, network 10.0.0.0 0.0.0.255 area 0 enables OSPF on any interface whose
address is 10.0.0.x. To enable OSPF on all interfaces, some engineers write
network 0.0.0.0 255.255.255.255 area 0, although this can accidentally include interfaces
you did not intend.
Passive interfaces
By default, enabling OSPF on an interface sends Hellos out of it, looking for neighbours. On a LAN with no other OSPF router — or worse, on a link facing users — those Hellos are wasted and slightly insecure. A passive interface suppresses Hellos on that interface while still advertising its network into OSPF. It is the standard way to “advertise the LAN but do not talk to hosts”.
! silence Hellos toward the LAN, keep advertising 10.0.0.0/24
R1(config-router)# passive-interface GigabitEthernet0/0
! make everything passive, then re-enable only real neighbour links
R1(config-router)# passive-interface default
R1(config-router)# no passive-interface GigabitEthernet0/1
The passive-interface default pattern is a best practice: it makes every interface
passive, then the administrator explicitly turns Hellos back on only where a genuine OSPF neighbour
exists (the inter-router links). This prevents stray adjacencies.
Setting the router ID
As Lesson 19 explained, the router ID is chosen from a configured value, else the highest loopback, else the highest active physical interface. Because that automatic choice can change, set it explicitly:
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
! for the new ID to take effect immediately, restart the process
R1# clear ip ospf process
The router ID must be unique in the OSPF domain. A common convention is to assign each router a loopback address (for example 1.1.1.1, 2.2.2.2, 3.3.3.3) and use the same values as router IDs.
Verification
Three commands prove that OSPF is working:
! 1. are neighbours fully adjacent?
R1# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/DR 00:00:35 10.0.1.2 GigabitEthernet0/1
! 2. which interfaces run OSPF, in which area?
R1# show ip ospf interface brief
Interface PID Area IP Address/Mask Cost State Nbrs F/C
Gi0/1 1 0 10.0.1.1/24 1 P2P 1/1
! 3. which routes came from OSPF? (code O)
R1# show ip route ospf
O 10.0.2.0/24 [110/2] via 10.0.1.2, 00:02:11, GigabitEthernet0/1
The FULL state in show ip ospf neighbor is the goal: it means the two
routers have exchanged their full databases and agree. A neighbour stuck in INIT,
2-WAY, or EXSTART points to a parameter mismatch or a link problem.
show ip route ospf lists only OSPF-learned routes, each starting with the code
O and showing [110/<cost>]. Useful extras are
show ip protocols (which networks OSPF is advertising) and show ip ospf
(process ID, router ID, and SPF statistics).
O route and vice versa.The vocabulary you need
Every term below appears in the lesson text above. Select one to read its definition, then use the quiz at the end to check what stuck.
Review
Check what you have learned with these review questions.
Sources & references
- Cisco. CCNA (200-301) Exam Topics. cisco.com.
- IETF. Request for Comments (RFCs). rfc-editor.org.
- IANA. Internet Assigned Numbers Authority registries. iana.org.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.