OSPF Complete Guide: From Fundamentals to Enterprise Design

OSPF Complete Guide on PingLabz: link-state routing fundamentals, configuration, and enterprise design on Cisco IOS XE.
Table of Contents

OSPF (Open Shortest Path First) is the most widely deployed interior gateway protocol in enterprise networks, and the protocol most CCNP and CCIE candidates spend the longest time in the lab with. It is fast-converging, vendor-neutral, scales cleanly to thousands of routers when you design it right, and has just enough complexity (LSA types, area types, DR/BDR election, virtual links) to keep it interesting for a long career.

This is the cluster overview for the full PingLabz OSPF series: 38 articles covering fundamentals, configuration, troubleshooting, internals, and enterprise design, all built on Cisco IOS XE 17.x. If you are studying for CCNA/CCNP/CCIE, designing a multi-area campus, or troubleshooting a stuck adjacency at 2 AM, start here. We will work through what OSPF is, how the protocol operates, the LSA types you actually need to know, and the configuration commands to bring up a working topology, with links into the deeper articles where you need them.

What OSPF Solves

Inside a single autonomous system you need a routing protocol that can react to a link failure in well under a second, scale to thousands of routes without flooding the network with updates, and let multiple network operators express decisions about which links to prefer. RIP is too slow and does not scale. EIGRP is fast but proprietary (open since 2013, but adoption beyond Cisco is rare). BGP is too slow on purpose and the wrong abstraction for intra-domain routing.

OSPF is what most networks reach for. It is:

  • Link-state. Every router floods its view of the local topology to every other router in the area, so all routers build the same map and run the same shortest-path computation independently.
  • Standards-based (RFC 2328 for OSPFv2, RFC 5340 for OSPFv3). Vendor interop is genuinely good.
  • Fast-converging. Sub-second failover is achievable with the default timers and trivial with BFD.
  • Hierarchical. Areas let you contain LSA flooding and SPF computation to a sub-region, which is how OSPF scales past a few hundred routers.
  • Cost-based. The metric is a 16-bit integer derived from interface bandwidth, with a single tiebreaker (equal-cost multipath, ECMP, by default up to 4 paths and tunable).

You will run OSPF underneath BGP on most production networks: OSPF for fast internal reachability, BGP at the edge for inter-AS policy. The two are complementary, not competitive. What is OSPF? A Complete Guide to Open Shortest Path First has the long-form intro.

How OSPF Works (the 10,000-Foot View)

OSPF runs directly on top of IP (protocol number 89, no TCP or UDP). It uses two multicast addresses on broadcast networks: 224.0.0.5 (AllSPFRouters) and 224.0.0.6 (AllDRouters). The protocol moves through three phases on every link it activates:

  1. Neighbor discovery. Routers send Hello packets. If the Hello parameters match (area ID, hello/dead timers, subnet mask on broadcast links, authentication, MTU), the routers form a neighbor relationship.
  2. Database synchronization. Once neighbors are at ExStart/Exchange, they swap Database Description (DBD) packets summarizing their LSDB, then request and exchange any missing LSAs via LSR/LSU/LSAck.
  3. SPF computation. When the LSDB stabilizes, every router runs Dijkstra's SPF algorithm against its own copy and installs the resulting routes. Because every router in the area has an identical LSDB, every router computes the same topology. That is the link-state guarantee.

The full mechanics are in Introduction to OSPF: How It Works and Why It Matters, with packet-level detail in OSPF Packet Types Explained: Hello, DBD, LSR, LSU, LSAck.

Multi-area OSPF topology with two ABRs in Area 0 backbone connected by 10.0.0.0/30, R1 hanging off ABR1 in Area 1 (standard), R2 hanging off ABR2 in Area 2 (stub), each router labeled with router ID and DR/BDR priority
Figure 1. The reference topology used through this guide: Area 0 backbone with two ABRs, plus a standard area and a stub area hanging off it.

OSPF Neighbor States: What show ip ospf neighbor Tells You

Every OSPF adjacency walks through these states. If you see a neighbor stuck somewhere along the way, the state itself is the diagnostic clue:

