🛰️ OSPF (Open Shortest Path First)

 

🛰️ OSPF (Open Shortest Path First)


🧠 Top 5 Key Points about OSPF

  1. Link-State Protocol → OSPF shares detailed information about network topology (not just hop count).

  2. Metric: Uses cost, calculated based on bandwidth (higher bandwidth = lower cost).

  3. Fast Convergence: Quickly detects and adapts to network changes.

  4. Supports VLSM & CIDR: Fully classless, allowing subnet flexibility.

  5. Area-Based Design: Supports hierarchical networks (Area 0 = Backbone, others connect to it).


⚙️ Additional Notes

  • Works at Layer 3 (Network Layer) of the OSI model.

  • Uses Dijkstra’s SPF (Shortest Path First) algorithm.

  • Multicast addresses:

    • 224.0.0.5 → All OSPF routers

    • 224.0.0.6 → Designated Router (DR) and Backup DR


OSPF uses Link-State Advertisements (LSAs) to exchange topology information. Each LSA type has a specific purpose.

Here's a practical explanation of LSA Types 1–7.


1. Type 1 – Router LSA

Generated by: Every OSPF router

Flooded within: Its own area only

Purpose: Describes the router's own links and interfaces.

For example:

Area 0

R1 ----- R2 ----- R3

R1 creates a Type 1 LSA saying:

  • I am Router R1
  • I have a link to R2
  • Cost = 10

R2 and R3 create their own Type 1 LSAs.

Think of it as:

"This is who I am and these are my neighbors."


2. Type 2 – Network LSA

Generated by: DR (Designated Router)

Flooded within: Its own area

Purpose: Lists all routers connected to a broadcast or NBMA network.

Example:

        Switch
/ | \
R1 R2 R3

Suppose R2 is the DR.

R2 generates a Type 2 LSA containing:

Network
├── R1
├── R2
└── R3

Instead of every router describing the shared network, the DR does it once.


3. Type 3 – Summary LSA

Generated by: Area Border Router (ABR)

Flooded to: Other areas

Purpose: Advertises networks from one area into another.

Example:

Area 0          Area 1

R1 ---- ABR ---- R2

Area 1 has:

192.168.10.0/24

The ABR sends a Type 3 LSA into Area 0 saying:

Network:
192.168.10.0/24

Think of it as:

"Here are the networks from another area."


4. Type 4 – ASBR Summary LSA

Generated by: ABR

Purpose: Tells routers where the ASBR is.

Example:

Internet
|
ASBR
|
Area 1
|
ABR
|
Area 0

The ABR tells Area 0:

The ASBR is reachable here.

Without this, routers wouldn't know how to reach the ASBR that injected external routes.


5. Type 5 – External LSA

Generated by: Autonomous System Boundary Router (ASBR)

Flooded: Throughout the OSPF domain (except stub areas)

Purpose: Advertises routes learned from outside OSPF.

Example:

Internet
|
ASBR

The ASBR injects:

0.0.0.0/0

or

8.8.8.0/24

Every router learns these as external routes.

Think of it as:

"This network is outside OSPF."


6. Type 6 – Group Membership LSA

Purpose: Used by the multicast extension to OSPF (MOSPF).

Today it is rarely used because MOSPF has largely been replaced by other multicast routing protocols.

For most CCNA/CCNP labs, you can simply remember:

Type 6 = Multicast (MOSPF)


7. Type 7 – NSSA External LSA

Generated by: ASBR inside an NSSA (Not-So-Stubby Area)

Purpose: Advertises external routes within an NSSA.

Example:

Internet
|
ASBR
|
NSSA Area
|
ABR
|
Area 0

The ASBR creates a Type 7 LSA inside the NSSA.

When the Type 7 reaches the ABR, the ABR converts it into a Type 5 LSA before advertising it to the rest of the OSPF domain.


Summary Table

