What Is OSPF?
OSPF, short for Open Shortest Path First, is the link-state routing protocol that routers rely on to pick the best path for traffic within one organization's network. It gets there by first giving each router a complete picture of the topology. Only then does the router work out, through a shortest-path calculation, which next hop a packet should take.
Take a business running three regional offices, with two WAN links between each pair of sites. If the main circuit linking two of them fails, the routers pick up on it in a matter of seconds. They recompute, and traffic moves onto the backup link without anyone editing a route manually.
OSPF belongs to the Interior Gateway Protocol (IGP) family. Its scope is one autonomous system: the set of networks a single organization controls and administers. Deployments range from enterprise campuses and data centers to service provider cores and WANs spanning many sites.
Because the protocol is an open standard, you can mix router vendors in the same OSPF domain. OSPFv2 is the IPv4 version, and for IPv6 you'd run OSPFv3.
How Does the OSPF Protocol Work?
The OSPF protocol works on a straightforward idea: routers describe their own links, every router ends up with the same database, and routing decisions come out of that database.
Neighbor discovery: It starts with neighbor discovery. Routers send Hello packets, small messages that announce their presence, out of each OSPF-enabled interface, and two routers that agree on settings such as area ID, timers and subnet become neighbors.
Database exchange: Next comes the database exchange, where neighbors trade Link State Advertisements (LSAs). Each LSA describes a router's interfaces along with the networks attached to them and their associated costs, and routers hold all of these in a Link State Database (LSDB), which is effectively the complete topology map.
Route calculation: With the LSDB in place, a router runs Dijkstra's algorithm (a shortest-path method) across it and builds a tree of lowest-cost paths, placing itself at the root.
Change handling: Suppose a link later changes state. The router connected to it floods a new LSA, and its neighbors update their copies and rerun the calculation only for the part of the tree that changed.
Path selection comes down to cost, a number tied to interface bandwidth. Lower cost wins. Administrators can tune it on specific links to steer traffic toward preferred routes.
Does OSPF Use TCP or UDP?
OSPF uses neither TCP nor UDP. It runs directly on top of IP as protocol number 89, so it works as a transport in its own right.
That leaves reliable delivery to OSPF itself. Every Link State Update needs an acknowledgment from each neighbor, and when one doesn't arrive in time, the router sends the update again. Each LSA also carries a sequence number, which is how a router tells a newer copy from an outdated one.
For most of its traffic, OSPF uses reserved multicast groups:
224.0.0.5 (FF02::5 in OSPFv3): reaches all OSPF routers sharing a segment.
224.0.0.6 (FF02::6 in OSPFv3): what routers use to reach the Designated Router and its backup.
Packets leave with a time-to-live (TTL) of 1. That hop limit stops them from being forwarded beyond the local link, which is why adjacencies only ever form between directly connected routers.
There's a practical side to this. Firewall rules and access control lists must permit IP protocol 89, since there's no port to open. If a filter drops it, neighbors never reach Full, and the problem can pass for a routing fault until someone checks the policy.
What Are OSPF Packet Types?
OSPF keeps adjacencies and databases in sync with five packet types:
Hello: discovers neighbors and confirms they're still alive.
Database Description (DBD): gives a summary of the contents of a router's LSDB.
Link State Request (LSR): where something is missing, the router issues one to its neighbor.
Link State Update (LSU): carries LSAs, whether they were requested or flooded after a change.
Link State Acknowledgment (LSAck): sent back by the receiving router to confirm the LSAs arrived.
What Are OSPF Neighbor States?
OSPF neighbor states track how far two routers have progressed toward a full adjacency. Getting there takes the pair through eight of them, in this order: Down, Attempt, Init, 2-Way, ExStart, Exchange, Loading, Full.
A pair stuck in ExStart or Exchange often points to an MTU mismatch between interfaces. When a neighbor keeps dropping back to Down, the usual suspects are a flapping link, mismatched timers or an authentication error. Full means both routers hold identical databases for the area.
What Are OSPF Areas and Router Types?
An OSPF area is a logical group of routers sharing one LSDB. Dividing a large network this way keeps flooding contained and shortest-path calculations fast. The backbone is Area 0, and every other area has to attach to it.
What role a router plays depends on where it sits:
Internal router: all of its interfaces are in one area.
Backbone router: one interface in Area 0 is enough.
Area Border Router (ABR): connects other areas to the backbone and summarizes routes between them.
Autonomous System Boundary Router (ASBR): brings in routes from outside OSPF, such as static routes or another routing protocol.
Stub areas and NSSAs (not-so-stubby areas) limit which external routes enter an area, which trims table size on smaller routers.
What Are LSA Types in OSPF?
LSA types tell routers what kind of topology information an advertisement carries and how far it should travel. Router LSAs and Network LSAs stay within their area. An ABR generates Summary LSAs to carry routes between areas.
Routes an ASBR learns from outside are advertised domain-wide as AS External LSAs. Inside an NSSA, the same kind of route shows up as an NSSA External LSA instead, and it stays inside that area.
LSA Type | Name | Generated By | Scope |
Type 1 | Router LSA | Every router | Within its area |
Type 2 | Network LSA | Designated Router | Within its area |
Type 3 | Summary LSA | ABR | Between areas |
Type 4 | ASBR Summary LSA | ABR | Between areas |
Type 5 | AS External LSA | ASBR | Whole OSPF domain |
Type 7 | NSSA External LSA | ASBR in an NSSA | Within the NSSA |
What Are OSPF Network Types?
OSPF network types, set per interface, decide two things: how neighbors get discovered, and whether a Designated Router election happens at all. In practice you'll run into four: broadcast, point-to-point, non-broadcast multi-access (NBMA) and point-to-multipoint.
Ethernet is the typical broadcast case, and on segments like it the routers elect a Designated Router (DR) plus a Backup Designated Router (BDR). With the DR acting as the central point for LSA exchange, the other routers on the link avoid having to build full adjacencies with one another. Point-to-point links skip the election, since only two routers share the connection.
What Is the Difference Between OSPF and BGP?
Where OSPF selects routes by link cost within a single organization, BGP (Border Gateway Protocol) works between organizations. BGP is an exterior, path-vector protocol. It runs over TCP port 179 and chooses routes using policy attributes.
Factor | OSPF | BGP |
Protocol type | Interior, link-state | Exterior, path-vector |
Where it runs | Inside one autonomous system | Between autonomous systems |
Path selection | Lowest cost | Policy and path attributes |
Transport | IP protocol 89 | TCP port 179 |
Convergence | Faster | Slower, built for scale and policy control |
OSPF usually converges faster, whereas BGP accepts slower convergence in return for scale and much finer policy control. It's common for an enterprise to run the two together, with OSPF across the campus or WAN and BGP at the internet edge.
Why Is OSPF Important for Network Operations?
OSPF matters to operations teams because routing health directly shapes whether applications stay reachable. One adjacency drop can push traffic across a congested link, add latency or cut off a site entirely, and users tend to feel it long before a ticket names the cause.
Keeping OSPF stable means watching it all the time. Teams track neighbor state changes through SNMP traps and syslog messages, compare route tables against the expected topology, and flag rising LSA flooding that hints at an unstable link.
When those routing events sit next to interface metrics like packet loss and utilization, root cause analysis moves faster, and an engineer can trace a slow application to a flapping WAN circuit before anyone starts checking servers. Tracking changes to network configuration closes the loop, because many adjacency failures trace back to a recent edit on timers, areas or authentication.
Explore More IT Terms
Browse our comprehensive IT glossary to learn more about technology terminology.