What is OSPF (Open Shortest Path First)?
Learn what OSPF is, how link-state advertisements and Dijkstra build routing tables, and why areas matter — with interview Q&A.
Expected Interview Answer
OSPF is a link-state interior gateway routing protocol that lets routers within a single autonomous system share their local link information with every other router so each one independently builds a complete topology map and computes the shortest path to every destination using Dijkstra’s algorithm.
Each OSPF router floods Link State Advertisements (LSAs) describing its directly connected links and their costs to all other routers in the same area, and every router stores these in an identical link-state database. From that shared database, each router runs Dijkstra’s shortest-path-first algorithm independently to build its own routing table, so there is no need to trust a neighbor’s computed distance the way distance-vector protocols do. OSPF organizes large networks into areas connected through a backbone (Area 0) to limit how far LSA floods travel and to keep the database size manageable. It also elects a Designated Router (DR) and Backup Designated Router (BDR) on multi-access segments like Ethernet to reduce the number of adjacencies formed, and it converges quickly after a topology change because only the changed LSA needs to be reflooded and recalculated.
- Fast convergence because only changed LSAs are reflooded and recomputed
- Loop-free routing since every router computes from the same topology map
- Areas limit flooding scope and keep large networks scalable
- Cost-based metric supports unequal-bandwidth path selection
AI Mentor Explanation
OSPF is like every fielder on the ground memorizing a complete, identical map of the pitch conditions, boundary distances, and wind direction at every position, rather than only trusting whatever the fielder next to them shouts. Because everyone builds their own understanding from the same shared map, each fielder can independently work out the fastest route to intercept a ball without waiting on a relay of guesses. When conditions change, like a wet patch appearing, only that patch of information is redistributed to everyone rather than resending the whole ground survey. This mirrors how OSPF routers keep an identical link-state database and independently compute shortest paths.
Step-by-Step Explanation
Step 1
Neighbor discovery
Routers running OSPF discover each other via Hello packets and form adjacencies on shared links.
Step 2
LSA flooding
Each router floods Link State Advertisements describing its links and costs to every router in the area.
Step 3
Shared database
All routers in an area converge on an identical link-state database built from received LSAs.
Step 4
SPF computation
Each router independently runs Dijkstra’s algorithm on the database to build its own shortest-path routing table.
What Interviewer Expects
- Correctly identifies OSPF as link-state, not distance-vector
- Explains LSA flooding and the shared link-state database
- Mentions Dijkstra’s SPF algorithm for path computation
- Understands areas, Area 0 backbone, and DR/BDR election
Common Mistakes
- Confusing OSPF with distance-vector protocols like RIP
- Not knowing every router in an area holds an identical database
- Forgetting that areas exist to limit flooding scope
- Thinking OSPF metric is hop count instead of cost (bandwidth-based)
Best Answer (HR Friendly)
“OSPF is a routing protocol where every router builds a complete map of the network from information shared by all its neighbors, then works out the fastest path to any destination on its own, rather than blindly trusting what a neighboring router reports. It is fast to recover from failures because only the changed piece of the map needs to be shared, and it is widely used inside large corporate and ISP networks.”
Code Example
# Enter the OSPF daemon shell
vtysh
# Show OSPF neighbor adjacencies
show ip ospf neighbor
# Show the link-state database
show ip ospf database
# Show the computed routing table entries learned via OSPF
show ip route ospfFollow-up Questions
- How does OSPF differ from BGP in scope and use case?
- What is the purpose of the Designated Router (DR) on a broadcast segment?
- How does OSPF calculate its cost metric?
- What happens during an OSPF area border router (ABR) summarization?
MCQ Practice
1. What type of routing protocol is OSPF?
OSPF is a link-state protocol where every router builds an identical topology database.
2. Which algorithm does OSPF use to compute shortest paths?
OSPF runs Dijkstra’s shortest-path-first algorithm over its link-state database.
3. What is the purpose of OSPF areas?
Areas bound how far link-state advertisements flood, keeping large networks scalable.
Flash Cards
What is OSPF? — A link-state interior gateway protocol where routers share LSAs and independently compute shortest paths.
OSPF path algorithm? — Dijkstra’s shortest-path-first (SPF) algorithm.
What is Area 0? — The mandatory OSPF backbone area that all other areas must connect to.
Why elect a DR? — To reduce the number of adjacencies formed on multi-access segments like Ethernet.