Networking · Concepts

OSPF Explained

By CertSharp Team~16 min readLast updated

Free practice quiz

Test yourself on Cisco CCNA (200-301)

30 exam-style Cisco CCNA (200-301) questions with explanations. No signup needed. Browse all Cisco certifications.

Take the free quiz

Quick answer

OSPF (Open Shortest Path First) is an open-standard link-state routing protocol. Each router floods information about its links, builds an identical map of the network called the link-state database, and runs Dijkstra's algorithm to choose the lowest-cost path to every destination. Cost is based on interface bandwidth, and OSPF has an administrative distance of 110.

OSPF (Open Shortest Path First) is the routing protocol candidates spend the most CCNA study time on, and for good reason — it carries the largest chunk of the IP Connectivity domain, the single biggest section of the 200-301 exam. Get the mechanics solid and a meaningful share of that domain's questions become straightforward.

The mental model

Picture every router in an OSPF network building its own copy of a complete road map — not just a list of "next turn" directions, but the entire layout: every road, every intersection, every distance. Once every router has the same map, each one independently calculates the shortest route to every destination using that map. This is fundamentally different from a routing protocol where routers only tell each other "go this way" without sharing the full picture.

OSPF is a link-state protocol. This matters because it explains almost everything else about how OSPF behaves:

  • Link-state (OSPF): every router builds an identical, complete topology database, then independently runs Dijkstra's shortest-path-first algorithm against it. Convergence is fast because every router already has the full picture when a change happens.
  • Distance-vector (RIP, and EIGRP as an advanced hybrid): routers only know what their direct neighbors tell them — "I can reach network X in N hops" — without seeing the full topology.

This is why OSPF requires more router CPU and memory than distance-vector protocols — it is doing real computation, not just repeating what neighbors said. OSPF also skips the transport layer entirely, running directly over IP protocol 89; TCP vs UDP Explained covers what that layer normally does.

How neighbor adjacency forms

Two OSPF routers go through a defined sequence before they become full neighbors and start exchanging routing information:

  1. Down: no Hello packets received yet.
  2. Init: a Hello packet was received, but the router has not yet seen itself listed in the neighbor's Hello.
  3. 2-Way: both routers see each other in their neighbors' Hello packets — bidirectional communication confirmed.
  4. ExStart / Exchange: routers negotiate master/slave roles and exchange database description packets.
  5. Loading: routers request any missing link-state information from each other.
  6. Full: both routers have identical topology databases — the adjacency is complete and routes are calculated.

For two routers to progress past 2-Way, several values must match exactly: the area ID, the hello and dead timers, the subnet mask on the shared segment, and the authentication settings (if configured). A mismatch on any of these silently prevents adjacency — this is the most common real-world OSPF troubleshooting scenario.

DR and BDR election

On multi-access networks (like an Ethernet segment with three or more routers), OSPF elects a Designated Router (DR) and Backup Designated Router (BDR) to reduce the number of adjacencies needed. Instead of every router forming a full adjacency with every other router (an inefficient full mesh), all routers form full adjacencies only with the DR and BDR, and stay in a lighter 2-Way state with each other.

Election criteria, in order:

  1. Highest OSPF priority (configurable per interface, default 1; a priority of 0 makes a router ineligible to become DR/BDR).
  2. Highest Router ID as the tiebreaker — typically the highest IP address on a loopback interface, or the highest active physical interface IP if no loopback exists.

Point-to-point links (a direct connection between exactly two routers) skip DR/BDR election entirely — there is no need to reduce adjacency count when only two routers exist on the segment.

Areas and why they exist

A single, flat OSPF network becomes computationally expensive as it grows — every router recalculating the full topology on every change does not scale. Areas solve this by dividing the network into smaller sections, each maintaining its own detailed topology database, while only summarized routing information crosses area boundaries.

  • Area 0 (the backbone) is mandatory in any multi-area OSPF design — every other area must connect to it, directly or through a virtual link.
  • A router with interfaces in two different areas is an Area Border Router (ABR).
  • CCNA-level OSPF is typically single-area (all routers in Area 0) — multi-area design goes deeper at the CCNP level, but recognizing the vocabulary is fair game.

