In computer networking, when the size of the network increases and multiple routers are connected with each other, it becomes very important to use an efficient and fast routing protocol, and in such situations, OSPF is used because it is an advanced dynamic routing protocol that provides faster convergence, better path selection, and supports large networks using a structured design.
OSPF (Open Shortest Path First) is a link-state dynamic routing protocol in which routers exchange link-state information using LSAs and calculate the best path using Dijkstra’s Shortest Path First algorithm, which helps in achieving efficient and reliable routing in large networks.
OSPF works on a different concept compared to RIP and EIGRP, because instead of sharing complete routing tables, routers share only link-state information, and based on this information, every router builds a complete map of the network called Link-State Database, and then calculates the shortest path using the SPF algorithm, which makes routing faster and more efficient.
OSPF uses the concept of dividing a large network into smaller parts called areas, and each area is identified using an Area-ID, and this design helps in reducing network traffic and improving performance.
👉 Important:
👉 Area means:
A group of routers inside a network
Area 0 is the most important area in OSPF, and it is called the backbone area because it acts as the central communication point between all other areas, and it is mandatory in OSPF design.
👉 Important:
In large networks, multiple areas are used to reduce complexity, and this is known as multi-area OSPF, where each area reduces routing load and improves network performance.
👉 Rule:
All areas must connect to Area 0
ABR is a router that connects multiple areas, and it plays an important role in transferring routing information between different areas.
In OSPF, cost is a metric used to determine the best path, and it is calculated based on the bandwidth of the link, where lower cost represents a better and faster path.
👉 Cost means:
Value used to select the best path

