🖧 OSPF (Open Shortest Path First)

 

🌐 Introduction

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.

 

📖 Definition

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.

 

🧠 Basic Information

  • OSPF → Open Shortest Path First 
  • It is a link-state routing protocol 
  • It is used in medium to large networks 
  • It provides fast convergence 

 

🔍 Concept Explanation

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.

 

📌 Area Concept in OSPF

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.

  • Each area has a unique Area-ID 
  • Area 0 is called Backbone Area (Main Area) 

👉 Important:

  • All other areas must be connected to Area 0 
  • This ensures proper communication between all networks 

 

🧠 Simple Meaning

👉 Area means:
A group of routers inside a network

 

📡 Area Identification

  • Each area is identified using an Area-ID 
  • Area-ID can be in: 
    • Decimal format (0, 1, 2) 
    • IP format (0.0.0.0, etc.) 

 

⭐ Backbone Area (Area 0)

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:

  • Area 0 is required 
  • It is the main area 
  • All other areas must connect to Area 0 

 

🔄 Multi-Area Design

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

 

🔗 Area Border Router (ABR)

ABR is a router that connects multiple areas, and it plays an important role in transferring routing information between different areas.

 

📊 Cost Metric in OSPF

 

📖 Definition

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.

 

🧠 Simple Meaning

👉 Cost means:
Value used to select the best path

 

📌 Cost Formula :

 

📊 Example

  • High bandwidth → Low cost 
  • Low bandwidth → High cost 

👉 Lower cost = Better path

 

🔍 Working of Cost

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.

 

📈 Path Selection

  • OSPF selects lowest cost path 
  • Supports equal-cost load balancing

 

📡 Process ID (PID)

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.

  • Range: 1 – 65535 
  • It is locally significant 

 

🆔 Router ID (RID)

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.

  • 32-bit value 
  • Looks like IP address (but not actual IP) 
  • Example: 192.168.100.1 

 

📊 Algorithm Used

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.

 

📡 Types of OSPF Routers

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

 

🔄 Neighbor Relationship (Adjacency)

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.

 

📢 LSA (Link-State Advertisement)

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 Database & Tables :

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 Communication

OSPF uses multicast IP addresses for communication:

  • 224.0.0.5 → All OSPF routers 
  • 224.0.0.6 → Designated Router (DR) and Backup DR 

 

📏 Wildcard Mask in OSPF

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

 

Default Wildcard Masks

  • Class A → 0.255.255.255 
  • Class B → 0.0.255.255 
  • Class C → 0.0.0.255 

 

✨ Key Features of OSPF

  • Link-state routing protocol 
  • Uses SPF algorithm 
  • Supports area-based design 
  • Faster convergence 
  • Efficient routing updates 
  • Uses LSDB and LSA 

 

✅ Advantages of OSPF

  • It provides faster convergence compared to RIP 
  • It supports large and complex networks 
  • It reduces unnecessary traffic by sending only updates 
  • It provides better and accurate path selection 
  • It supports hierarchical network design using areas 

 

❌ Disadvantages of OSPF

  • It is more complex to configure and understand 
  • It requires more CPU and memory 
  • Proper planning of areas is required 
  • Not suitable for very small networks 

 

⚠️ Important Understanding

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.

 

🎯 Key Idea

👉 OSPF = Fast + Scalable + Area-Based Routing
👉 Best path = Calculated using SPF algorithm


 

🌐OSPF Configuration Syntax & Steps

 

📖 Introduction

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.

 

📌 OSPF Configuration Syntax

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

 

🔍 Explanation of Syntax

  • router ospf <process-id> → Enables OSPF routing protocol 
  • router-id <router-id> → Assigns unique Router ID (optional but recommended) 
  • network <network-address> <wildcard-mask> area <area-id> → Specifies networks and assigns them to an area 
  • log-adjacency-changes → Logs neighbor relationship changes 

 

⚠️ Important Points

  • Process ID is locally significant 
  • Router ID must be unique 
  • Wildcard mask is mandatory in OSPF 
  • All routers must be in same area for basic configuration 
  • Interfaces must be active (no shutdown) 

 

📊 Example

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:

  • OSPF enabled with Process ID 1 
  • Router ID set to 1.1.1.1 
  • Networks added to Area 0 

 

📌 Steps to Configure OSPF

🧠 Concept

Before configuring OSPF:

  • Assign IP addresses to all interfaces 
  • Ensure interfaces are up 
  • Identify network addresses and area 

 

🔧 Step-by-Step Configuration :-

 

1️⃣ Enter Privileged Mode

Router> enable

 

2️⃣ Enter Global Configuration Mode

Router# configure terminal

 

3️⃣ Enable OSPF with Process ID

Router(config)# router ospf 1

 

4️⃣ Configure Router ID (Optional but Recommended)

Router(config-router)# router-id 1.1.1.1

 

5️⃣ Add Networks with Area

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

 

6️⃣ Enable Logging

Router(config-router)# log-adjacency-changes

 

7️⃣ Exit Configuration Mode

Router(config-router)# exit
Router(config)# end

 

8️⃣ Verify Configuration

Router# show ip route

👉 Check routing table

Router# show ip ospf neighbor

👉 Check neighbor relationship

Router# show ip protocols

👉 Check OSPF details

 

📊 Complete Example

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

 

✨ Key Features of OSPF Configuration

  • Uses Process ID 
  • Uses wildcard mask 
  • Supports area-based configuration 
  • Forms adjacency automatically 
  • Efficient routing updates 

 

⚠️ Important Notes

  • Use correct wildcard mask 
  • Router ID should be unique 
  • Same area required for basic setup 
  • Configure OSPF on all routers 

 

 

🖧 OSPF Configuration in a Four-LAN Multi-Area Network

 

🌐 Introduction

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.

 

🖼️ Network Topology

 

📌 Placement:
Immediately after Introduction

 

📡 Network Details

  • LAN 1 → 192.168.100.0/24 → Area 501 
  • LAN 2 → 192.168.101.0/24 → Area 0 
  • LAN 3 → 192.168.102.0/24 → Area 0 
  • LAN 4 → 192.168.103.0/24 → Area 601 

👉 Routers used:

  • GATEWAY1 (ABR) 
  • ROUTER1 (Backbone Router) 
  • GATEWAY2 (ABR) 

 

🧠 Working Concept

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 Configurations :-

 

🔹 GATEWAY1 CONFIGURATION (ABR)

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

 

🔹 ROUTER1 CONFIGURATION (Backbone Router)

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

 

🔹 GATEWAY2 CONFIGURATION (ABR)

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

 

📡 Connectivity Test

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.

 

 

📊 Routing Table Verification

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 Verification

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.

 

🎯 Key Understanding

  • OSPF uses Area 0 as backbone 
  • ABR connects different areas 
  • Routers exchange LSAs 
  • Best path selected using cost 

 

⚠️ Important Points

  • Area 0 is mandatory 
  • Router ID must be unique 
  • Use correct wildcard mask 
  • All routers must run OSPF 

 

🎯 Key Idea

👉 OSPF = Multi-area + Cost-based + Fast Routing

 

🎯 Summary

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.