OSPF
A link-state IGP: flood LSAs, run Dijkstra, install routes in the RIB.
Level: advanced
What is it?
Open Shortest Path First (OSPF) is a link-state interior gateway protocol. Routers exchange link-state advertisements within areas, build a topology database, and run a shortest-path calculation to choose routes based on configured costs.
Why does it matter?
OSPF adapts to internal topology changes without manually configuring every route. Its areas and summarization support scale, but adjacency, area, metric, and network-type mismatches can prevent neighbors from exchanging usable routes.
Mental model
Every router learns a common view of the area's topology, then computes its own shortest paths from that view. The resulting routing table is local even though the topology database is shared.
How it works
- OSPF uses neighbor relationships and link-state advertisements to distribute topology information.
- Routers run Dijkstra's shortest-path-first algorithm against the link-state database.
- Areas limit flooding scope and support hierarchical routing; Area 0 is the backbone in conventional multi-area designs.
- Interface costs influence path preference; equal-cost multipath may install several next hops where supported.
- Authentication, timers, MTU/network type, router IDs, and area settings must be compatible for adjacency.
Steps
- Interfaces send Hellos and discover eligible OSPF neighbors.
- Neighbors establish adjacencies and synchronize relevant link-state databases.
- Link-state changes are flooded and the router recomputes shortest paths.
- The router installs routes and forwards packets using its forwarding plane.
Real-world usage
- Routing inside enterprises, campuses, and provider networks.
- Diagnosing a route absent because an OSPF adjacency or area design is wrong.
Common mistakes
- Assuming OSPF is used between autonomous systems on the public internet; BGP typically serves that role.
- Confusing an OSPF database entry with an installed forwarding route.
- Changing costs without checking equal-cost paths and convergence impact.
Interview questions
What algorithm does OSPF use for route calculation?
It uses a shortest-path-first calculation based on the link-state topology and configured link costs.
Why use OSPF areas?
Areas constrain flooding and support hierarchical scale and summarization, while requiring an area design with a backbone connection in conventional multi-area OSPF.