LearnNetwork
OSPF

OSPF — the link-state workhorse

14 min

OSPF (Open Shortest Path First, RFC 2328 for v2 / RFC 5340 for v3) is the dominant interior gateway protocol in most enterprise and many operator networks. It's a link-state protocol: every router builds a full picture of the network topology and runs Dijkstra's algorithm against it. Fast convergence, vendor-neutral, well-understood.

How it works in five steps

  1. Hello. Routers send periodic Hello packets (default every 10 s) out OSPF-enabled interfaces. Neighbors discover each other.
  2. Adjacency. Compatible neighbors form an adjacency, exchanging summaries of their link-state databases.
  3. Database sync. Each router floods its LSAs (Link-State Advertisements) to all neighbors until everyone has the same database.
  4. SPF. Each router runs Dijkstra on the database to compute the shortest path to every destination.
  5. RIB install. Best paths go into the routing table with AD 110.

When a link fails, the affected router floods a new LSA, every router re-runs SPF, the new topology takes effect in seconds.

Areas — making OSPF scale

A flat OSPF (everything in area 0) doesn't scale past a few dozen routers — every change triggers a full SPF everywhere. Areas segment the topology:

  • Area 0 (backbone) is mandatory. Every other area must touch it.
  • ABRs (Area Border Routers) sit between area 0 and other areas, summarizing routes between them.
  • Non-backbone areas see only the summary, not the full intra-area detail of other areas.

Special area types:

| Area type | Allows | |---|---| | Standard | All LSA types | | Stub | Drops Type 5 (external) LSAs — uses default route instead | | Totally stubby | Drops Type 3, 4, and 5 — even smaller table | | NSSA (Not-So-Stubby) | Stub + can originate Type 7 for local externals |

For CCNA: know that areas exist, know area 0 is the backbone, know stub/totally-stubby reduce LSA flood at the cost of using a default for external traffic.

LSA types you'll see

| Type | Name | What | |---|---|---| | 1 | Router LSA | Each router floods its own interfaces | | 2 | Network LSA | Originated by DR on broadcast/NBMA networks | | 3 | Summary LSA | ABR summarizes inter-area routes | | 4 | ASBR Summary | ABR advertises the location of an ASBR | | 5 | External (AS-External) | Routes redistributed in from BGP, static, etc. | | 7 | NSSA External | Type 5 equivalent within an NSSA area |

DR / BDR on broadcast segments

On a multi-access network (Ethernet) with multiple OSPF routers, full mesh adjacencies would be n×(n-1)/2. OSPF avoids this by electing a DR (Designated Router) and BDR (Backup DR); other routers form adjacency only with the DR and BDR. The DR floods updates on behalf of the segment.

DR election: highest OSPF interface priority wins (default 1; 0 = ineligible). Tie-breaker: highest router-id.

Point-to-point links don't elect a DR — they always have just two neighbors.

Metric — bandwidth-based cost

OSPF cost is reference-bandwidth / interface-bandwidth. Default reference is 100 Mbps, which means a 100 Mbps link costs 1, a 1 Gbps link also costs 1 (because the formula floors at 1), and a 100 Gbps link still costs 1. Modern networks raise the reference bandwidth so the math differentiates fast links:

Cisco IOSRaise OSPF reference bandwidth
[object Object]

Do this on every OSPF speaker in the network — mismatches cause path selection asymmetry.

Basic configuration

Cisco IOSCisco OSPF on a router
[object Object],[object Object]
Nokia SR OSNokia SR OS OSPF area 0
[object Object]

Quick troubleshooting

| Symptom | Likely cause | |---|---| | Neighbors stuck in INIT | One side sending Hellos, the other not — check ACLs, interface state | | Stuck in EXSTART/EXCHANGE | MTU mismatch on the link | | Adjacency forms then drops | Hello/dead timer mismatch, or auth secret mismatch | | Routes show up but not in RIB | Lower-AD source (static? eBGP?) wins |

What to remember

  • Link-state + Dijkstra → fast convergence, complete topology view.
  • Area 0 mandatory, others attach to it via ABRs.
  • DR/BDR on multi-access segments, none on point-to-point.
  • Cost = reference-bandwidth / link-bandwidth. Raise the reference for modern speeds.
  • LSAs flood within an area; ABRs summarize across.