LSA TypeNameGenerated ByPurpose
1Router LSAEvery routerDescribes the router and its links
2Network LSADRDescribes a multi-access network and its attached routers
3Summary LSAABRAdvertises networks between areas
4ASBR Summary LSAABRAdvertises the location of an ASBR
5External LSAASBRAdvertises routes from outside OSPF
6Group Membership LSAMOSPFSupports multicast (rarely used)
7NSSA External LSAASBR in NSSACarries external routes inside an NSSA; converted to Type 5 by the ABR

Easy way to remember

  • Type 1 → "I am this router."
  • Type 2 → "These routers share this LAN."
  • Type 3 → "These networks are in another area."
  • Type 4 → "This is where the ASBR is."
  • Type 5 → "These routes came from outside OSPF."
  • Type 6 → "Multicast information (MOSPF)."
  • Type 7 → "External routes inside an NSSA."

Compare OSPF route codes

Route CodeMeaning
OIntra-area route (same OSPF area)
O IAInter-area route (different OSPF area)
O E1External Type 1 route
O E2External Type 2 route
O N1NSSA External Type 1 route
O N2NSSA External Type 2 route

🧰 OSPF Lab in Cisco Packet Tracer

🎯 Goal:

Configure OSPF routing between three routers so that all connected PCs can communicate.


🖥️ Network Topology

PC1 -- R1 -- R2 -- R3 -- PC2

IP Address Plan

DeviceInterfaceIP AddressNetwork
R1G0/0192.168.1.1192.168.1.0/24
S0/0/010.0.0.110.0.0.0/30
R2S0/0/010.0.0.210.0.0.0/30
S0/0/110.0.0.510.0.0.4/30
R3S0/0/110.0.0.610.0.0.4/30
G0/0192.168.2.1192.168.2.0/24
PC1NIC192.168.1.10192.168.1.0/24
PC2NIC192.168.2.10192.168.2.0/24

🪜 Step-by-Step Configuration

Step 1: Configure IP Addresses

🔹 Router R1

enable conf t interface g0/0 ip address 192.168.1.1 255.255.255.0 no shutdown exit interface s0/0/0 ip address 10.0.0.1 255.255.255.252 clock rate 64000 no shutdown exit

🔹 Router R2

enable conf t interface s0/0/0 ip address 10.0.0.2 255.255.255.252 no shutdown exit interface s0/0/1 ip address 10.0.0.5 255.255.255.252 clock rate 64000 no shutdown exit

🔹 Router R3

enable conf t interface s0/0/1 ip address 10.0.0.6 255.255.255.252 no shutdown exit interface g0/0 ip address 192.168.2.1 255.255.255.0 no shutdown exit

Step 2: Configure OSPF

We’ll use Process ID 1 and Area 0 (backbone area).

🔹 R1

router ospf 1 network 192.168.1.0 0.0.0.255 area 0 network 10.0.0.0 0.0.0.3 area 0

🔹 R2

router ospf 1 network 10.0.0.0 0.0.0.3 area 0 network 10.0.0.4 0.0.0.3 area 0

🔹 R3

router ospf 1 network 10.0.0.4 0.0.0.3 area 0 network 192.168.2.0 0.0.0.255 area 0

Step 3: Verify OSPF Configuration

Use the following commands to verify:

show ip ospf neighbor

➡ Shows OSPF neighbor relationships.

show ip route ospf

➡ Displays routes learned via OSPF (marked with “O”).

show ip protocols

➡ Confirms OSPF is active on interfaces.


Step 4: Test Connectivity

  • Go to PC1 → Command Prompt
    Type:

    ping 192.168.2.10

✅ If replies are successful, OSPF routing works!


🧠 What You Learned

ConceptDescription
OSPF TypeLink-State Protocol
AlgorithmDijkstra’s SPF
MetricCost (based on bandwidth)
Area 0Backbone area for OSPF domains
Neighbor DiscoveryFormed using Hello packets (224.0.0.5)

💬 Summary

“OSPF is smarter than RIP — it builds a map of the entire network and chooses the fastest route based on cost, not just hop count.”

Comments

Popular posts from this blog

🖧 VLAN (Virtual Local Area Network)

🌐 NAT (Network Address Translation)