👉 Lower cost = Better path
OSPF calculates cost for each link, and when a packet needs to be sent, it selects the path with the lowest total cost, which ensures efficient routing.
OSPF uses Process ID during configuration, and it is important to understand that this ID is only locally significant, which means it does not need to match on other routers.
In OSPF, every router is identified using a unique Router ID, which is a 32-bit value that looks like an IPv4 address, and it is used to uniquely identify routers in the network.
OSPF uses:
👉 Dijkstra’s Shortest Path First (SPF) Algorithm
This algorithm calculates the shortest path from the router to all other networks, which ensures optimal routing.
OSPF classifies routers based on their role in the network:
1️⃣ Internal Router : Router whose all interfaces belong to the same area
2️⃣ Backbone Router : Router having at least one interface in Area 0
3️⃣ Area Border Router (ABR) : Router that connects multiple areas
4️⃣ Autonomous System Boundary Router (ASBR) : Router that connects to an external network or different autonomous system
In OSPF, routers first build a neighbor relationship called adjacency, and once this adjacency is successfully formed, routers start exchanging link-state information using LSAs, which helps in building a complete network topology.
OSPF uses Link-State Advertisements (LSA) to exchange network information, and these LSAs are used to update the Link-State Database so that routers have an updated view of the network.
OSPF maintains different tables to store routing information:-
1️⃣ Neighbor Table : Stores information about current neighbors
2️⃣ Link-State Database (LSDB) : Stores complete network topology
3️⃣ Routing Table : Stores best paths (shortest path)
OSPF uses multicast IP addresses for communication:
OSPF uses wildcard mask in configuration, which is the inverse of subnet mask, and it helps in specifying which networks should participate in OSPF.
👉 Formula:
255.255.255.255 – Subnet Mask = Wildcard Mask
OSPF is a powerful and scalable routing protocol that is mainly used in large enterprise networks, and although it is more complex than RIP and EIGRP, it provides better performance, faster convergence, and efficient routing, which makes it one of the most important routing protocols in real-world networking.
👉 OSPF = Fast + Scalable + Area-Based Routing
👉 Best path = Calculated using SPF algorithm
After understanding the working of OSPF, its area concept, and cost metric, the next step is to configure OSPF on routers so that they can automatically exchange routing information and calculate the best path, and this configuration is done using Cisco IOS commands where we enable OSPF with a Process ID and specify the networks along with area information.
The basic syntax to configure OSPF is:
router ospf <process-id>
router-id <router-id>
network <network-address> <wildcard-mask> area <area-id>
log-adjacency-changes
router ospf 1
router-id 1.1.1.1
network 192.168.1.0 0.0.0.255 area 0
network 192.168.2.0 0.0.0.255 area 0
log-adjacency-changes
👉 Meaning:
Before configuring OSPF:
Router> enable
Router# configure terminal
Router(config)# router ospf 1
Router(config-router)# router-id 1.1.1.1
Router(config-router)# network 192.168.1.0 0.0.0.255 area 0
Router(config-router)# network 192.168.2.0 0.0.0.255 area 0
Router(config-router)# log-adjacency-changes
Router(config-router)# exit
Router(config)# end
Router# show ip route
👉 Check routing table
Router# show ip ospf neighbor
👉 Check neighbor relationship
Router# show ip protocols
👉 Check OSPF details
Router> enable
Router# configure terminal
Router(config)# router ospf 1
Router(config-router)# router-id 1.1.1.1
Router(config-router)# network 192.168.1.0 0.0.0.255 area 0
Router(config-router)# network 192.168.2.0 0.0.0.255 area 0
Router(config-router)# log-adjacency-changes
Router(config-router)# end
Router# show ip route
In this practical, we have implemented OSPF (Open Shortest Path First) in a four-LAN topology, where the network is divided into multiple areas to improve performance and scalability, and OSPF uses these areas along with cost-based routing to efficiently determine the best path between networks.
📌 Placement:
✔ Immediately after Introduction
👉 Routers used:
In this topology, OSPF uses a multi-area design, where Area 0 acts as the backbone area and connects other areas (Area 501 and Area 601), and routers form adjacency, exchange LSAs, build LSDB, and calculate shortest path using SPF algorithm, which ensures efficient communication between all LANs.
Router>ENABLE
Router#CONFIG T
Router(config)#HOSTNAME GATEWAY1
GATEWAY1(config)#INTERFACE FA0/0
GATEWAY1(config-if)#IP ADDRESS 192.168.100.4 255.255.255.0
GATEWAY1(config-if)#NO SHUTDOWN
GATEWAY1(config-if)#EXIT
GATEWAY1(config)#INTERFACE FA0/1
GATEWAY1(config-if)#IP ADDRESS 192.168.101.1 255.255.255.0
GATEWAY1(config-if)#NO SHUTDOWN
GATEWAY1(config-if)#EXIT
GATEWAY1(config)#ROUTER OSPF 1
GATEWAY1(config-router)#ROUTER-ID 1.1.1.1
GATEWAY1(config-router)#NETWORK 192.168.100.0 0.0.0.255 AREA 501
GATEWAY1(config-router)#NETWORK 192.168.101.0 0.0.0.255 AREA 0
GATEWAY1(config-router)#LOG-ADJACENCY-CHANGES
GATEWAY1(config-router)#EXIT
GATEWAY1(config)#EXIT
Router>ENABLE
Router#CONFIG T
Router(config)#HOSTNAME ROUTER1
ROUTER1(config)#INTERFACE FA0/0
ROUTER1(config-if)#IP ADDRESS 192.168.101.2 255.255.255.0
ROUTER1(config-if)#NO SHUTDOWN
ROUTER1(config-if)#EXIT
ROUTER1(config)#INTERFACE FA0/1
ROUTER1(config-if)#IP ADDRESS 192.168.102.1 255.255.255.0
ROUTER1(config-if)#NO SHUTDOWN
ROUTER1(config-if)#EXIT
ROUTER1(config)#ROUTER OSPF 1
ROUTER1(config-router)#ROUTER-ID 2.2.2.2
ROUTER1(config-router)#NETWORK 192.168.101.0 0.0.0.255 AREA 0
ROUTER1(config-router)#NETWORK 192.168.102.0 0.0.0.255 AREA 0
ROUTER1(config-router)#LOG-ADJACENCY-CHANGES
ROUTER1(config-router)#EXIT
ROUTER1(config)#EXIT
Router>ENABLE
Router#CONFIG T
Router(config)#HOSTNAME GATEWAY2
GATEWAY2(config)#INTERFACE FA0/0
GATEWAY2(config-if)#IP ADDRESS 192.168.103.1 255.255.255.0
GATEWAY2(config-if)#NO SHUTDOWN
GATEWAY2(config-if)#EXIT
GATEWAY2(config)#INTERFACE FA0/1
GATEWAY2(config-if)#IP ADDRESS 192.168.102.2 255.255.255.0
GATEWAY2(config-if)#NO SHUTDOWN
GATEWAY2(config-if)#EXIT
GATEWAY2(config)#ROUTER OSPF 1
GATEWAY2(config-router)#ROUTER-ID 3.3.3.3
GATEWAY2(config-router)#NETWORK 192.168.102.0 0.0.0.255 AREA 0
GATEWAY2(config-router)#NETWORK 192.168.103.0 0.0.0.255 AREA 601
GATEWAY2(config-router)#LOG-ADJACENCY-CHANGES
GATEWAY2(config-router)#EXIT
GATEWAY2(config)#EXIT
In this topology, connectivity is tested by sending a ping request from PC1 (LAN 1) to Server1 (LAN 4), and successful replies are received without any packet loss, which confirms that all routers are correctly exchanging routing information and all networks are reachable through OSPF.
The routing table is verified using the show ip route command, where routes learned through OSPF are marked with the letter O, and directly connected networks are marked with C, which confirms that OSPF is successfully learning and sharing routes between different areas.

OSPF neighbor relationship is verified using the show ip ospf neighbor command, where routers display their adjacent neighbors and the state of the relationship, and the state should be FULL, which confirms that adjacency is successfully established.

👉 OSPF = Multi-area + Cost-based + Fast Routing
In this four-LAN topology, OSPF is configured using a multi-area design where Area 0 connects other areas, and routers exchange LSAs, build LSDB, and calculate shortest path using SPF algorithm, which ensures efficient, scalable, and reliable communication across the network.