How to Configure OSPF on Cisco Router in GNS3

OSPF (Open Shortest Path First) routing protocol is the Dynamic Routing protocol. This algorithm protocol recalculates routing routes in any network change using the Dijkstra algorithm.

How to Configure OSPF on Cisco Router in GNS3

How to Setup OSPF on Router in GNS3

The OSPF routing protocol provides additional security on the network using AS (Autonomous System) numbers. Routers configured with the same AS number can communicate with each other. In addition, routers in the AS 1 field can communicate with routers in the AS 2 field, for example.

Each Router in the AS has full network topology information. So they can easily identify the good path to the destination.

Although the OSPF and EIGRP protocol is similar, the biggest difference between them is that the EIGRP protocol is a routing protocol specific to Cisco devices only.

In our previous article, we gave detailed information about the OSPF protocol. In this article, we will communicate two different networks by activating the OSPF routing protocol on Routers in the GNS3 network simulator program.

How to Configure OSPF

Add a Cloud computer before proceeding with the configuration steps. Next, prepare two VMware virtual machines for network topology.

   Step 1

Start the GNS3 program for the routing protocol and create a new project.

Creating a New Project in GNS3

   Step 2

Create a network topology as in the following image, and add comments to the workspace to make the network topology more understandable.

GNS3 Network Topology

   Step 3

Create two virtual machines in the VMware virtualization program. Perform VMnet settings for the virtual machine.

Select VMnet1 as the Windows 8.1 virtual machine network card setting as follows and continue.

Virtual Machine Network Adapter Setting

   Step 4

In the same way, select VMnet2 as the Windows 10 virtual machine network card setting.

Virtual Machine VMnet Setting

   Step 5

Check the VMnet settings on the VMware Virtual Network Editor.

VMware Virtual Network Editor

   Step 6

Next, run VMware virtual machines and configure the TCP/IP settings according to the network addresses specified in the network topology.

ipconfig

   Step 7

The TCP/IP settings for the Windows 10 virtual machine are also as follows.

ipconfig

   Step 8

Configure the FastEthernet and Serial interfaces of the Cisco Router R1 according to the network topology.

R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#
R1(config)#interface fastethernet 0/0
R1(config-if)#ip address 192.168.5.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#
*Mar 1 00:10:50.427: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:10:51.427: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config)#
R1(config)#interface serial 0/0
R1(config-if)#ip address 10.1.1.1 255.255.255.252
R1(config-if)#no shutdown
R1(config-if)#end
R1#

 
You can check the interface status using the show ip interface brief command on the Cisco Router R1.

R1#show ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.5.1 YES manual up up
Serial0/0 10.1.1.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
Serial0/1 unassigned YES unset administratively down down
R1#

 
R1(config-if)#ip address 192.168.5.1 255.255.255.0

   Step 9

In the same way, configure the FastEthernet and Serial interfaces of the Cisco Router R2.

R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#
R2(config)#interface fastethernet 0/1
R2(config-if)#ip address 192.168.10.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#
*Mar 1 00:12:31.055: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar 1 00:12:32.055: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config)#
R2(config)#interface serial 0/1
R2(config-if)#ip address 10.1.1.2 255.255.255.252
R2(config-if)#no shutdown
R2(config-if)#end
R2#

 
You can check the status of the Cisco Router R2 interfaces as follows.

R2#show ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset administratively down down
Serial0/0 unassigned YES unset administratively down down
FastEthernet0/1 192.168.10.1 YES manual up up
Serial0/1 10.1.1.2 YES manual up up
R2#

 
R2(config-if)#ip address 192.168.10.1 255.255.255.0

   Step 10

Ping the connection from the Windows 8.1 virtual machine to the FastEthernet and Serial interfaces of Router R1 and R2.

Network Testing with Ping

   Step 11

Do the same from the Windows 10 machine. Ping to the opposite network will fail as follows.

Network Testing with Ping

   Step 12

To enable OSPF, open the Router R1 CLI prompt and perform the following commands in sequence.

R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#
R1(config)#router ospf 10
R1(config-router)#network 192.168.5.0 ?
A.B.C.D O-S-P-F wild card bits
R1(config-router)#network 192.168.5.0 0.0.0.255 ?
area Set the O-S-P-F area ID
R1(config-router)#network 192.168.5.0 0.0.0.255 area ?
O-S-P-F area ID as a decimal value
A.B.C.D O-S-P-F area ID in IP address format
R1(config-router)#network 192.168.5.0 0.0.0.255 area 0
R1(config-router)#network 10.1.1.0 0.0.0.3 area 0
R1(config-router)#end
R1#

 
R1(config)#router ospf 10

   Step 13

Use the following commands to enable OSPF on Router2.

R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#
R2(config)#router ospf 10
R2(config-router)#network 192.168.10.0 0.0.0.255 area 0
R2(config-router)#network 10.1.1.0 0.0.0.3 area 0
R2(config-router)#
*Mar 1 00:18:09.227: %O-S-P-F-5-ADJCHG: Process 10, Nbr 192.168.5.1 on Serial0/1 from LOADING to FULL, Loading Done
R2(config-router)#end
R2#

 
R2(config)#router ospf 10

   Step 14

