GuideRoutingOSPF

OSPF: Neighbors, LSDB, SPF, Cost, and Areas

Learn OSPF from the ground up: link-state operation, Hello packets and adjacencies, LSAs and the LSDB, SPF, cost, DR/BDR, Area 0, OSPFv2/OSPFv3, convergence, and troubleshooting.

Routing overviewReview static routes

What OSPF is

OSPF (Open Shortest Path First) is a link-state interior gateway protocol designed to operate inside an autonomous system. OSPFv2 is defined for IPv4, while OSPFv3 introduced support for IPv6 and later extensions added further capabilities.

Instead of configuring every route manually, OSPF routers exchange topology information, build a link-state database, and calculate paths with a shortest-path-first algorithm.

SPF and OSPF cost

OSPF builds a shortest-path tree using the SPF algorithm associated with Dijkstra. Path preference is based on OSPF cost. The exact way an implementation derives an interface cost may depend on reference bandwidth and configuration, but the protocol concept is to add interface costs along a path.

When several equal-cost paths exist, OSPF can produce routes that the forwarding plane installs for ECMP.

Router ID

Every OSPF router uses a 32-bit Router ID as an identifier inside the routing domain. Its notation resembles an IPv4 address, but its role is identification and it should not automatically be interpreted as a reachable IP address.

A stable, unique Router ID makes operation and troubleshooting easier. Unexpected Router ID changes can affect adjacencies, LSDB state, and how the router is represented to its peers.

Hello packets, neighbors, and adjacencies

Routers discover and maintain neighbors using Hello packets. To form a valid relationship they must agree on key link and area parameters. They then exchange database descriptions, request missing information, and synchronize link-state data.

Not every neighbor relationship is identical on every network type. Ethernet broadcast segments introduce the DR/BDR concept to limit the number of full adjacencies that would otherwise be required.

DR and BDR on multiaccess networks

On broadcast networks with several OSPF routers, the protocol can elect a Designated Router (DR) and a Backup Designated Router (BDR). This reduces adjacency overhead and organizes link-state exchange on the segment.

The DR is not the default gateway of user hosts. DR/BDR is an OSPF control-plane role, while a default gateway is a data-plane function for hosts.

Areas and the Area 0 backbone

OSPF can divide a routing domain into areas. Each area maintains its own topology detail and limits how much link-state information must be processed throughout the entire organization. The classic OSPF design uses Area 0 as the backbone connecting other areas.

A router with interfaces in multiple areas can operate as an Area Border Router (ABR). Areas can improve scale and fault containment, but creating unnecessary areas also increases operational complexity.

LSAs and the LSDB without memorizing everything at once

At the fundamentals level, the important workflow is simple: routers originate link-state information, flood it within the appropriate scope, maintain an LSDB, and recalculate SPF when relevant topology changes occur.

Later, advanced troubleshooting benefits from understanding specific LSA types, intra-area versus inter-area information, and external routes. You do not need to memorize every LSA before you understand the protocol itself.

OSPFv2 and OSPFv3

OSPFv2 is traditionally associated with IPv4. OSPFv3 adapts the protocol to IPv6 while retaining core concepts such as flooding, DR election, adjacency formation, and SPF calculation. Address handling and per-link behavior differ from OSPFv2.

OSPFv3 commonly uses IPv6 link-local addresses for neighbor communication. Review IPv6 first if link-local scope is not yet familiar.

Learn single-area OSPF before multi-area design

A single-area network is enough to learn neighbors, LSDB behavior, SPF, cost, and convergence. Multi-area OSPF becomes valuable when hierarchy solves a real scale, containment, or design problem.

Do not add areas merely because the protocol supports them. The architecture should answer a network requirement.

Default routes and redistribution

OSPF can advertise a default route and can also import routes from other sources through redistribution, depending on platform and policy. Both features deserve care. Uncontrolled redistribution can introduce unexpected paths, route feedback, or loops.

Prefer clear boundaries, explicit policy, and summarization when the addressing design supports it.

OSPF troubleshooting

When an OSPF route is missing, start below OSPF: interface state and IP addressing. Then check neighbors and adjacencies, Area ID, timers, network type, authentication, and other parameters that must be compatible. If neighbors are healthy, inspect the LSDB, prefix advertisement, and route selection.

  • Is IP connectivity working on the link?
  • Are Hello packets being exchanged?
  • Are both routers in the expected area?
  • Does the adjacency reach the correct state?
  • Is the destination prefix actually being advertised?
  • Is another route source winning selection?

Authentication and control-plane protection

Routing exchanges are control-plane traffic and should be protected from unauthorized neighbors. OSPFv2 supports authentication mechanisms, while OSPFv3 evolved its security model alongside IPv6 and later extensions.

Exact commands and recommended cryptographic options depend on the network operating system, so production configuration should follow current vendor documentation rather than old memorized examples.

Convergence after a topology change

When a link changes state, OSPF distributes updated topology information and routers recalculate SPF as required. Convergence is the process by which the domain reaches a consistent view again and installs updated forwarding routes.

Convergence speed depends on more than the algorithm itself. Failure detection, timers, LSDB size, link stability, and CPU resources all contribute. Aggressive timers can create instability if the underlying network is noisy.

Passive interfaces

Many implementations allow a connected network to be advertised into OSPF without trying to form OSPF neighbors on that interface. This is commonly implemented as a passive interface feature and is useful on user-facing LANs where no routing neighbor should exist.

The principle is broader than one vendor command: exchange a routing protocol only on links where a routing relationship is intentionally expected.

What to study after OSPF

Return to the routing table to see how OSPF routes appear and compare them with static routes. Then study route summarization before moving to policy-oriented interdomain routing with BGP.