The cost metric, worked example

OSPF's metric is cost, calculated per interface as: reference bandwidth ÷ interface bandwidth. Cisco IOS defaults the reference bandwidth to 100 Mbps (100,000 Kbps).

Interface bandwidthOSPF cost (default reference)
10 Mbps (Ethernet)10
100 Mbps (Fast Ethernet)1
1 Gbps (Gigabit Ethernet)1 (rounds down — see note)

Worked example: a packet crosses two Fast Ethernet links (cost 1 each) to reach its destination. Total path cost = 1 + 1 = 2. If an alternate path crosses one 10 Mbps link (cost 10), OSPF prefers the two-hop Fast Ethernet path because its total cost (2) is lower — fewer hops does not automatically mean a better path in OSPF.

Note: with the default 100 Mbps reference bandwidth, both Fast Ethernet and Gigabit Ethernet round to a cost of 1, meaning OSPF cannot tell them apart by default. Network engineers commonly raise the reference bandwidth (auto-cost reference-bandwidth) on modern high-speed networks to restore meaningful cost differentiation — a detail worth knowing conceptually for CCNA even though configuring it is beyond the exam's core scope.

LSAs at a glance

Routers exchange Link-State Advertisements (LSAs) to build their shared topology database. CCNA-level awareness of the two most common types is sufficient:

  • Type 1 (Router LSA): describes a router's own directly connected links, flooded within its area.
  • Type 2 (Network LSA): generated by the DR on a multi-access segment, describing all routers attached to that segment.

OSPF vs EIGRP

CCNA expects deep OSPF fluency but only conceptual EIGRP awareness. The key distinction: OSPF is an open standard link-state protocol (works across vendors); EIGRP is Cisco-proprietary and technically an advanced distance-vector protocol, though it behaves faster than classic distance-vector protocols thanks to its DUAL algorithm and feasible successor concept (see EIGRP explained for how it works, and the RIP routing protocol for the classic hop-count alternative). Full comparison table in the CCNA cheat sheet.

Why adjacencies fail to form

The most common real-world (and exam simlet) causes, roughly in order of frequency:

  1. Area ID mismatch — both ends of a link must be configured for the same OSPF area.
  2. Hello/dead timer mismatch — both routers must agree on how often to send Hellos and how long to wait before declaring a neighbor dead.
  3. Subnet mask mismatch — routers on the same segment must agree on the subnet boundaries.
  4. MTU mismatch — mismatched maximum transmission unit sizes can stall the Exchange state specifically, a distinctive symptom worth recognizing.
  5. Authentication mismatch — if configured, both sides must match exactly.
  6. Passive interface misconfiguration — a passive interface suppresses Hello packets entirely, which looks identical to a cabling problem from the neighbor router's perspective.

Common misconceptions

  • “OSPF always picks the path with the fewest hops.” False — it picks the lowest total cost, which can favor a longer path over higher-bandwidth links, as shown in the worked example above.
  • “Every OSPF network elects a DR and BDR.” False — only multi-access segments do; point-to-point links skip election entirely.
  • “OSPF and EIGRP can share routes automatically.” False — they are independent protocols with different metrics and require explicit redistribution to exchange routes.
  • “A router with the highest priority always becomes DR.” Mostly true, but only at election time — OSPF does not re-elect a new DR just because a higher-priority router joins later (the existing DR keeps its role until it fails or the segment resets).

How this is tested on CCNA

Expect a mix of pure recall (default administrative distance is 110, default reference bandwidth is 100 Mbps), applied cost calculations across multiple hops, DR/BDR election logic, and troubleshooting scenarios — sometimes as simlets — where you must read show ip ospf neighbor or show ip ospf interface output and identify why an expected adjacency has not formed. A reliable heuristic: if the question describes two routers stuck below Full state, check area ID, timers, and MTU first — those three cover the large majority of real adjacency failures.

For the full CCNA routing metric comparison and administrative distance table, see the CCNA cheat sheet. You can also drill this concept specifically in CertSharp's 500-question CCNA bank.