After enabling OSPF on routers, execute the show ip route command on Router R1 and R2 and review the route records.

Cisco Router R1 routing table;

R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - O-S-P-F, IA - O-S-P-F inter area
N1 - O-S-P-F NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - O-S-P-F external type 1, E2 - O-S-P-F external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

O 192.168.10.0/24 [110/74] via 10.1.1.2, 00:01:02, Serial0/0
C 192.168.5.0/24 is directly connected, FastEthernet0/0
10.0.0.0/30 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial0/0
R1#

 
Cisco Router R2 routing table;

R2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - O-S-P-F , IA - O-S-P-F inter area
N1 - O-S-P-F NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - O-S-P-F external type 1, E2 - O-S-P-F external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

C 192.168.10.0/24 is directly connected, FastEthernet0/1
O 192.168.5.0/24 [110/74] via 10.1.1.1, 00:01:02, Serial0/1
10.0.0.0/30 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial0/1
R2#

 
R1#show ip route

   Step 15

After setting up the OSPF protocol on the routers, now test the network connection by pinging each other from the virtual machines.

Pinging from Windows 8.1 machine to Windows 10 machine will succeed as follows!

Ping 192.168.10.10

   Step 16

Pinging from Windows 10 to Windows 8.1 will be successful as follows.

Ping 192.168.5.5

   Step 17

After we have completed the OSPF process and tested the connection between the virtual machines, let’s examine the show commands on the routers.

Cisco Router R1 show commands are as follows.

R1#show ip ospf ?
Process ID number
border-routers Border and Boundary Router Information
database Database summary
flood-list Link state flood list
interface Interface information
max-metric Max-metric origination information
mpls MPLS related information
neighbor Neighbor list
request-list Link state request list
retransmission-list Link state retransmission list
sham-links Sham link information
statistics Various O-S-P-F Statistics
summary-address Summary-address redistribution Information
timers O-S-P-F timers information
traffic Traffic related statistics
virtual-links Virtual link information
| Output modifiers

 
For example, you can examine the “show ip ospf neighbor” and “show ip ospf database” commands.

R1#show ip

   Step 18

You can also review the show command outputs on the Cisco Router R2.

R1#show ip

   Step 19

You can use the debug ip ospf hello command to verify the OSPF routing protocol on routers.

You can view the debug ip ospf hello command output on Router R1 from the image below.

R1#debug ip ospf ?
adj O-S-P-F adjacency events
database-timer O-S-P-F database timer
events O-S-P-F events
flood O-S-P-F flooding
hello O-S-P-F hello events
lsa-generation O-S-P-F lsa generation
mpls O-S-P-F MPLS
nsf O-S-P-F non-stop forwarding events
packet O-S-P-F packets
retransmission O-S-P-F retransmission events
spf O-S-P-F spf
tree O-S-P-F database tree

 
The OSPF routing protocol sends hello packets to Multicast (224.0.0.5).

debug ip

   Step 20

On Router R2, execute the debug ip ospf hello command. You can see hello packages from the image below.

debug ip

   Step 21

Another way to verify the OSPF configuration is to use the Wireshark program. Right-click on the Serial cable between the routers and click Start Capture.

Start Capture

   Step 22

In the Packet Capture window, click OK to continue.

Selecting the Interface to Analyze

   Step 23

After opening the Wireshark program, you can see that Hello packets are sent via Multicast (224.0.0.5) address, as in the image below.

Multicast (224.0.0.5)

OSPF Configuration Show Commands

Router R1 Show Commands

R1#show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface
192.168.10.1 0 FULL/ - 00:00:32 10.1.1.2 Serial0/0
R1#
R1#show ip ospf database

O-S-P-F Router with ID (192.168.5.1) (Process ID 10)

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count
192.168.5.1 192.168.5.1 382 0x80000003 0x00832D 3
192.168.10.1 192.168.10.1 383 0x80000002 0x00B1F4 3
R1#

 


R1#debug ip ospf hello
O-S-P-F hello events debugging is on
R1#
*Mar 1 00:26:47.011: O-S-P-F: Send hello to 224.0.0.5 area 0 on Serial0/0 from 10.1.1.1
R1#
*Mar 1 00:26:48.939: O-S-P-F: Send hello to 224.0.0.5 area 0 on FastEthernet0/0 from 192.168.5.1
*Mar 1 00:26:49.267: O-S-P-F: Rcv hello from 192.168.10.1 area 0 from Serial0/0 10.1.1.2
*Mar 1 00:26:49.267: O-S-P-F: End of hello processing
R1#
*Mar 1 00:26:56.151: O-S-P-F: Rcv hello from 192.168.10.1 area 0 from Serial0/0 10.1.1.2
*Mar 1 00:26:56.151: O-S-P-F: End of hello processing
*Mar 1 00:26:57.011: O-S-P-F: Send hello to 224.0.0.5 area 0 on Serial0/0 from 10.1.1.1
R1#
*Mar 1 00:26:58.939: O-S-P-F: Send hello to 224.0.0.5 area 0 on FastEthernet0/0 from 192.168.5.1
R1#

 


