Basic OSPF Configuration
Course Contents
Introduction
This lab focuses on the basic OSPF configuration. You’ll configure OSPF in a single area across four routers.

By the end, you’ll be able to:
- Start the OSPF process
- Advertise IP Networks in OSPF
- Verify OSPF neighbors and learned routes
⚠️ This lab assumes you’ve already completed the lesson “What is OSPF?”. If not, check that first to understand how OSPF works.
Let’s dive into the configuration together!
Step 1 – Enable the OSPF Process
First, we need to take a look at our OSPF topology and all the IP networks.

The first thing you need to do is enable OSPF on all routers. We’ll begin with Router R1:
R1# configure terminal
R1(config)# router ospf 1
This command starts the OSPF process using Process ID 1.
The Process ID is locally significant, so we can choose any number.
Step 2 – Advertise Networks in OSPF
Once the OSPF process is started, we need to tell the router which network will participate in OSPF.
This is done using the network command inside OSPF router configuration mode.

I have described the syntax of the command above in order to read each part.
Let’s advertise networks connected to Router 1

These networks will be advertised in OSPF!
- 192.168.1.0/24
- 192.168.2.0/24
- 192.168.10.0/24
Here’s the configuration:
R1(config)# router ospf 1 R1(config-router)# network 192.168.1.0 0.0.0.255 area 0 R1(config-router)# network 192.168.2.0 0.0.0.255 area 0 R1(config-router)# network 192.168.10.0 0.0.0.255 area 0
As you can see the 3 networks are advertised into OSPF. You might wonder what a wildcard mask is, since we used it in the command.
What is a Wildcard Mask?
The wildcard mask is the second parameter in the network command.
It defines the range of IP addresses to match.
A wildcard mask is simply the inverse of a subnet mask.
For example:
Subnet Mask | Wildcard Mask |
---|---|
255.255.255.0 | 0.0.0.255 |
255.255.255.252 | 0.0.0.3 |
255.255.255.255 | 0.0.0.0 |
To calculate it, you need to subtract each octet of the subnet mask from 255.
When we enter the command:
R1(config-router)# network 192.168.1.0 0.0.0.255 area 0
…it means:
Enable OSPF on any interface whose IP address starts with 192.168.1 and falls within the 192.168.1.0 to 192.168.1.255 range.
The router will then activate OSPF on that interface, send Hello packets, form adjacencies, and advertise the subnet configured on that interface.
We’ve just focused on R1, but we’ll repeat this approach on each router, by advertising the networks they are directly connected to.
Step 3 – Configure All Routers
Let’s now advertise the connected networks of the other routers (R2, R3, and R4) in OSPF.
Each router must advertise its connected networks using the network command.
This allows the OSPF protocol to discover all parts of the network and build complete routing tables across all routers.

R2
R2(config)# router ospf 1 R2(config-router)# network 192.168.1.0 0.0.0.255 area 0 R2(config-router)# network 192.168.4.0 0.0.0.255 area 0 R2(config-router)# network 192.168.20.0 0.0.0.255 area 0
R3
R3(config)# router ospf 1 R3(config-router)# network 192.168.2.0 0.0.0.255 area 0 R3(config-router)# network 192.168.3.0 0.0.0.255 area 0
R4
R4(config)# router ospf 1 R4(config-router)# network 192.168.3.0 0.0.0.255 area 0 R4(config-router)# network 192.168.4.0 0.0.0.255 area 0
Routers will form Adjacency
Once OSPF is enabled, routers start exchanging Hello packets.

If the configuration is correct, routers will form adjacencies with its connected neighbors. For example, on R1, you might see a system log like this:
*Jul 12 10:21:18.123: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.1.2 on GigabitEthernet0/2 from LOADING to FULL, Loading Done
This indicates that R1 has successfully established a full OSPF adjacency with R2 on interface Gi0/2.
You’ll see similar logs on each router as they discover and synchronize with their neighbors.
Now that adjacencies are established, let’s verify that OSPF is working properly.
Step 4 – Verifying OSPF Operation
Now that OSPF is configured on all routers, it’s time to verify that the network is fully operational.
Let’s start by checking R1, then we’ll make sure that all routers have received the expected OSPF routes.

Our goals are:
- Check that R1 has formed OSPF neighbor adjacencies
- Confirm OSPF is running on the correct interfaces
- Ensure R1 has learned routes via OSPF
- And finally, test full end-to-end connectivity from PC1 to PC2
Verifying OSPF Neighbors
First, we need to check if R1 has discovered its OSPF neighbors.
R1# show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 192.168.20.3 1 FULL/DR 00:00:33 192.168.1.1 Gi0/2 192.168.3.2 1 FULL/BDR 00:00:35 192.168.2.1 Gi0/1
R1 has successfully formed two OSPF neighbor relationships:
- With R2 on interface Gi0/2
- With R3 on interface Gi0/1
This means OSPF Hello packets were exchanged and adjacencies were successfully established.
Checking OSPF Interfaces
Let’s now make sure OSPF is running on the correct interfaces.
R1# show ip ospf interface brief Interface PID Area IP Address Cost State Nbrs F/C Gi0/1 1 0 192.168.2.2 1 DR 1/1 Gi0/2 1 0 192.168.1.2 1 DR 1/1 Gi0/3 1 0 192.168.10.3 1 DR 0/0
Gi0/1 and Gi0/2 are connected to other routers and show 1 neighbor each. This is expected and correct. Gi0/3 is connected to PC1, so no OSPF neighbor is expected on that interface.
This confirms OSPF is active on the right interfaces.
Inspecting the OSPF Routing Table
Let’s now check if R1 has learned routes from its OSPF neighbors.
R1# show ip route ospf O 192.168.20.0/24 [110/2] via 192.168.1.1, 00:00:14, Gi0/2 O 192.168.4.0/24 [110/2] via 192.168.1.1, 00:00:14, Gi0/2 O 192.168.3.0/24 [110/2] via 192.168.2.1, 00:00:15, Gi0/1
These three networks are not directly connected to R1 but appear in its routing table thanks to OSPF.
This confirms that route exchange is working correctly.
You’ll notice that each route includes two values in brackets, like [110/2].
- 110 is the Administrative Distance (AD) of OSPF. It represents the trust level of the routing source.
- The number after the slash (/2) is the OSPF cost, a metric used by OSPF to choose the best path.
If you’re not sure what the cost means yet, don’t worry, we’ll explain it in more detail later.
For now, just know that a lower cost means a better path, and that OSPF automatically calculates it based on the interface bandwidth.
Verifying OSPF on Other Routers
After confirming that R1 has learned its OSPF routes, let’s check one of the other routers to ensure the OSPF process is working in the entire network.
Here’s the output from R2:
R2# show ip route ospf O 192.168.10.0/24 [110/2] via 192.168.1.2, 00:00:12, Gi0/0 O 192.168.2.0/24 [110/2] via 192.168.1.2, 00:00:12, Gi0/0 O 192.168.3.0/24 [110/2] via 192.168.4.2, 00:00:14, Gi0/1
This confirms that R2 has learned routes from R1 and R4 through OSPF.
Even though we’re only showing R2 here, the same verification can be done on R3 and R4.
Each of them has also received all the necessary OSPF routes, and the routing tables are fully populated.
At this point, the OSPF topology is fully synchronized.
Each router knows how to reach every network in the topology, even if it’s multiple hops away.
Testing End-to-End Connectivity from PC1 to PC2
Now that all routers have successfully exchanged routes via OSPF, let’s confirm that communication works from one end of the network to the other.

We’ll test connectivity by pinging PC2 (192.168.20.1) from PC1 (192.168.10.1).
PC1> ping 192.168.20.1 Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
This confirms that:
- The ICMP packets were successfully routed through the OSPF-enabled routers (R1 → R2).
- Return traffic also followed the correct OSPF routes back from PC2 to PC1.
Thanks to OSPF, dynamic routing took care of everything there was no need to configure static routes manually.
Summary
In this lab, you’ve learned the essentials of basic OSPF configuration, including how to:
- Start the OSPF process using the router ospf command
- Enable OSPF on the appropriate interfaces using the network command and wildcard masks
- Verify OSPF operation using commands like show ip ospf neighbor, show ip route, and show ip ospf interface brief
- Confirm full end-to-end connectivity between two hosts, by successfully routing traffic through the OSPF-enabled network.
This basic OSPF configuration demonstrated how routers dynamically learn routes and build a synchronized routing table across the entire network.
You’re now ready to explore more advanced OSPF features and multi-area designs.