StateWhat's happeningStuck here means...
DownNo Hellos received yetL2 problem, OSPF not enabled, ACL
AttemptNBMA only: trying to send unicast HelloManual neighbor config issue
InitHello received but our router ID is not yet in their HelloOne-way Hello, asymmetric ACL/filter
2-WayBidirectional Hellos confirmed; this is the final state for non-DR/BDR pairs on broadcast linksHealthy on broadcast non-DR pairs
ExStartNegotiating master/slave for DBD exchangeMTU mismatch (#1 cause)
ExchangeDBD packets being swappedMTU mismatch, packet drop
LoadingRequesting missing LSAs via LSRRare; LSU loss
FullLSDBs synchronized; healthy steady stateThis is what you want

Stuck-in-ExStart is so common it has its own article: OSPF MTU Mismatch: Symptoms and Fixes. The full state walkthrough with packet captures is in OSPF Neighbor States Explained.

Eight OSPF neighbor states grouped into two phases: Discover Neighbor (Down, Attempt, Init, 2-Way) and Synchronize LSDB (ExStart, Exchange, Loading, Full). ExStart highlighted in red as where MTU mismatch lives, Full highlighted in teal as the target state
Figure 2. The eight states split by what they're doing. ExStart is the MTU-mismatch graveyard; Full is where a healthy adjacency lives.

LSA Types: The Heart of OSPF Internals

OSPF carries topology information in Link-State Advertisements (LSAs). Different LSA types describe different scopes and propagate differently. Memorize the first six; the rest are special-case:

TypeNameOriginated byScopeCarries
1Router LSAEvery routerSingle areaRouter's own links and costs
2Network LSADR on broadcast/NBMASingle areaRouters attached to the segment
3Summary LSA (network)ABROther areasInter-area prefix
4Summary LSA (ASBR)ABROther areasHow to reach an ASBR
5External LSAASBRWhole AS (not stub)Redistributed external routes
7NSSA External LSAASBR in NSSANSSA only, then converted to Type 5 by ABRExternal routes from inside an NSSA
9-11Opaque LSAsVariousLink / area / ASMPLS-TE, traffic engineering, segment routing

The reason area types exist (stub, totally stubby, NSSA, totally NSSA) is to control which of these LSA types make it into the area, which is how you keep small areas small. The full reference, including how each LSA looks in show ip ospf database, is in OSPF LSA Types Explained (Type 1-7).

OSPF LSA types reference: Type 1 Router LSA originated by every router with single-area scope, Type 2 Network LSA by DR on broadcast, Type 3 Summary by ABR for inter-area prefixes, Type 4 ASBR Summary, Type 5 External by ASBR scoped to whole AS except stubs, Type 7 NSSA External scoped to NSSA and converted to Type 5 at the ABR
Figure 3. The six LSA types you actually have to know, and how far each one floods.

Areas: Why OSPF Scales

OSPF scales by splitting a network into areas. Every router in an area has an identical LSDB, but routers in different areas only see summarized inter-area information. Three rules govern area design:

  1. Every multi-area OSPF deployment must have an Area 0 (the backbone).
  2. All non-backbone areas must connect to Area 0, either directly via an Area Border Router (ABR), or indirectly through a virtual link (try to avoid these).
  3. Inter-area traffic must transit Area 0. The protocol does not support arbitrary area-to-area shortcuts.

The four area flavors and what they filter:

Area typeType 3 summary?Type 4 summary?Type 5 external?Type 7 NSSA?
StandardYesYesYesNo
StubYesNoNoNo
Totally stubbyNo (default route only)NoNoNo
NSSAYesNoNoYes (converted to T5 at ABR)
Totally NSSANo (default route only)NoNoYes

Use stub areas wherever you can; the smaller the LSDB the faster the SPF run. The full design walkthrough is in OSPF Areas Explained: Why and How to Use Them, configuration in OSPF Stub Area Configuration, and the rare-but-needed OSPF Virtual Links Configuration for backbone discontinuities.

OSPF area type filtering matrix: Type 3 inter-area allowed in Standard, Stub, NSSA and replaced by default in Totally Stubby and Totally NSSA. Type 4 ASBR summary and Type 5 external blocked everywhere except Standard. Type 7 NSSA external allowed only in NSSA and Totally NSSA
Figure 4. What each area type filters. Smaller LSDB = faster SPF. Use the most restrictive area type the topology allows.

On a broadcast or NBMA segment with N routers, full-mesh adjacencies would require N(N-1)/2 sessions. Instead, OSPF elects one Designated Router (DR) and one Backup DR (BDR), and every other router only forms full adjacencies with those two. The DR generates the Type 2 LSA describing the segment.

Election rules in order:

  1. Highest OSPF priority (default 1, range 0-255; 0 means "never DR")
  2. Highest router ID (which itself defaults to the highest loopback IP, falling back to highest physical interface IP at process start)

The election is non-preemptive. If you bring up a router with priority 100 onto a segment that already has a DR, the existing DR stays put. To force a change, bounce the OSPF process or take the link down. OSPF DR and BDR: What They Are and Why They Matter has the full election walkthrough.

DR/BDR election on a five-router broadcast segment: R1 wins as DR with priority 100, R2 takes BDR with priority 50, R3, R4, and R5 stay as DROther with default priority 1. Adjacency matrix shows DROther to DR/BDR pairs go Full while DROther to DROther pairs stop at 2-Way, giving 7 full adjacencies instead of 10
Figure 5. The election rules on a multi-access segment, and the adjacency math: 5 routers, 7 full adjacencies (not 10), because DROthers only fully peer with the DR and BDR.

On point-to-point links (the default network type for most modern WAN circuits), there is no DR election. Full adjacencies form directly between the two routers.

OSPF Network Types: The One Setting Most Engineers Forget

OSPF behaves differently depending on the network type assigned to each interface. The default depends on the interface (broadcast on Ethernet, point-to-point on serial, NBMA on Frame Relay), but you can override it:

Network typeDR election?Hello/DeadNeighbor discoveryUse when
BroadcastYes10/40MulticastDefault Ethernet, multi-access
Point-to-pointNo10/40MulticastPoint-to-point links
Point-to-multipointNo30/120MulticastHub-and-spoke without DR overhead
NBMAYes30/120Manual neighbor configFrame Relay full mesh (rare today)
LoopbackNon/an/aDefault for loopback interfaces

The single most useful trick: change a broadcast interface to point-to-point with ip ospf network point-to-point. It skips DR election and shaves a few seconds off neighbor formation. OSPF Network Types Explained covers when to do this and when not to.

Configuration on Cisco IOS XE: Minimum Viable OSPF

The smallest possible single-area OSPF config:

R1(config)# router ospf 1
R1(config-router)#  router-id 1.1.1.1
R1(config-router)#  network 10.0.0.0 0.0.255.255 area 0
R1(config-router)#  passive-interface default
R1(config-router)#  no passive-interface GigabitEthernet0/0/1

Three things to notice. First, the process ID (1) is locally significant only; you do not have to match it on neighbors. Second, the wildcard mask in the network statement is inverted from a regular subnet mask (0.0.255.255 is the inverse of /16). Third, passive-interface default followed by selective no passive-interface is the safe pattern: it stops you from accidentally forming OSPF adjacencies on every interface in the network statement.

You will also see the interface-based form, which is cleaner for multi-process or selective enablement:

R1(config)# interface GigabitEthernet0/0/1
R1(config-if)#  ip ospf 1 area 0

Once both sides are up, verification:

R1# show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:36    10.0.12.2       GigabitEthernet0/0/1

If you see anything other than FULL/- on a P2P link or FULL/DR or FULL/BDR on a broadcast link, you have a problem. Walk back up the neighbor states table.

The full configuration walkthrough is in How to Configure Single-Area OSPF on Cisco Routers and Configuring Multi-Area OSPF on Cisco Routers. Other essentials:

Metric and Cost: How OSPF Picks the Best Path

OSPF uses cost (a 16-bit integer) as its only metric. Lower cost wins, and the SPF algorithm sums costs along the path. The default Cisco formula is:

cost = reference_bandwidth / interface_bandwidth

The default reference bandwidth is 100 Mbps, which means anything 100 Mbps or faster gets a cost of 1. That is wrong on any modern network. Set the reference bandwidth high enough to differentiate your fastest link:

R1(config)# router ospf 1
R1(config-router)#  auto-cost reference-bandwidth 100000   ! 100 Gbps

Set the same value on every router in the OSPF domain. How OSPF Calculates Metric and Cost walks through the math and the gotchas.

OSPF cost formula equals reference bandwidth divided by interface bandwidth. With the default 100 Mbps reference, every interface 100 Mbps or faster collapses to cost 1, hiding 1G, 10G, and 100G differences. Setting auto-cost reference-bandwidth 100000 (100 Gbps) restores meaningful cost values: 10000 for 10 Mbps, 1000 for 100 Mbps, 100 for 1G, 10 for 10G, 1 for 100G
Figure 6. Why the default reference bandwidth is wrong on every modern network: anything above 100 Mbps clamps to cost 1 and OSPF can't tell a 1G link from a 100G link.

Get the OSPF Field Reference - 9 pages, free

Everything in this pillar, on nine printable pages. State machine diagram, LSA types, troubleshooting decision tree, copy-paste IOS XE templates, and real lab captures from a Cisco Modeling Labs build. Free for PingLabz members - just sign up with your email.

Get the OSPF cheat-sheet

OSPF vs Other Routing Protocols

TraitOSPFEIGRPIS-ISBGP
TypeLink-stateDistance-vector (DUAL)Link-statePath-vector
StandardsOpen (RFC 2328)Open since 2013, Cisco-ledOpen (ISO 10589)Open (RFC 4271)
Default AD (Cisco)11090 internal / 170 external11520 / 200
ConvergenceSub-second with tuningSub-second (DUAL)Sub-second with tuningSlow on purpose
MetricCost (bandwidth-derived)Composite (bandwidth, delay)Cost (configurable)Path attributes
HierarchyAreas with strict rulesNone nativeTwo-level (L1/L2)Confederations / RR
ScopeIntra-ASIntra-ASIntra-AS (huge ISPs)Inter-AS

If you also run BGP (and most production networks do), see the BGP pillar at BGP (Border Gateway Protocol): The Complete Guide for how the two coexist. The dedicated head-to-head is BGP vs OSPF: When to Use Each Routing Protocol, and OSPF vs Other Routing Protocols goes deeper on the trade-offs.

Redistribution: Bringing Routes In and Out of OSPF

Every multi-protocol network needs redistribution somewhere: from connected/static into OSPF, between OSPF processes, between OSPF and BGP, between OSPF and EIGRP. Two things matter:

  1. Filter aggressively. Redistribution defaults are dangerous (one ASBR can pull thousands of routes into OSPF Type 5 LSAs and explode the LSDB). Use route maps with prefix-list matches.
  2. Pick external metric type carefully. Type 1 (E1) adds the OSPF cost to reach the ASBR; Type 2 (E2, default) does not. Use E1 inside a single AS to allow internal cost tiebreakers; E2 for routes coming in from outside.

The full walkthrough with worked examples is in OSPF Redistribution: How to Inject Routes from Other Protocols, and summarization at the ABR / ASBR boundary is in OSPF Route Summarization: Strategy and Configuration.

OSPF Security and the Common Mistakes

OSPF was not designed with hostile networks in mind, but the modern hardening checklist is short and well-understood:

  • Authentication on every adjacency. MD5 minimum, SHA where supported. Plain-text exists only for migration scenarios.
  • Passive-interface default followed by explicit no passive-interface on the interfaces that should peer. This is by far the most common control failure: a network statement that accidentally pulls in a customer-facing interface.
  • Strict TTL check (GTSM) with ip ospf ttl-security hops 1 on point-to-point links to defeat off-link attackers.
  • maxprefix-style redistribution filtering to cap blast radius from a misconfigured ASBR.
  • Stub or NSSA on edge areas to limit the LSAs a compromised router can inject.

The full hardening pattern is in OSPF Design Best Practices for Enterprise Networks.

Troubleshooting: The Five Failures You Will See

The Full OSPF Cluster, in Reading Order

Fundamentals

1. What is OSPF? A Complete Guide to Open Shortest Path First
2. OSPF Key Terms and Concepts Every Network Engineer Should Know
3. OSPF Neighbor States Explained
4. OSPF Areas Explained: Why and How to Use Them
5. OSPF DR and BDR: What They Are and Why They Matter
6. How OSPF Calculates Metric and Cost
7. OSPF Router ID: What It Is and How to Configure It
8. OSPF Packet Types Explained
9. OSPF vs Other Routing Protocols

Configuration

10. How to Configure Single-Area OSPF on Cisco Routers
11. Configure Single Area OSPFv2: Complete Lab Guide
12. OSPF Passive Interfaces: When and How to Use Them
13. Interface-Based OSPF Configuration
14. How to Advertise a Default Route in OSPF
15. Configuring Multi-Area OSPF on Cisco Routers
16. OSPF Authentication Configuration
17. OSPF Stub Area Configuration
18. OSPF Virtual Links Configuration
19. OSPF Timers: Hello and Dead Intervals Explained
20. OSPF Network Types Explained
21. Cisco OSPF Configuration Guide: Step-by-Step Tutorial
22. Configuring OSPF Router IDs and Why They Matter

Troubleshooting

23. OSPF Neighbors Not Forming
24. Fixing OSPF Area Mismatch Issues
25. OSPF MTU Mismatch
26. OSPF Authentication Mismatch
27. Fixing Duplicate OSPF Router ID Issues
28. OSPF Routes Not Appearing in Routing Table
29. Common OSPF Passive Interface Mistakes
30. OSPF Subnet Mask Mismatch

Deep Dives

31. OSPF LSA Types Explained (Type 1-7)
32. How OSPF SPF Algorithm and LSDB Work
33. OSPF Neighbor Relationships: The Foundation of OSPF
34. Understanding OSPF Terminology and Concepts

Design and Scaling

35. OSPF Route Summarization
36. OSPF Redistribution
37. OSPF Design Best Practices for Enterprise Networks
38. OSPF Basics: How It Works and Why It Matters

Hands-on OSPF - 5 CCNA labs included

Configure OSPF single-area (free preview), multi-area with ABRs and inter-area routes, network types, DR/BDR election, and MD5 authentication on real Cisco IOS XE 17.16 routers. Downloadable CML topology .yaml + starter configs. Open the PingLabz CCNA Labs library to start.

Open the OSPF labs

Frequently Asked Questions

What does OSPF stand for?

OSPF stands for Open Shortest Path First. It is a link-state interior gateway protocol defined in RFC 2328 (OSPFv2 for IPv4) and RFC 5340 (OSPFv3 for IPv6 and now IPv4 too).

What protocol number does OSPF use?

OSPF runs directly on top of IP using protocol number 89. It does not use TCP or UDP. Hellos and most updates are sent to multicast 224.0.0.5 (AllSPFRouters) and DR/BDR-only traffic to 224.0.0.6 (AllDRouters).

What is the administrative distance of OSPF?

110 on Cisco. Lower than RIP (120) and IS-IS (115), higher than EIGRP internal (90) and eBGP (20). The AD is used when multiple routing protocols offer routes to the same prefix; the protocol with the lowest AD wins.

OSPF vs EIGRP, which one should I use?

EIGRP converges slightly faster on small networks because of DUAL's local computation, but OSPF is the safer enterprise choice in 2026: it is genuinely vendor-neutral, scales further (multiple areas), and every certification track expects you to know it. Most CCIE candidates run both in the lab and OSPF in production.

OSPF vs BGP, when do you use each?

OSPF for fast intra-AS reachability. BGP for inter-AS policy and DFZ-scale prefix counts. You almost always run both: OSPF underneath BGP so the iBGP TCP sessions stay up and BGP NEXT_HOPs resolve. See the BGP pillar for the inter-AS half of the story.

How many OSPF neighbor states are there?

Eight: Down, Attempt, Init, 2-Way, ExStart, Exchange, Loading, Full. The first four are about discovering the neighbor; the last four are about synchronizing the LSDB. A healthy adjacency on a point-to-point link ends in Full; on a broadcast link, non-DR/BDR pairs stay at 2-Way and only the DR/BDR pair reaches Full.

Key Takeaways

If you take one thing away from this guide, make it this: OSPF rewards careful design at the area level. Every other concept (LSA types, area types, DR/BDR, network types) becomes obvious once you understand why areas exist. Memorize the neighbor states and the LSA types, set passive-interface default on every router, set the reference bandwidth on every router, and verify with show ip ospf neighbor after every change. Bookmark this page, work through the cluster articles in order, and lab every configuration. By the time you finish, you will be ready for any OSPF question a CCIE lab or a 3 AM ticket can throw at you.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Ping Labz.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.