New Batch Starts on 16th Oct.
Module: Network Fundamentals (L2 L3 Protocol Testing)
Timing: 07:00 AM to 08:00 AM IST (Weekdays)
Sign Up Now !

OSPF Configuration Example 1: Adjacency Formation Between Two Cisco Routers

Table of Contents


OSPF Configuration Example 1: Adjacency Formation Between Two Cisco Routers

In previous chapters, you learned key OSPF concepts like DR-BDR election and redistribution. In this guide, you’ll follow a step-by-step process to configure OSPF on two Cisco routers, verify adjacency formation, and check the routing table. By the end of this tutorial, you’ll know how to set up OSPF on Cisco routers, laying the groundwork for the other configuration examples we’ll be covering. This post is part of a series, which includes configuration examples on DR and BDR elections, configuring stub areas, and other OSPF-related scenarios to ensure a comprehensive learning experience.

Objective:

In this example, your objective is to configure OSPF on two Cisco routers and verify the adjacency. Afterward, you’ll advertise a loopback network from both routers and check whether the routes appear in the routing table.

Topology :

A network diagram showing two routers with loopback interfaces for an OSPF configuration example, highlighting adjacency check
OSPF Configuration Example 1 : Topology Setup

About OSPF Configuration:

To configure OSPF on a Cisco router, start by entering the command router ospf process-number in global configuration mode. The process number allows you to create multiple OSPF instances on a single router, which is useful for segmenting the network and preventing the sharing of network information between different segments.

After configuring the OSPF process, use the network command to specify the networks that will participate in OSPF. The syntax for this command is “network network-address wildcard-mask area area-number“. It’s important to note that when using this command, you should specify the network address of the interface, not the IP address configured on the interface itself.

For example, in the topology mentioned above, to enable OSPF on the Fast Ethernet 0/0 interface connecting R1 to R2, with an IP address of 1.1.1.1/8, the corresponding OSPF network command would be

network 1.0.0.0 0.255.255.255 area 1

Configuration Procedure:

  1. Configure IP addresses on the physical interfaces of R1 and R2 as given in the topology.
    (Check ping connectivity between the routers.)
  2. Create a loopback interface on both routers and configure IP addresses.
  3. Enable OSPF and advertise networks.
  4. Verify the adjacency status and routing table.

Why use loopback interfaces in this setup?

To check whether OSPF in our router is advertising or learning a network, we need a second network on each router besides the directly connected one between them. In this example, R1 advertises the network 10.0.0.0 using OSPF, while R2 advertises the network 20.0.0.0. Without these loopback interfaces, you wouldn’t be able to verify whether OSPF is actually working or not.

You can use a physical interface instead, but then you would need physical devices connected to both routers to bring those interfaces “UP.” Using a loopback interface allows you to simulate networks without needing any physical devices. This makes the setup more straightforward and efficient for testing and verifying OSPF configurations.

OSPF Configuration Commands:

You can use the following commands on Router1 and Router2 if you’re using Cisco routers. Ensure that the interface states are “up” and that you can ping the neighbor before configuring OSPF. OSPF requires proper physical connectivity to exchange packets and form adjacencies.

1.Setting up the physical interface FastEthernet 0/0 with IP address 1.1.1.1/8 and the loopback interface with IP address 10.1.1.1/8 on Router 1:

2.Configuring OSPF on Router 1 with networks 1.0.0.0 and 2.0.0.0, using a wildcard mask of 0.255.255.255 and assigning them to area 1:

3.Configuring the physical interface FastEthernet 0/0 with IP address 1.1.1.2/8 and the loopback interface with IP address 20.1.1.1/8:

4.Configuring OSPF and advertising the directly connected networks on Router 2:

Adjacency Verification

Before checking the OSPF and routing table, ensure connectivity between your devices. Ping the devices to confirm that the interfaces are connected.

Checking OSPF adjacency status using “show ip ospf neighbor” :