How do you configure basic single-area OSPF on a Cisco router?

Here is the minimum configuration to run OSPFv2 in Area 0 on a Cisco IOS router. The network command takes a wildcard mask, not a subnet mask; if wildcards are new to you, review the wildcard section of our subnetting walkthrough first.

R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
R1(config-router)# network 10.1.1.0 0.0.0.255 area 0
R1(config-router)# network 192.168.10.0 0.0.0.255 area 0
R1(config-router)# passive-interface GigabitEthernet0/1
R1(config-router)# end
  • router ospf 1 starts OSPF process ID 1. The process ID is locally significant; it does not have to match on neighbors.
  • router-id 1.1.1.1 sets the router ID manually. Without it, IOS uses the highest IP on a loopback interface, otherwise the highest IP on an active physical interface.
  • network ... area 0 enables OSPF on every interface whose IP address falls inside that address range and advertises that interface's network.
  • passive-interface stops Hello packets on an interface (for example, one facing users) while still advertising its network, so no adjacency can form there.

An alternative that scales better is interface-level configuration: interface GigabitEthernet0/0 then ip ospf 1 area 0. It avoids wildcard math entirely and makes it obvious which interfaces participate.

Which show commands verify OSPF?

CommandWhat it tells you
show ip ospf neighborNeighbor router IDs, priority, state (FULL, 2WAY, INIT, EXSTART), DR/BDR role, dead timer and interface
show ip route ospfOnly routes learned via OSPF, marked O, with administrative distance and metric as [110/cost]
show ip ospf interface briefPer-interface area, cost, state (DR, BDR, DROTHER, P2P) and neighbor count
show ip ospf interface GigabitEthernet0/0Timers (hello/dead), network type, priority, DR/BDR and cost
show ip protocolsRouter ID, networks being advertised, passive interfaces and administrative distance
show ip ospf databaseThe link-state database grouped by LSA type
debug ip ospf adjLive adjacency negotiation messages; useful for finding mismatches (use carefully on production devices)
R1# show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:35    10.1.1.2        GigabitEthernet0/0
3.3.3.3           1   FULL/BDR        00:00:38    10.1.1.3        GigabitEthernet0/0

R1# show ip route ospf
O    192.168.20.0/24 [110/2] via 10.1.1.2, 00:05:12, GigabitEthernet0/0

Read the state column as STATE/ROLE. FULL/DR means the neighbor has reached Full adjacency and is the Designated Router on that segment. Seeing 2WAY/DROTHER between two non-DR routers on an Ethernet segment is normal, not a fault.

What OSPF facts should you memorize?

ItemValue
Administrative distance110
IP protocol number89 (OSPF runs directly over IP, not TCP or UDP)
Multicast addresses224.0.0.5 (all OSPF routers) and 224.0.0.6 (all DR/BDR routers)
Default Hello / Dead timers (broadcast and point-to-point)10 seconds / 40 seconds
Default Hello / Dead timers (non-broadcast)30 seconds / 120 seconds
Default OSPF priority1 (0 means never DR or BDR)
Router ID orderManual router-id, then highest loopback IP, then highest active physical interface IP
Default reference bandwidth100 Mbps (cost = 100 Mbps divided by interface bandwidth)
AlgorithmDijkstra shortest path first, run independently by each router

How do OSPF network types affect DR/BDR election and timers?

Network typeTypical mediumDR/BDR elected?Default hello / dead
BroadcastEthernetYes10 / 40
Point-to-pointSerial or a configured Ethernet linkNo10 / 40
Non-broadcast (NBMA)Frame Relay style multi-accessYes30 / 120
Point-to-multipointHub-and-spoke designsNo30 / 120

A very common design is two routers connected by Ethernet. Because Ethernet defaults to the broadcast network type, they elect a DR and BDR needlessly. Setting ip ospf network point-to-point on both interfaces skips the election and speeds up convergence. Both ends must be set the same way, or the hello and dead timers can mismatch.

Worked example: who becomes DR and BDR?