R1#show running-config
Building configuration...

Current configuration : 1152 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
no ip icmp rate-limit unreachable
ip cef
!
!
no ip domain lookup
ip auth-proxy max-nodata-conns 3
ip admission max-nodata-conns 3
!
!
ip tcp synwait-time 5
!
!
!
interface FastEthernet0/0
ip address 192.168.5.1 255.255.255.0
duplex auto
speed auto
!
interface Serial0/0
ip address 10.1.1.1 255.255.255.252
clock rate 2000000
!
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
!
interface Serial0/1
no ip address
shutdown
clock rate 2000000
!
router ospf 10
log-adjacency-changes
network 10.1.1.0 0.0.0.3 area 0
network 192.168.5.0 0.0.0.255 area 0
!
ip forward-protocol nd
!
!
no ip http server
no ip http secure-server
!
no cdp log mismatch duplex
!
!
control-plane
!
!
line con 0
exec-timeout 0 0
privilege level 15
logging synchronous
line aux 0
exec-timeout 0 0
privilege level 15
logging synchronous
line vty 0 4
login
!
!
end
R1#

 
Router R2 Show Commands


R2#show ip ospf ?
Process ID number
border-routers Border and Boundary Router Information
database Database summary
flood-list Link state flood list
interface Interface information
max-metric Max-metric origination information
mpls MPLS related information
neighbor Neighbor list
request-list Link state request list
retransmission-list Link state retransmission list
sham-links Sham link information
statistics Various O-S-P-F Statistics
summary-address Summary-address redistribution Information
timers O-S-P-F timers information
traffic Traffic related statistics
virtual-links Virtual link information
| Output modifiers

R2#

 


R2#show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface
192.168.5.1 0 FULL/ - 00:00:32 10.1.1.1 Serial0/1
R2#
R2#show ip ospf database

O-S-P-F Router with ID (192.168.10.1) (Process ID 10)

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count
192.168.5.1 192.168.5.1 419 0x80000003 0x00832D 3
192.168.10.1 192.168.10.1 418 0x80000002 0x00B1F4 3
R2#

 


R2#debug ip ospf ?
adj O-S-P-F adjacency events
database-timer O-S-P-F database timer
events O-S-P-F events
flood O-S-P-F flooding
hello O-S-P-F hello events
lsa-generation O-S-P-F lsa generation
mpls O-S-P-F  MPLS
nsf O-S-P-F non-stop forwarding events
packet O-S-P-F packets
retransmission O-S-P-F retransmission events
spf O-S-P-F spf
tree O-S-P-F database tree
R2#

 


R2#debug ip ospf hello
OSPF hello events debugging is on
R2#
*Mar 1 00:27:32.383: O-S-P-F: Send hello to 224.0.0.5 area 0 on FastEthernet0/1 from 192.168.10.1
R2#
*Mar 1 00:27:36.975: O-S-P-F: Rcv hello from 192.168.5.1 area 0 from Serial0/1 10.1.1.1
*Mar 1 00:27:36.975: O-S-P-F: End of hello processing
R2#
*Mar 1 00:27:39.223: O-S-P-F: Send hello to 224.0.0.5 area 0 on Serial0/1 from 10.1.1.2
R2#
*Mar 1 00:27:42.383: O-S-P-F: Send hello to 224.0.0.5 area 0 on FastEthernet0/1 from 192.168.10.1
R2#

 

R2#show running-config
Building configuration...
Current configuration : 1154 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
no ip icmp rate-limit unreachable
ip cef
!
!
no ip domain lookup
ip auth-proxy max-nodata-conns 3
ip admission max-nodata-conns 3
!
!
ip tcp synwait-time 5
!
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface Serial0/0
no ip address
shutdown
clock rate 2000000
!
interface FastEthernet0/1
ip address 192.168.10.1 255.255.255.0
duplex auto
speed auto
!
interface Serial0/1
ip address 10.1.1.2 255.255.255.252
clock rate 2000000
!
router ospf 10
log-adjacency-changes
network 10.1.1.0 0.0.0.3 area 0
network 192.168.10.0 0.0.0.255 area 0
!
ip forward-protocol nd
!
!
no ip http server
no ip http secure-server
!
no cdp log mismatch duplex
!
!
!
control-plane
!
!
!
line con 0
exec-timeout 0 0
privilege level 15
logging synchronous
line aux 0
exec-timeout 0 0
privilege level 15
logging synchronous
line vty 0 4
login
!
!
end
R2#

 

How to Configure OSPF Protocol ⇒ Video

You can watch the video below to enable and verify OSPF and also subscribe to our YouTube channel to support us!

   Final Word


In this article, we have configured the OSPF Dynamic Routing protocol configuration in the network simulator. We have mainly addressed the OSPF routing protocol.

In later articles, we will also configure advanced network topologies. Thanks for following us!

   Related Articles


How to Configure RIP in GNS3
How to Configure Static Routing in GNS3
How to Configure RIPv2 in GNS3
How to Configure EIGRP in GNS3
How to Configure Static NAT in GNS3

Add a Comment

Your email address will not be published. Required fields are marked *

shares
error: