Intermediate 7 min read Updated: 2026-08-25T07:20:17Z

OSPF Basics

Learn about OSPF Basics in this Networking tutorial.

Open Shortest Path First (OSPF) is one of the most widely used enterprise routing protocols in the world. It is an Interior Gateway Protocol (IGP), meaning it is used to route traffic inside an organization's network, rather than across the global internet (which is handled by BGP).

What is a Link-State Protocol?

OSPF is a link-state routing protocol. Unlike older protocols that simply count how many "hops" it takes to reach a destination, an OSPF router builds a complete mathematical map of the entire network.

Every router using OSPF originates a Link-State Advertisement (LSA) that lists all its connected interfaces, subnets, and the "Cost" (speed) of those links. These LSAs are flooded throughout the network. Every router collects these LSAs and builds an identical Link-State Database (LSDB). Finally, every router independently runs the Shortest Path First (SPF) algorithm (Dijkstra's algorithm) to calculate the absolute fastest, most efficient path to every destination.

OSPF Cost and Path Selection

OSPF calculates the "best" path based on Cost. The cost is derived from the bandwidth of the link. A 10 Gbps fiber optic link has a much lower cost than a 100 Mbps copper link.

Imagine Router 1 wants to reach Router 3. It has two physical paths:

  • Path A: Go directly to Router 3 over a 10 Mbps microwave link (High Cost).
  • Path B: Go through Router 2, then to Router 3 over dual 10 Gbps fiber links (Low Cost).

Even though Path A is physically shorter (fewer hops), OSPF will choose Path B because the total cumulative cost of the high-speed fiber links is much lower.

Neighbor Adjacencies

Before OSPF routers can exchange routing databases, they must discover each other and become "Neighbors." They do this by continuously multicasting Hello Packets out of their OSPF-enabled interfaces.

For two routers to form a neighbor adjacency, several parameters in their Hello packets must perfectly match:

  • Area ID: Both interfaces must be assigned to the same OSPF Area.
  • Subnet and Mask: The interfaces connecting them must be in the exact same IP subnet.
  • Hello and Dead Timers: They must agree on how frequently to send Hellos, and how long to wait before declaring a silent neighbor "dead."
  • Authentication: If a password is configured, it must match.
  • MTU: If the Maximum Transmission Unit doesn't match, they may become neighbors but fail to exchange their databases.

OSPF Areas and the Backbone

If an enterprise has 500 routers, running the SPF mathematical algorithm every time a link flaps would overwhelm the routers' CPUs. To solve this, OSPF uses a hierarchical design called Areas.

  • Area 0 (The Backbone): The core of the network. Every other area must connect directly to Area 0.
  • Non-Backbone Areas (e.g., Area 10, Area 20): Used for branch offices or specific building floors.

By dividing the network into Areas, an administrator can summarize routes. If a single link flaps inside Area 20, the routers in Area 20 recalculate their SPF algorithm, but the routers in Area 0 and Area 10 are shielded from the CPU spike.

Common OSPF Troubleshooting

When OSPF routes are missing from your Routing Table, follow this workflow:

  1. Is the interface UP? OSPF cannot run over a physically down port.
  2. Is OSPF enabled on the interface? Ensure the network statement or interface-level command correctly activates OSPF for that specific subnet.
  3. Is the Area correct? Ensure the interface is assigned to the correct Area, and that it matches the router on the other end of the cable.
  4. Are neighbors established? Check the OSPF neighbor table (e.g., show ip ospf neighbor). If the state is stuck in INIT, 2-WAY, or EXSTART, investigate MTU mismatches, timer mismatches, or firewall ACLs blocking Multicast 224.0.0.5.
  5. Is the interface Passive? A "Passive Interface" is a security best practice used on Access Ports facing end-users. It advertises the subnet into OSPF, but suppresses the transmission of Hello packets so users cannot form rogue adjacencies. Ensure you didn't accidentally make a router-to-router link passive.

Quick Summary

  • OSPF is a dynamic, link-state routing protocol used within enterprise networks.
  • It uses the SPF algorithm to find the lowest-cost (fastest bandwidth) path to destinations.
  • Routers must form perfect neighbor adjacencies before exchanging routes.
  • Networks are divided into hierarchical Areas (centered on Backbone Area 0) to scale efficiently.
Code copied to clipboard!