When a router loses a link, the rest of the network needs a way to learn that the path has changed. In a small network, an administrator can update static routes manually. In a larger routed environment, a dynamic routing protocol can exchange reachability information and help routers select another path. One of the most widely deployed protocols for this job is Open Shortest Path First (OSPF).
OSPF is a link-state Interior Gateway Protocol. It discovers neighboring routers, distributes link-state information, builds a shared topology database within an area and calculates routes using the Shortest Path First algorithm. This guide explains the process from Hello packets to route installation, with practical design and troubleshooting advice.
1. Why routers need a routing protocol
A router forwards packets between networks. To do that reliably, it needs a routing table that identifies reachable destinations and the next hop or outgoing interface to use. Small networks can use manually configured static routes, but larger routed environments change too often for every path to be maintained by hand. Links fail, new networks are added, capacity changes and providers redesign topology. Dynamic routing protocols allow routers to exchange reachability information and update their forwarding decisions as the network changes.
Open Shortest Path First (OSPF) is a dynamic Interior Gateway Protocol (IGP). It is designed to exchange routing information among routers within an autonomous routing domain. OSPF is a link-state protocol: participating routers describe their local links and the state of those links, distribute that information through controlled flooding, and independently calculate shortest paths from a shared view of the topology.
OSPF is not the protocol that carries ordinary user data. It helps routers build routes that are then used to forward IP packets. Understanding this separation is important. An OSPF neighbor relationship can be healthy while an application is unavailable for another reason, and a user packet can be forwarded without the router needing to inspect the OSPF database for every packet.
This guide explains OSPF concepts from the first Hello packet through route installation. It covers areas, link-state advertisements, designated routers, metrics, convergence, OSPFv2 and OSPFv3, plus a practical troubleshooting workflow.
2. What does link-state routing mean?
In a link-state routing system, each router learns about the routers and links in its routing area. It creates information describing its own local view, then advertises that information to other routers in the area. The collection of advertisements forms a link-state database (LSDB). Routers in the same area should converge on a consistent database for that area, subject to the protocol's synchronization and flooding rules.
Each router runs a shortest-path calculation using the LSDB, with itself as the root of the calculation. OSPF uses Dijkstra's Shortest Path First (SPF) algorithm. The result is a shortest-path tree that identifies preferred paths to destinations. A router then derives candidate routes and installs selected routes in its routing table, subject to route preference, policy and other routing sources.
This differs from a distance-vector approach, in which routers primarily exchange destination reachability and distance information with neighbours rather than maintaining a topology database. Link-state protocols can make topology changes visible across an area, but they require database synchronization, memory and processing to maintain that shared view.
OSPF does not mean every router has one identical global routing table. Routers in the same area share that area's LSDB, but each router calculates paths from its own position. Different areas have different detailed topology databases. Area border routers exchange summarized reachability between areas according to OSPF rules.
3. OSPF terminology: router ID, interface, area and cost
An OSPF router ID is a 32-bit identifier written in dotted-decimal format, resembling an IPv4 address. It identifies the router within the OSPF routing domain; it is not necessarily an address assigned to an active interface. A stable and unique router ID helps avoid confusing one router's advertisements with another's. Duplicate router IDs can cause serious adjacency and database problems.
An OSPF interface is a router interface on which the protocol is enabled and configured. OSPF settings can include the area, network type, cost, timers, authentication and other parameters. An interface belongs to one OSPF area. A router with interfaces in more than one area participates in each of those areas and is commonly an Area Border Router.
An OSPF area is a logical grouping of routers and networks. Areas limit the scope of detailed link-state flooding and help scale a routing domain. Area 0.0.0.0 is the backbone area. Inter-area routing is designed around the backbone, and non-backbone areas should connect to it through appropriate area border router design. Virtual links exist for specific topology-repair cases, but should not be treated as a substitute for a sound area architecture.
OSPF cost is a metric used to compare paths. Each interface has an outgoing cost, and the path cost is built from the costs of the links along the route. Lower total cost is preferred. Vendors commonly derive a default cost from interface bandwidth, but reference bandwidth and calculation rules can be configurable. If reference bandwidth is too low or inconsistent, modern high-speed links may receive indistinguishable costs. Plan and document cost policy instead of assuming defaults are appropriate.
4. How OSPF discovers neighbors with Hello packets
OSPF routers use Hello packets to discover and maintain relationships with neighboring routers on a shared network. A router sends Hellos periodically on OSPF-enabled interfaces. A Hello includes information such as the sender's router ID, area, network mask in relevant OSPFv2 contexts, Hello and Dead intervals, options, priority and known neighbors.
When two routers receive compatible Hello packets on the same network, they can recognize each other as neighbors. The Hello process also detects whether a neighbor is still reachable. If a router does not receive expected Hellos within the Dead interval, it declares the neighbor down and updates the topology information as required.
Hello and Dead interval settings must be compatible between neighbors on many network types. Other important compatibility factors include area ID, authentication, network type, options and, in relevant cases, subnet configuration. A mismatch can prevent neighbors from progressing beyond the initial state.
On common IPv4 broadcast and point-to-point networks, OSPFv2 uses multicast addresses for protocol communication. The AllSPFRouters address is 224.0.0.5, and AllDRouters is 224.0.0.6. OSPFv3 uses IPv6 link-local multicast addresses FF02::5 and FF02::6. OSPF packets are carried directly over IP rather than TCP or UDP; OSPFv2 uses IP protocol number 89.
5. Neighbor versus adjacency: why FULL matters
An OSPF neighbor is a router discovered through the Hello protocol. An adjacency is a more advanced relationship in which two routers synchronize link-state information. Not every neighbor on every network type must form a full adjacency with every other neighbor. OSPF controls which routers exchange full databases to reduce unnecessary duplication on shared multi-access networks.
During adjacency formation, routers progress through states. Common states include Down, Init, 2-Way, ExStart, Exchange, Loading and Full. The exact path depends on the network type and whether an adjacency is required. In the Down state, no recent Hello has been received. Init indicates a Hello was received, but the local router ID was not yet seen in the neighbor's Hello list. 2-Way means bidirectional Hello communication has been established.
On point-to-point links, routers normally proceed to form an adjacency. On broadcast networks, a router may remain in 2-Way with certain peers because full database exchange is organized through the Designated Router and Backup Designated Router. That can be normal. The goal is not for every neighbour pair to show FULL; the goal is for the required adjacencies to be FULL and the LSDB to synchronize correctly.
ExStart and Exchange involve negotiating database description exchange and comparing database summaries. Loading occurs when a router requests missing or newer link-state advertisements. Full indicates that the adjacency's databases have synchronized. If a neighbor is stuck in an intermediate state, examine compatibility, MTU, packet delivery, authentication, timers and database exchange rather than repeatedly restarting the process.
6. How OSPF synchronizes its link-state database
OSPF uses several packet types to discover neighbors and exchange topology information. Hello packets discover and maintain neighbor relationships. Database Description packets summarize the contents of a router's link-state database so that neighbors can compare what each knows. Link State Request packets ask for specific advertisements that are missing or need updating. Link State Update packets carry one or more Link State Advertisements. Link State Acknowledgment packets confirm receipt of LSAs.
The database exchange process avoids sending every advertisement blindly at the start. Routers first compare summaries, request the information they need and then receive updates. The protocol uses sequence numbers, age and checksums to distinguish newer information and detect corrupted advertisements. Reliable flooding and acknowledgments help routers in an area converge on consistent topology information.
An LSA describes a piece of the OSPF topology or reachability information. Different LSA types have different roles. Router-LSAs describe a router's links within an area. Network-LSAs are originated by a Designated Router for certain multi-access networks. Summary-LSAs describe inter-area destinations. AS-external LSAs describe routes redistributed from outside the OSPF domain, subject to the applicable OSPF version and area rules.
LSAs are not the same as routes in the IP routing table. They are topology and reachability building blocks in the LSDB. OSPF runs the SPF calculation over that database and derives routes. A router may know about an LSA but not install a corresponding route if another route source is preferred, the destination is unreachable under the calculation, or policy and route selection rules exclude it.
7. OSPF areas and the backbone
Areas divide an OSPF routing domain into logical regions. Detailed link-state information is normally flooded within its originating area, limiting the amount of topology information that every router must process. Inter-area reachability is advertised through area border routers, which connect multiple areas and exchange summary information.
Area 0.0.0.0 is the backbone. It provides the central structure for inter-area routing. A well-designed multi-area topology connects each non-backbone area to the backbone through an Area Border Router. If the physical design cannot provide a direct connection, OSPF virtual links may be used in specific circumstances, but they add complexity and are generally a sign to review the topology.
OSPF supports special area types that limit which external or summary information is accepted or advertised. Stub areas reduce the external routing information entering an area. Totally stubby behaviour is a vendor-specific extension in many deployments. Not-So-Stubby Areas (NSSA) allow certain external routes to be introduced while retaining restrictions on other external information. The exact LSA behaviour depends on the area type and implementation.
Area design should reflect operational boundaries, scale, summarization opportunities and failure domains. Too many small areas can add configuration and troubleshooting complexity. One very large area can increase flooding and SPF work. Summarization at area boundaries can reduce routing table size and hide internal topology details, but summarization must match the actual address plan and reachability requirements.
8. Designated Router and Backup Designated Router
On broadcast multi-access networks such as Ethernet, multiple OSPF routers may share the same Layer 2 segment. If every router formed a full adjacency with every other router, the number of relationships and repeated database exchange could grow quickly. OSPF elects a Designated Router (DR) and Backup Designated Router (BDR) on these network types to organize LSA exchange.
The DR represents the multi-access network in the OSPF topology and helps coordinate flooding. The BDR monitors the DR role and can take over if the DR fails. Other routers form full adjacencies with the DR and BDR rather than with every other router on the segment. The election is based on interface priority and router ID as a tie-breaker, subject to OSPF election rules.
DR and BDR election is per network segment, not a permanent global title for the entire router. A router can be DR on one Ethernet segment and a DROther on another. A priority of zero makes an interface ineligible to become DR or BDR. Election behaviour is not necessarily preemptive: a newly arriving router with a higher priority does not automatically displace an already elected DR in a stable segment.
Point-to-point networks do not need a DR or BDR because only two routers share the link. When troubleshooting, first identify the OSPF network type. Seeing a DR/BDR election on a broadcast segment is normal; expecting one on a point-to-point interface is not.
9. How OSPF selects the best route
OSPF builds a shortest-path tree using the LSDB and the SPF algorithm. The calculation starts at the local router and evaluates the cumulative cost to reach other routers and networks. The route with the lowest total OSPF cost is generally preferred within the relevant route-selection context.
Interface costs are added along a path. If Router A reaches Router C through Router B, the total cost includes the outgoing interface costs on the path. OSPF cost is not inherently a measurement of live congestion or instantaneous latency. It is an administratively configured or derived metric. A low-cost route can still be congested, and a high-cost route can have more physical bandwidth if the metric policy does not reflect it.
When multiple paths have equal cost, OSPF can install equal-cost routes, allowing traffic to be distributed across next hops according to the router's forwarding implementation. Equal-cost multipath can improve utilization and resilience, but the distribution method may be per-flow or based on other platform-specific hashing. It does not guarantee that every individual packet uses a different path.
OSPF route selection also interacts with other routing sources. Routers compare administrative distance or route preference between protocols according to vendor rules, and BGP, static routes and connected routes may be preferred over an OSPF candidate. OSPF's internal route types—such as intra-area, inter-area and external—also have defined preference relationships. Check the actual routing table rather than assuming that the lowest OSPF metric always wins globally.
10. OSPF convergence and what happens after a link failure
Convergence is the process by which routers detect a topology change, distribute updated information, recalculate paths and install new routes. When an OSPF-enabled interface goes down, the router updates its local link-state information and originates an updated LSA. The change is flooded to other routers in the relevant area. Those routers update their LSDB and run SPF as needed.
Convergence time depends on failure detection, protocol timers, flooding, database processing, SPF scheduling, hardware and topology. A directly detected interface failure can be noticed quickly. A silent failure may take longer if the routers must wait for a Dead interval or another detection mechanism. Bidirectional Forwarding Detection (BFD) can provide faster failure detection on supported platforms, but it is a separate mechanism that can be integrated with OSPF.
Fast convergence is not always the same as stable convergence. Very aggressive timers can increase control-plane load and cause false neighbour failures when a router is busy or a link is experiencing transient delay. SPF throttling, LSA pacing and sensible timer policy help balance responsiveness and stability.
After a topology change, the route selected by OSPF may differ from the previous route. Applications can see brief packet loss or reordered traffic while forwarding tables update. A redundant path helps only if it is physically and logically independent and the routing design can use it. Two links that share the same conduit, power source or upstream device may fail together.
11. OSPFv2 versus OSPFv3
OSPFv2 is commonly used for IPv4 routing and is specified in IETF RFC 2328. OSPFv3 was originally specified for IPv6 in RFC 5340 and has since been updated by later standards. OSPFv3 changes packet and LSA formats and uses IPv6 link-local addressing for neighbour communication. It is not simply OSPFv2 with a different address written in the configuration.
OSPFv2 uses IPv4 protocol number 89 and IPv4 multicast addresses for protocol communication. OSPFv3 uses IPv6 next-header value 89 and link-local multicast addresses. OSPFv3 has a different approach to carrying addressing information in LSAs, and its architecture supports address-family extensions so implementations can support more than one network-layer protocol family.
OSPFv3 neighbours are formed on links and use IPv6 link-local addresses for adjacency communication. The protocol's Router ID remains a 32-bit identifier even though the data plane may be IPv6. This is another reason not to assume that the Router ID is an interface IPv6 address.
Operationally, verify which OSPF version and address family are enabled on each interface. A network can run OSPFv2 for IPv4 and OSPFv3 for IPv6 at the same time. Authentication mechanisms, LSA formats and configuration commands differ across platforms and versions, so use vendor documentation for the exact implementation.
12. OSPF authentication and routing security
Routing protocols influence where traffic flows, so OSPF control-plane messages must be protected against unauthorized participation and manipulation. An attacker who can inject valid-looking routing information or disrupt neighbour relationships may cause traffic blackholing, interception or instability.
OSPF implementations support authentication mechanisms, but the options differ by protocol version and platform. Legacy simple or cryptographic authentication methods may be available in some environments; modern deployments should use the strongest supported method and follow current vendor guidance. OSPFv3 can use IPsec-based protection in applicable deployments, and later extensions define additional security approaches.
Authentication should be configured consistently on the relevant interfaces and neighbours. A mismatch can prevent adjacency formation. Also restrict which interfaces run OSPF, filter or control route redistribution, protect router management access, and monitor unexpected neighbours or topology changes.
Do not treat authentication as a complete routing-security solution. It does not by itself validate every route's business purpose, prevent configuration mistakes or protect against a compromised authenticated router. Operational controls, change review, logging, segmentation and route policy remain essential.
13. OSPF troubleshooting: a step-by-step workflow
Start by checking the physical and Layer 2 path. Confirm that interfaces are up, the correct VLAN or routed segment is present, IP addressing is valid and both routers can exchange packets on the link. If the link is unstable, solve that problem before changing OSPF timers.
Check the OSPF process and interface participation. Verify the expected router ID, area ID, network type, interface cost and whether OSPF is enabled on the correct interface. A network statement or interface-level command may not match the intended address, depending on the vendor's configuration model.
Inspect neighbour state and Hello parameters. Confirm that Hello and Dead intervals, authentication, area, network type and relevant options match. On broadcast links, understand the DR/BDR role and whether a 2-Way state is expected for that neighbour relationship.
If a neighbour is stuck in ExStart or Exchange, check MTU compatibility and database-description exchange. Cisco's troubleshooting guidance identifies MTU mismatch, duplicate router IDs, timer mismatch, network-type mismatch, area-type mismatch and missing OSPF configuration among common causes. Avoid bypassing MTU checks as a first response; fix the underlying link or interface configuration.
If neighbours are FULL but routes are missing, inspect the LSDB, LSA types, area boundaries, summarization, route filtering, redistribution, route preference and next-hop reachability. Verify whether the route exists in the routing table and whether another protocol has installed a preferred route. For packet-level reachability checks beyond OSPF itself, see the ICMP, ping and traceroute diagnostics guide.
Use platform commands such as show ip ospf neighbor, show ip ospf interface, show ip ospf database and show ip route on Cisco-style systems, or the equivalent commands on the router operating system. Collect outputs from both sides of the adjacency and compare timestamps. Avoid clearing the entire OSPF process on a production router unless the impact is understood and the change is approved.
14. Common OSPF design mistakes
Using duplicate or unstable router IDs can make the control plane unpredictable. Define a stable router ID for every router and keep an inventory. Avoid changing it casually after deployment because a change can trigger protocol events and require adjacency re-establishment.
Building areas without a clear backbone plan can create reachability and maintenance problems. Keep area design understandable, connect non-backbone areas to Area 0 in a supported way and document any virtual links. Do not create area boundaries solely to make a diagram look tidy.
Leaving default interface costs without checking reference bandwidth can cause high-speed links to appear equal when the design intended to distinguish them. Set a consistent metric policy across the routing domain and test the impact before changing costs.
Redistributing routes from other protocols without filtering can inject excessive or unintended reachability into OSPF. Use route maps or equivalent policy, tag redistributed routes where appropriate and avoid uncontrolled mutual redistribution that can create feedback loops.
Overly aggressive timers and indiscriminate debugging can burden routers. Monitor CPU and memory, use targeted debugging in a controlled window and prefer counters, logs and packet captures before enabling high-volume diagnostics on production devices.
15. OSPF compared with static routing, RIP and IS-IS
Static routing is simple and predictable for small or stable networks, but every topology change requires manual action unless another automation system updates routes. OSPF is dynamic and can react to link-state changes, but introduces a routing protocol that must be designed, secured and maintained.
RIP is a distance-vector IGP with a hop-count metric and relatively simple operation. Its design limits make it less suitable for many larger modern enterprise networks. OSPF uses a link-state database and cost-based SPF calculation, allowing more flexible hierarchical design and faster, more informed topology changes in many deployments.
IS-IS is another link-state IGP widely used in service-provider and large network environments. It has different protocol architecture and operational conventions, but also uses link-state information and SPF calculations. Choosing OSPF or IS-IS depends on platform support, operational expertise, network scale, design requirements and interoperability needs.
BGP serves a different primary role: it exchanges reachability between autonomous systems and supports extensive routing policy. OSPF is typically used inside an enterprise or provider routing domain, while BGP is commonly used at internet and inter-domain boundaries. Some networks use both, with careful redistribution and route-policy design.
16. When OSPF is useful—and when it may not be
OSPF is useful in enterprise campus networks, data centres, large routed LANs, service-provider internal networks and multi-site environments where routers need dynamic IPv4 or IPv6 route exchange. Its area hierarchy, equal-cost routing and broad vendor support make it a common IGP choice.
A very small network with a handful of stable routes may be easier to operate with static routing. A network that already uses another IGP consistently may not benefit from introducing OSPF without a specific migration or interoperability reason. Routing protocols add control-plane complexity and should solve a real operational need.
Before deployment, document the topology, areas, router IDs, IP plan, interface costs, authentication, summarization and redistribution policy. Build a lab that includes link failure, neighbour loss, route changes and recovery. Confirm monitoring and backup configuration before introducing the protocol into a production network.
17. Key takeaways for network operators
OSPF is a link-state Interior Gateway Protocol. Routers discover neighbours with Hello packets, form required adjacencies, synchronize link-state databases, flood LSAs within the relevant scope and run SPF to calculate routes. Areas help control topology-information distribution, with Area 0 providing the backbone for inter-area routing.
Neighbour state is a useful diagnostic signal, but FULL is not required between every pair of routers on every network type. DR and BDR elections reduce adjacency complexity on multi-access networks. Route cost is a configured metric, not a live measurement of congestion or latency.
OSPFv2 is commonly used for IPv4; OSPFv3 supports IPv6 and has a different packet and LSA architecture. Authentication, interface compatibility, MTU, router IDs and area design all matter. A healthy OSPF control plane supports forwarding, but it does not guarantee that an application or internet service is healthy.
For more network fundamentals, read the [subnetting and CIDR guide](/blog/ipv6-explained-internet-transition/) and explore the [Internet Technology & Updates category](/blog/category/internet-technology-updates/).
18. Frequently asked questions
What is OSPF in networking?
OSPF (Open Shortest Path First) is a link-state Interior Gateway Protocol that lets routers exchange topology information and calculate routes within an autonomous routing domain.
Is OSPF a distance-vector or link-state protocol?
OSPF is a link-state protocol. Routers distribute link-state advertisements, build a link-state database and run the SPF algorithm to calculate paths.
What is an OSPF area?
An OSPF area is a logical grouping that limits the scope of detailed link-state information. Area 0.0.0.0 is the backbone used for inter-area routing.
What does FULL mean in OSPF?
FULL means two routers have completed the required adjacency process and synchronized their link-state databases. Not every neighbour pair must reach FULL on a broadcast network.
What is the difference between an OSPF neighbor and an adjacency?
A neighbor is discovered through Hello packets. An adjacency is a relationship in which routers synchronize link-state information and exchange LSAs.
What are DR and BDR in OSPF?
The Designated Router and Backup Designated Router coordinate link-state exchange on supported multi-access networks, reducing the number of full adjacencies required.
What is an LSA in OSPF?
A Link State Advertisement describes topology or reachability information. Routers flood LSAs within their defined scope so the link-state database can be synchronized.
What is the OSPF metric?
OSPF uses cost as its metric. A path's total cost is derived from the outgoing interface costs along the path; lower cost is preferred.
What is the difference between OSPFv2 and OSPFv3?
OSPFv2 is commonly used for IPv4. OSPFv3 was designed for IPv6 and uses different packet and LSA formats and IPv6 link-local communication.
Why is my OSPF neighbor stuck in ExStart or Exchange?
Common causes include MTU mismatch, duplicate router IDs, network-type or timer mismatch, authentication problems and packet loss. Compare both routers' interface and neighbor details.
Standards and further reading
- IETF RFC 2328 — OSPF Version 2: the core OSPFv2 specification for IPv4 routing.
- IETF RFC 5340 — OSPF for IPv6: the OSPFv3 specification, with later updates and errata noted by the RFC Editor.
- IETF RFC 5709 — OSPF HMAC-SHA Cryptographic Authentication: cryptographic authentication extensions for OSPFv2.
- Cisco — Troubleshoot OSPF Neighbor Problems: practical causes and checks for neighbour state and adjacency issues.
- Cisco IOS XE — Configuring OSPF: vendor implementation and configuration reference.
OSPF behaviour is defined by IETF specifications, while exact configuration syntax, defaults and operational commands vary by router platform and software release. Always check the documentation for the device in use.
