Introduction
You have configured static routes. You have set up default
routes. But now your network is growing, and you cannot keep adding routes
manually.
This is where OSPF comes in.
OSPF (Open Shortest Path First) is a dynamic routing
protocol that automatically learns routes, finds the best path, and adapts when
links fail. Once you configure it, the routers do the work for you.
But here is what most beginners get wrong. They enable OSPF,
see routes in the table, and think they are done. Then a link goes down,
traffic stops, and they have no idea why.
In this lab, you will configure OSPF step by step, verify
neighbor relationships, troubleshoot common issues, and test failover. This is
the exact process network engineers use in real networks.
📌 New to CCNA? Start
with Why Most Beginners Fail CCNA and OSI Model vs TCP/IP.
Your Pain Points
Many CCNA students struggle with OSPF because they only
memorize commands without understanding how OSPF actually works.
|
Ø
Pain Point |
Why It Hurts |
|
Ø
I enabled OSPF, but neighbors won't form |
You don't know why OSPF neighbors fail to
establish adjacency. |
|
Ø
I don't understand wildcard masks |
The network command syntax confuses
you. |
|
Ø
I don't know why routes are missing |
Some networks appear in the routing table,
others don't. |
|
Ø
I can't troubleshoot OSPF issues |
You don't know which commands to use. |
|
Ø
I am scared of CCNA exam questions |
OSPF questions are common and you keep getting
them wrong. |
Good news: By the end of this lab, all of these
problems will disappear.
📌 Related: Read Subnetting Made Easy and Wildcard Mask Explained.
What is OSPF? (The Simple Answer)
OSPF is a link-state routing protocol that calculates the
shortest path to each destination using a mathematical algorithm called
Dijkstra's algorithm. Unlike RIP, which uses hop count and has a limit of
15 hops, OSPF uses cost based on bandwidth and scales to large networks.
OSPF sends Hello packets to discover neighbors. Once
neighbors are discovered, they form an adjacency and exchange routing
information. When the network changes, OSPF recalculates the best paths
automatically.
A router sends updates only when the network changes, making
OSPF efficient in production networks.
Lab Topology
We will configure four routers in a single OSPF area. Each
router connects to a local LAN and to other routers.
|
Device |
Interface |
IP
Address |
Subnet
Mask |
Purpose |
|
R1 |
G0/0 |
192.168.1.1 |
255.255.255.0 |
Gateway for PC1 |
|
R1 |
S0/0/0 |
10.0.12.1 |
255.255.255.252 |
Link to R2 |
|
R1 |
S0/0/1 |
10.0.13.1 |
255.255.255.252 |
Link to R3 |
|
R2 |
S0/0/0 |
10.0.12.2 |
255.255.255.252 |
Link to R1 |
|
R2 |
S0/0/1 |
10.0.24.2 |
255.255.255.252 |
Link to R4 |
|
R3 |
S0/0/0 |
10.0.13.3 |
255.255.255.252 |
Link to R1 |
|
R3 |
G0/0 |
192.168.20.1 |
255.255.255.0 |
Gateway for PC2 |
|
R4 |
S0/0/0 |
10.0.24.4 |
255.255.255.252 |
Link to R2 |
|
R4 |
G0/0 |
192.168.30.1 |
255.255.255.0 |
Gateway for PC3 |
Step 1: Configure Basic Settings
Configure Hostnames and IP Addresses
On R1:
Router> enable
Router# configure terminal
Router(config)# hostname R1
R1(config)# interface G0/0
R1(config-if) # Ip address 192.168.1.1 255.255.255.0
R1(config-if) # no shutdown
R1(config)# interface S0/0/0
R1(config-if) # ip address 10.0.12.1 255.255.255.252
R1(config-if) # clock rate 128000
R1(config-if)# no shutdown
R1(config)# interface S0/0/1
R1(config-if)# ip address 10.0.13.1 255.255.255.252
R1(config-if)# clock rate 128000
R1(config-if)# no shutdown
On R2:
Router> enable
Router# configure terminal
Router(config)# hostname R2
R2(config)# interface S0/0/0
R2(config-if)# ip address 10.0.12.2 255.255.255.252
R2(config-if)# no shutdown
R2(config)# interface S0/0/1
R2(config-if)# ip address 10.0.24.2 255.255.255.252
R2(config-if)# clock rate 128000
R2(config-if)# no shutdown
On R3:
Router> enable
Router# configure terminal
Router(config)# hostname R3
R3(config)# interface S0/0/0
R3(config-if)# ip address 10.0.13.3 255.255.255.252
R3(config-if)# no shutdown
R3(config)# interface G0/0
R3(config-if)# ip address 192.168.20.1 255.255.255.0
R3(config-if)# no shutdown
On R4:
Router> enable
Router# configure terminal
Router(config)# hostname R4
R4(config)# interface S0/0/0
R4(config-if)# ip address 10.0.24.4 255.255.255.252
R4(config-if)# no shutdown
R4(config)# interface G0/0
R4(config-if)# ip address 192.168.30.1 255.255.255.0
R4(config-if)# no shutdown
Step 2: Configure OSPF on Each Router
The network command tells OSPF which interfaces to
include. The wildcard mask determines which bits must match.
Method 1: Using network Command with Wildcard Mask
On R1:
R1(config)# router ospf 1
R1(config-router)# network 192.168.1.0 0.0.0.255 area 0
R1(config-router)# network 10.0.12.0 0.0.0.3 area 0
R1(config-router)# network 10.0.13.0 0.0.0.3 area 0
On R2:
R2(config)# router ospf 1
R2(config-router)# network 10.0.12.0 0.0.0.3 area 0
R2(config-router)# network 10.0.24.0 0.0.0.3 area 0
On R3:
R3(config)# router ospf 1
R3(config-router)# network 10.0.13.0 0.0.0.3 area 0
R3(config-router)# network 192.168.20.0 0.0.0.255 area 0
On R4:
R4(config)# router ospf 1
R4(config-router)# network 10.0.24.0 0.0.0.3 area 0
R4(config-router)# network 192.168.30.0 0.0.0.255 area 0
Method 2: Using Interface Subcommands
Instead of the network command, you can enable OSPF directly on each interface:
R1(config)# interface G0/0
R1(config-if)# ip ospf 1 area 0
R1(config)# interface S0/0/0
R1(config-if)# ip ospf 1 area 0
R1(config)# interface S0/0/1
R1(config-if)# ip ospf 1 area 0
This method is more explicit and avoids wildcard mask
calculations.
Step 3: Configure Loopback Interfaces
Loopback interfaces provide stable Router IDs. OSPF prefers loopback IPs as the Router ID over physical interfaces.
R1(config)# interface loopback 0
R1(config-if)# ip address 1.1.1.1 255.255.255.255
R2(config)# interface loopback 0
R2(config-if)# ip address 2.2.2.2 255.255.255.255
R3(config)# interface loopback 0
R3(config-if)# ip address 3.3.3.3 255.255.255.255
R4(config)# interface loopback 0
R4(config-if)# ip address 4.4.4.4 255.255.255.255
To manually set the Router ID :
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
If you change the Router ID, restart the OSPF process:
R1# clear ip ospf process
Step 4: Configure Passive Interfaces
Interfaces connected to LANs should not send OSPF Hellos. Set them as passive.
R1(config)# router ospf 1
R1(config-router)# passive-interface G0/0
R3(config)# router ospf 1
R3(config-router)# passive-interface G0/0
R4(config)# router ospf 1
R4(config-router)# passive-interface G0/0
This prevents unnecessary OSPF traffic on LAN segments.
Step 5: Verification Commands
Check OSPF Neighbor Relationships
R1# show ip ospf neighbor
Expected Output:
Neighbor ID
Pri State Dead Time Address Interface
2.2.2.2 0
FULL/ - 00:00:37 10.0.12.2 Serial0/0/0
3.3.3.3
0 FULL/ - 00:00:35 10.0.13.3 Serial0/0/1
All neighbors should show FULL state.
Check the Routing Table
R1# show ip route
Expected Output:
O 10.0.24.0/30
[110/128] via 10.0.12.2, 00:01:23, Serial0/0/0
O
192.168.20.0/24 [110/65] via 10.0.13.3, 00:01:23, Serial0/0/1
O
192.168.30.0/24 [110/129] via 10.0.12.2, 00:01:23, Serial0/0/0
C 192.168.1.0/24
is directly connected, GigabitEthernet0/0
OSPF routes are marked with O.
Check OSPF-Enabled Interfaces
R1# show ip ospf interface brief
Check the Link-State Database
R1# sho ip ospf database
Step 6: Test Connectivity
From PC1 to PC2
PC1> ping 192.168.20.10
If the ping is successful, OSPF is working correctly.
From PC1 to PC3
PC1> ping 192.168.30.10
Step 7: Troubleshooting Common Issues
Issue 1: OSPF Neighbor Not Forming
Possible Cause: Hello/Dead timer mismatch.
Fix:
R1(config)# interface S0/0/0
R1(config-if)# ip ospf hello-interval 10
R1(config-if)# ip ospf dead-interval 40
Both routers must have the same Hello and Dead
intervals.
Issue 2: Route Missing from Routing Table
Possible Cause: OSPF not enabled on the
interface or wrong wildcard mask.
Fix:
R1(config)# router ospf 1
R1(config-router)# network 192.168.1.0 0.0.0.255 area 0
Check that the wildcard mask matches the interface IP
correctly.
Issue 3: Router ID Conflict
Possible Cause: Two routers using the same
Router ID.
Fix:
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
R1# clear ip ospf process
Step 8: Failover Testing
Test OSPF's ability to reroute traffic when a link
fails.
Step 1: Ping from PC1 to PC3 continuously.
PC1> ping 192.168.30.10 -t
Step 2: Shut down the link between R1 and R2.
R1(config)# interface S0/0/0
R1(config-if)# shutdown
Step 3: Observe the ping output.
The pings may stop briefly but should resume through the
alternate path (R1 → R3 → R4 → R2 → R4? Actually R1 → R3 → R4 → R2 is not a
direct path; in this topology, traffic may go R1 → R3 → R4 → R2 or R1 → R3 → R4
→ R2 depending on the topology).
Wait, with this topology, if the R1-R2 link fails, R1 can reach R2 via R3-R4-R2:
R1 → R3 → R4 → R2
OSPF will automatically find this path.
Step 4: Re-enable the interface.
R1(config)# interface S0/0/0
R1(config-if)# no shutdown
Step 5: OSPF converges automatically. Verify:
R1# show ip route ospf
Summary: What You Learned Today
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
📌 Related: Read TCP vs UDP Explained and IPv6 Addressing for Beginners for more networking basics. Your Action Step for Today
- Open
Cisco Packet Tracer and build the topology.
- Configure
OSPF on all routers.
- Verify
neighbor relationships with show ip ospf neighbor.
- Test
connectivity between PCs.
- Test
failover by shutting down a link.
- Comment
below with your results.
📚 Recommended External References
Cisco Official - OSPF Configuration Guide
For a deeper understanding of OSPF concepts and Cisco best practices, you can refer to the official documentation and trusted lab guides below. These resources cover OSPF theory, configuration commands, and troubleshooting techniques.
👉 Cisco OSPF Configuration Guide
Cisco Networking Academy - Packet Tracer Labs
Hands-on OSPF labs from Cisco NetAcad using Packet Tracer. Includes multi-area OSPF setup and verification steps.
👉 Cisco NetAcad Packet Tracer
GeeksforGeeks - OSPF Protocol Overview
A beginner-friendly explanation of OSPF working, LSA types, and key features of the Open Shortest Path First protocol.
👉 GeeksforGeeks OSPF Protocol
Packet Tracer Network - CCNA OSPF Lab
A complete step-by-step OSPF lab for CCNA with IP addressing table, configuration, and show commands for verification.
Final Thoughts
OSPF is the most widely used routing protocol in enterprise
networks. It automatically learns routes, adapts to changes, and scales to
large networks.
The only way to truly learn OSPF is to practice. Build the
lab, configure the commands, and break things on purpose. That is how you
learn.
Remember: show ip ospf neighbor is your best
friend. If you see FULL, OSPF is working. If you see something else,
troubleshoot.
If this guide helped you, share it with
someone who is struggling with OSPF.
.png)



0 Comments