3.4 Single-Area OSPFv2 — Concepts

Key Takeaways

  • OSPF is a link-state routing protocol that uses Dijkstra's SPF algorithm to find the shortest path.
  • OSPF uses cost as its metric, calculated as reference bandwidth divided by interface bandwidth.
  • The default reference bandwidth is 100 Mbps, making all Gigabit and faster links cost 1.
  • OSPF routers form neighbor adjacencies by exchanging Hello packets to multicast 224.0.0.5.
  • OSPF uses areas for scalability; the CCNA covers single-area OSPF with all interfaces in Area 0.
Last updated: June 2026

OSPF (Open Shortest Path First) is the most commonly used interior gateway protocol (IGP) in enterprise networks. It is an open-standard link-state routing protocol defined in RFC 2328, and it is the primary routing protocol tested on the CCNA 200-301 exam.

Why OSPF?

FeatureOSPFRIPEIGRP
TypeLink-stateDistance-vectorAdvanced distance-vector
StandardOpen (RFC 2328)OpenCisco (now open)
MetricCost (bandwidth)Hop count (max 15)Bandwidth + delay
ConvergenceFastSlowFast
ScalabilityExcellent (areas)PoorGood
AD11012090

How OSPF Works

Step 1 — Discover neighbors. Routers send Hello packets to discover OSPF speakers on directly connected links.

Step 2 — Form adjacencies. Routers exchange Hellos and progress through neighbor states until fully adjacent.

Step 3 — Exchange link state. Routers exchange Link-State Advertisements (LSAs) describing their interfaces, networks, and costs.

Step 4 — Build the LSDB. Each router assembles an identical Link-State Database (LSDB) — a full topology map of the area.

Step 5 — Run SPF. Each router runs Dijkstra's Shortest Path First algorithm against the LSDB, placing itself at the root of a shortest-path tree.

Step 6 — Install routes. Best paths from the SPF tree are installed into the routing table.

OSPF Packet Types

TypeNamePurpose
1HelloDiscover and maintain neighbor relationships
2DBD (Database Description)Summarize LSDB contents for synchronization
3LSR (Link-State Request)Request specific LSAs from a neighbor
4LSU (Link-State Update)Carry the actual LSAs
5LSAckAcknowledge received LSAs

OSPF runs directly over IP as protocol number 89 and uses multicast 224.0.0.5 (AllSPFRouters) for general traffic and 224.0.0.6 (AllDRouters) to reach the DR/BDR.

OSPF Cost Calculation

OSPF metric is cost, computed as:

Cost = Reference Bandwidth / Interface Bandwidth (result rounded up, minimum 1)

Default reference bandwidth = 100 Mbps.

Interface SpeedDefault CostNote
10 Mbps10Correct
100 Mbps (FastEthernet)1Correct
1 Gbps1Same as FastEthernet — problem
10 Gbps1Same as FastEthernet — problem

Fix: Raise the Reference Bandwidth

Router(config-router)# auto-cost reference-bandwidth 10000   ! 10 Gbps reference

With a 10 Gbps reference, 1 Gbps becomes cost 10 and 10 Gbps becomes cost 1, restoring differentiation. The reference bandwidth must be identical on every OSPF router or path selection becomes inconsistent. You can also pin a value directly: ip ospf cost 5 under the interface.

OSPF Neighbor Requirements

Two routers will not become neighbors unless these match:

ParameterMust Match?Notes
Area IDYesBoth interfaces in the same area
Hello/Dead timersYesDefaults 10s/40s on broadcast; 30s/120s on NBMA
AuthenticationYesSame type and key if used
Subnet/MaskYesInterfaces on the same subnet
MTUYesMismatch stalls adjacency in ExStart
Stub/area type flagYesBoth agree on stub/NSSA
Router IDNoMust be unique, need not match

OSPF Neighbor States

StateDescription
DownNo Hello received
InitHello received, but own RID not yet seen in it
2-WayBidirectional — each sees the other's RID; DR/BDR election happens here
ExStartMaster/slave negotiation for DBD exchange
ExchangeDBD packets exchanged
LoadingLSRs/LSUs exchanged to sync LSDBs
FullLSDBs synchronized — full adjacency

On the Exam: 2-Way is normal between two DROther routers and is not a fault. A neighbor stuck in ExStart/Exchange almost always means an MTU mismatch. Stuck in Init means one-way Hellos (an ACL or filter blocking return traffic).

OSPF Areas

  • Area 0 is the backbone; every other area must connect to it.
  • Single-area OSPF places all interfaces in Area 0 — this is the CCNA scope.
  • Multi-area OSPF (different areas, ABRs) is CCNP-level.

Keeping everything in Area 0 keeps the LSDB simple and is exactly what CCNA configuration and troubleshooting items assume.

Link-State vs. Distance-Vector: Why It Matters

A distance-vector protocol like RIP shares its entire routing table with directly connected neighbors and trusts what they report — "routing by rumor." A link-state protocol like OSPF instead floods raw topology information (LSAs) so every router builds the same complete map and independently computes its own shortest paths. This gives OSPF faster, loop-free convergence and lets it use a real cost metric rather than a crude hop count. The trade-off is more memory and CPU to hold the LSDB and run SPF, which is why areas exist — they shrink each router's LSDB.

For the CCNA, connect the concept to behavior: OSPF reacts quickly to a failure because every router already holds the topology and only needs to rerun SPF.

Worked Example: Computing Cumulative Cost

OSPF cost is the sum of the outbound interface costs along the path from the router to the destination. Suppose R1 reaches network X through two Gigabit links (each cost 1 at the default reference) then one FastEthernet link (cost 1). With the default 100 Mbps reference, every hop costs 1, so the total is 3 — and a parallel path crossing three 10 Mbps links would total 30, so R1 picks the first path. The catch: at the default reference, Gigabit and 10-Gigabit links both cost 1, masking the faster path. Raising the reference bandwidth to 10000 makes Gigabit cost 10 and 10-Gigabit cost 1, so SPF can finally prefer the faster medium.

Why the Router ID Must Be Stable

The Router ID identifies a router uniquely in the LSDB and seeds tie-breaks like DR election. If you let it default to the highest interface IP and that interface later goes down, the RID could change and force the whole process to reconverge. That is why best practice — and the recommended exam answer — is to configure a loopback or a manual router-id, giving a value that never disappears with a physical interface.

Loading diagram...
OSPF Neighbor Adjacency Formation
Test Your Knowledge

What is the default OSPF cost for a GigabitEthernet interface using the default reference bandwidth of 100 Mbps?

A
B
C
D
Test Your Knowledge

Which OSPF packet type is used to discover and maintain neighbor relationships?

A
B
C
D
Test Your Knowledge

Two directly connected OSPF routers are stuck in the ExStart/Exchange state. What is the most likely cause?

A
B
C
D