RouterPriorityRouter IDOutcome
R111.1.1.1DROTHER
R212.2.2.2BDR (highest router ID among the priority-1 routers)
R31003.3.3.3DR (highest priority)
R404.4.4.4DROTHER, ineligible (priority 0)

Priority is compared first, so R3 wins even though R4 has the highest router ID; R4 is ineligible because its priority is 0. Among the remaining priority-1 routers, R2's higher router ID makes it the BDR. Now add R5 with priority 200 later: it does not take over. OSPF elections are non-preemptive, so R5 becomes DROTHER until the DR or BDR fails or the OSPF process on the segment is reset.

Worked example: which path does OSPF choose?

R1 can reach the 172.16.5.0/24 LAN on R3 by two paths. With the default reference bandwidth, OSPF adds the cost of every outgoing interface along the way, including the interface into the destination network.

PathLinks (outgoing interface cost)Total cost
A: R1 to R2 to R3R1-R2 Fast Ethernet (1) + R2-R3 10 Mbps Ethernet (10) + R3 LAN Fast Ethernet (1)12
B: R1 to R4 to R3R1-R4 Fast Ethernet (1) + R4-R3 Fast Ethernet (1) + R3 LAN Fast Ethernet (1)3

Path B wins with a cost of 3, and show ip route ospf would display the route as [110/3]. If both paths had equal cost, OSPF would install both and load-balance across them (equal-cost multipath, up to a configurable number of routes).

How do you fix the reference bandwidth problem?

With the default 100 Mbps reference, every link at 100 Mbps or faster costs 1, so OSPF cannot prefer a 10 Gbps path over a 100 Mbps one. Raise the reference bandwidth on every router in the OSPF domain (the value is in Mbps), or set the cost manually per interface:

R1(config-router)# auto-cost reference-bandwidth 10000
R1(config)# interface GigabitEthernet0/0
R1(config-if)# ip ospf cost 5
Link speedCost at 100 Mbps referenceCost at 10,000 Mbps reference
10 Mbps101000
100 Mbps1100
1 Gbps110
10 Gbps11

If the reference bandwidth is changed on some routers but not others, costs become inconsistent and OSPF can make suboptimal choices. Cisco IOS prints a warning to remind you to change it everywhere.

What are the main OSPF LSA types and router roles?

LSA typeNameGenerated byFlooded to
1Router LSAEvery routerIts own area
2Network LSAThe DR on a multi-access segmentIts own area
3Summary LSAArea Border Router (ABR)Other areas
4ASBR Summary LSAABROther areas
5External LSAAutonomous System Boundary Router (ASBR)Whole OSPF domain (except stub areas)
  • Internal router: all interfaces in one area.
  • Backbone router: at least one interface in Area 0.
  • ABR: interfaces in more than one area (typically Area 0 and another).
  • ASBR: redistributes routes from outside OSPF, such as static routes or another protocol.

Troubleshooting: what does each stuck neighbor state mean?

SymptomLikely causeFirst command
Neighbor never appearsArea, subnet mask, hello/dead timer or authentication mismatch; passive interface; interface not covered by a network statement; ACL blocking 224.0.0.5show ip ospf interface, show ip protocols
Stuck in INITRouter receives the neighbor's Hellos but its own are not reaching the neighbor (ACL, one-way link, layer 2 issue)debug ip ospf hello, check ACLs and interface status
Stuck in 2WAY where FULL is expectedEvery router on a broadcast segment has priority 0, so no DR or BDR is electedshow ip ospf interface (check priority)
2WAY with a non-DR neighbor on EthernetExpected behavior, not a faultNone needed
Stuck in EXSTART or EXCHANGEMTU mismatch between the two interfaces (or duplicate router IDs)show interface on both ends, then show ip ospf neighbor
Routes missing but neighbors are FULLNetwork statements missing, filtering, or the destination is in a different area without proper connectivity to Area 0show ip ospf database, show ip route ospf

Duplicate router IDs are a subtle one: if two routers share a router ID, neighbors can flap or routes disappear. Check with show ip ospf on each router and set IDs manually.

What is the difference between OSPFv2 and OSPFv3?

