CCNA LAB

What is OSPF Protocol? How does it work? OSPF Routing Protocol with Examples.


In this article I will explain all about OSPF that What is OSPF? and How to configure OSPF with Cisco routers? Also the working of routers with OSPF. So, OSPF stands for Open Shortest Path First. The OSPF protocol is an intra-domain routing protocol based on link state routing. Its domain is also an autonomous system. It has a value in the IP Header (8 bit protocol field). Special routers (autonomous system boundary routers) or backbone routers responsible to dissipate information about other AS into the current system. So, OSPF is a protocol that interconnects two different routers.  Let’s discuss some other features of OSPF – 
  • OSPF:- Open Shortest Path First

  • It sends packets through the shortest route to another router
  • In OSPF we can connect a lot of routers.
  • It uses a link-state routing(LSR) algorithm.
  • It is an Interior Gateway Protocol (IGP) for the internet.
  • It uses the single Autonomous System as in an IP network and distributes IP routing information.
  • OSPF sends a hello message to another router every 10 seconds. If that second router does not reply to its message for 40 seconds, then that router down-ports its port.
  • OSPF does not allow traffic to increase on one of its routes. It sends the same message through two different routes, which does not increase much traffic on the same route.
  • In OSPF, we can also set a password, which can be connected only when the other router knows the password.

Let’s us understand the concept of OSPF routing with the help of a Network Topology that is given below —

Learn OSPF Routing at deepakacademy

OSPF Routing

Description of Topology –

In the above topology, I took 3 routers and each router has one switch directly connected with it and all switches are directly connected to 2 PCs on each switch. So in this topology, I connected  3  routers with serial DCE but the router to switch and switch to PCs are connected through Copper-Straight cable. Here I provided static IP addresses to all PCs. Now let’s learn the configuration of OSPF Routing Protocol.

First, we will assign the IP address to Routers interfaces –

Router 1 –

Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#interface FastEthernet0/0
Router(config-if)#ip address 1.0.0.1 255.0.0.0
Router(config-if)#no shut
Router(config-if)#exit
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

Router(config)#interface Serial0/0/0
Router(config-if)#ip address 2.0.0.1 255.0.0.0
Router(config-if)#no shut
Router(config-if)#exit
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to up

Give the command of OSPF on Router 1

Router(config)#router ospf 1
Router(config-router)#net 1.0.0.0 0.255.255.255 area 0
Router(config-router)#net 2.0.0.0 0.255.255.255 area 0
Router(config-router)#exit

Now, assign the IP address to Router 2 interfaces –

Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface Serial0/0/0 Router(config-if)#ip address 2.0.0.2 255.0.0.0 Router(config-if)#no shut Router(config-if)#exit %LINK-5-CHANGED: Interface Serial0/0/0, changed state to up Router(config)#interface Serial0/0/1 Router(config-if)#ip address 4.0.0.1 255.0.0.0 Router(config-if)#no shut
Router(config-if)#exit %LINK-5-CHANGED: Interface Serial0/0/1, changed state to down Router(config)#interface FastEthernet0/0 Router(config-if)#ip address 3.0.0.1 255.0.0.0 Router(config-if)#no shut Router(config-if)#exit %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

Give the command of OSPF on Router 2

Router(config)#router ospf 2
Router(config-router)#net 2.0.0.0 0.255.255.255 area 0
Router(config-router)#net 3.0.0.0 0.255.255.255 area 0
Router(config-router)#net 4.0.0.0 0.255.255.255 area 0

Now, assign the IP address to Router 3 interfaces –

Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#
Router(config)#interface Serial0/0/1
Router(config-if)#ip address 4.0.0.2 255.0.0.0
Router(config-if)#no shut
Router(config-if)#exit
%LINK-5-CHANGED: Interface Serial0/0/1, changed state to up

Router(config)#interface FastEthernet0/0
Router(config-if)#ip address 5.0.0.1 255.0.0.0
Router(config-if)#no shut
Router(config-if)#exit %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

Give the command of OSPF on Router 3

Router(config-if)#router ospf 3
Router(config-router)#net 4.0.0.0 0.255.255.255 area 0
Router(config-router)#net 5.0.0.0 0.255.255.255 area 0

Now check OSPF whether all the routers are working or not?

Router 1 Result

Router#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, 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 1.0.0.0/8 is directly connected, FastEthernet0/0
C 2.0.0.0/8 is directly connected, Serial0/0/0
O 3.0.0.0/8 [110/65] via 2.0.0.2, 00:01:56, Serial0/0/0
O 4.0.0.0/8 [110/128] via 2.0.0.2, 00:01:56, Serial0/0/0
O 5.0.0.0/8 [110/129] via 2.0.0.2, 00:01:01, Serial0/0/0

Router 2 Result

Router>show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, 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 1.0.0.0/8 [110/65] via 2.0.0.1, 00:03:25, Serial0/0/0
C 2.0.0.0/8 is directly connected, Serial0/0/0
C 3.0.0.0/8 is directly connected, FastEthernet0/0
C 4.0.0.0/8 is directly connected, Serial0/0/1
O 5.0.0.0/8 [110/65] via 4.0.0.2, 00:02:07, Serial0/0/1

Router 3 Result

Router#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, 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 1.0.0.0/8 [110/129] via 4.0.0.1, 00:02:39, Serial0/0/1
O 2.0.0.0/8 [110/128] via 4.0.0.1, 00:02:39, Serial0/0/1
O 3.0.0.0/8 [110/65] via 4.0.0.1, 00:02:39, Serial0/0/1
C 4.0.0.0/8 is directly connected, Serial0/0/1
C 5.0.0.0/8 is directly connected, FastEthernet0/0

In this way, we can configure OSPF protocol on the Cisco routers. So if you all liked the post, then share and like it more and more. If there are any problems, then you can tell in the comment. And also suggest if you have some other method.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s