A screenshot showing the output of 'show ip ospf neighbor' from an OSPF configuration example, with a router in FULL state adjacency with its neighbor.
Output of ‘show ip ospf neighbor’ on R1 showing FULL state adjacency with R2

In this output, router R1 has formed an adjacency with R2 (router ID 20.1.1.1) . The adjacency state has reached ‘FULL’. Even in simple topologies like this, OSPF requires at least 30 to 40 seconds to form the adjacency. If you see the state as INIT, 2-WAY, or any other state, wait a bit and then run the command again.

Checking the routes learned using “show ip route ospf” :

A screenshot showing the routes learned by OSPF using the 'show ip route ospf' command on a Cisco router for an OSPF configuration example.
Output of ‘show ip route ospf’ on R1 showing the learned network 20.0.0.0

Understanding the OSPF “show” commands

Now that we have verified the adjacency state and the routing table, let’s try to understand the information present in the output of the above ‘show’ commands.

Understanding “show ip ospf neighbor” output :

The following are different pieces of information we can see in the output:

Neighbor ID: This column lists the router IDs of different neighbors that OSPF has communicated with. Note that not all neighbors need to be in the FULL state with our router.

Priority: This column shows the OSPF interface priority. By default, it is set to one. OSPF uses this priority for DR and BDR elections.

State: This column shows two pieces of information: the adjacency state with the neighbor and whether the neighbor is a DR, BDR, or DROther. In our example, it shows FULL/BDR, which means the neighbor 20.1.1.1 is the BDR, and our router is the DR.”

Dead time: This indicates when our router received the last hello packet from the neighbor. The range typically falls between 30 to 40 seconds because this countdown restarts from 40 each time a hello packet is received.

Address: This is the IP address of the neighbor’s physical interface.

Interface: This is the interface on our router that connects to the neighbor.

Understanding the “show ip route ospf” output :

The first line about the network that R1 has learned using OSPF is:

20.0.0.0/32 is subnetted, 1 subnet.

This line means the Class A network 20.0.0.0 is subnetted, and the subnet mask is 32. Though we have not configured subnetting in our setup, OSPF is intelligent enough to understand that we are using a loopback interface here and will use a mask of 32 for that IP. By using a mask of 32, OSPF is indicating that there is only one IP address on that network.

Ok, now let’s decode the second line:

Illustration of the different fields in the 'show ip route ospf' output, including OSPF route indication, administrative distance, next hop IP, exit interface and metric value.

O 20.1.1.1 [110/2] via 1.1.1.2 , 1:10:49, FastEthernet0/0

“O”: This indicates the route is learned from an OSPF router within the same area. OSPF uses different codes like “O,” “OIA,” “OE2,” etc.

20.1.1.1: This is the network address that OSPF has learned from R2. Although we advertised the network “20.0.0.0” on R2, OSPF considers the IP address assigned to the loopback interface.

[110/2]: The first number, 110, is the administrative distance (AD) of OSPF. The second number, 2, is the metric to reach that network. In this example, we used a FastEthernet interface and a loopback interface, each having a cost of 1, making the total cost 2.

1:10:49: This timer shows how much time has passed since the network was learned.

FastEthernet0/0: This is the exit interface on our router that sends data packets to that network.

In this OSPF configuration example, we covered the basics of OSPF configuration. Now, you can try the same setup in topologies with a few more routers and multiple areas.


Next >>> OSPF Configuration Example 2: Configuring OSPF with Multiple Areas

Previous >>> Understanding OSPF Redistribution

Further reading : cisco


We’d love to hear your feedback and suggestions about this article. Feel free to reach out to us using the WhatsApp number below.

Sajith Achipra has been a trainer and testing consultant at Zframez Technologies since 2009. With 15+ years of experience, he specializes in networking, Python, development, and testing. He conducts online courses to help students and professionals enhance their skills. You can reach him on WhatsApp at +91 8884 884 844 for your training and testing requirements.