OSPFv2 routes IPv4. OSPFv3 routes IPv6 (and can carry IPv4 through address families on modern software). OSPFv3 is enabled per interface rather than through network statements, uses link-local addresses for neighbor communication, and still uses 32-bit router IDs written in dotted decimal. The core mechanics covered here carry over, which is why mastering OSPFv2 is the best preparation for either.

OSPF practice questions

1. Two routers on an Ethernet segment are stuck in EXSTART. What is the most likely cause?

An MTU mismatch between the two interfaces. Hellos still work, so the routers become neighbors, but large database description packets are not exchanged.

2. Which router becomes DR: R1 priority 1 with ID 9.9.9.9, or R2 priority 2 with ID 1.1.1.1?

R2. Priority is compared first; router ID only breaks ties.

3. What is the OSPF cost of a path crossing two Gigabit links and one Fast Ethernet link with default settings?

3. Every link at 100 Mbps or faster has a cost of 1 with the default reference bandwidth, so 1 + 1 + 1 = 3.

4. What wildcard mask would you use to match 10.1.1.0/24 in a network statement?

0.0.0.255, the inverse of 255.255.255.0.

5. Why would you configure ip ospf network point-to-point on an Ethernet link between two routers?

To skip the DR/BDR election, which is unnecessary with only two routers, and to speed up adjacency formation.

6. Which command shows the neighbor state and whether a neighbor is DR or BDR?

show ip ospf neighbor.

Keep practicing with timed scenarios in the CCNA practice exam, and see the pricing page for the complete question bank.

Do you need OSPF for Network+ or CCNA?

OSPF is tested in depth on CCNA, while CompTIA Network+ covers it at a conceptual level (link-state versus distance-vector, interior versus exterior routing). OSPF is an interior gateway protocol; BGP explained covers the exterior protocol that connects autonomous systems across the internet, and HSRP explained covers the first-hop redundancy that sits alongside it on the LAN edge. If you are choosing between them, read Network+ vs CCNA and is CCNA worth it in 2026 for a career-focused view.

Frequently asked questions

What is OSPF in one sentence?

OSPF (Open Shortest Path First) is an open-standard, link-state routing protocol that builds a complete map of a network from every router's perspective, then calculates the mathematically shortest path to each destination using Dijkstra's algorithm.

What is the default OSPF metric, and how is it calculated?

The default OSPF metric is cost, calculated as a reference bandwidth (100 Mbps by default on most Cisco IOS versions) divided by the interface bandwidth. A 100 Mbps interface has a cost of 1; a 10 Mbps interface has a cost of 10. The total path cost is the sum of every outgoing interface's cost along the route.

Why does OSPF elect a DR and BDR on some networks but not others?

OSPF only elects a Designated Router (DR) and Backup Designated Router (BDR) on multi-access network types (like Ethernet), where multiple routers share the same segment. On point-to-point links, where only two routers exist, there is nothing to elect — both routers simply become full neighbors directly.

How is this tested on the CCNA exam?

Expect both conceptual questions (DR/BDR election criteria, administrative distance, cost calculation) and troubleshooting scenarios, sometimes inside a simulation-style item, where you must diagnose why two routers are not forming an OSPF neighbor adjacency from a show command's output.

What is the OSPF administrative distance?

The default administrative distance of OSPF is 110. A route learned through OSPF is less trusted than a static route (1) or EIGRP internal route (90), but more trusted than RIP (120).

What multicast addresses does OSPF use?

OSPF uses 224.0.0.5 for all OSPF routers and 224.0.0.6 for all Designated Routers and Backup Designated Routers. OSPF runs directly over IP as protocol number 89.

Why is my OSPF neighbor stuck in EXSTART?

The most common cause is an MTU mismatch between the two interfaces, which lets Hello packets succeed but blocks the larger database description packets. Check the MTU on both ends with show interface, correct them, and confirm the neighbor reaches FULL.

Sources and further reading

Test yourself on this concept

30 free CCNA questions cover OSPF scenarios directly — no signup, no credit card. Full 500-question bank is $11.99 lifetime, or $9.99/month Pro unlocks every CertSharp certification.