Explain Open Shortest Path First (OSPF) Protocol & its Question Answer

Open Shortest Path First (OSPF) is one of the most widely deployed interior gateway protocols (IGPs) in enterprise and service-provider networks. If you're studying for CCNA/CCNP, preparing for a network engineering interview, or simply trying to understand how routers "talk" to each other inside an organization, this guide covers everything you need — from core concepts to real interview questions.

8/24/20265 min read

OSPF(OPEN SHORTEST PATH FIRST)

OSPF is a link-state, classless, open-standard routing protocol that uses Dijkstra's Shortest Path First (SPF) algorithm to build a loop-free map of the network and calculate the best path to every destination.

Key characteristics of OSPF:

  • Open standard — vendor-independent (unlike Cisco's proprietary EIGRP)

  • Link-state protocol — routers share topology, not just distances

  • Classless — supports VLSM and CIDR

  • Fast convergence — triggered updates instead of periodic full updates

  • Hierarchical design — uses areas to control database size and flooding

  • Uses cost as metric — based on interface bandwidth

  • Supports authentication — plain text, MD5, and (in OSPFv3) IPsec

  • Uses multicast — 224.0.0.5 (all OSPF routers) and 224.0.0.6 (DR/BDR)

Why OSPF Matters

OSPF is the default IGP choice for most medium-to-large enterprise networks because it scales well, converges quickly after a link failure, and — because it's an open standard — works across multi-vendor environments (Cisco, Juniper, Arista, MikroTik, etc.). It's also a core CCNA, CCNP ENCOR, and JNCIA exam topic, which is why it shows up constantly in networking interviews.

How OSPF Works

At a high level, OSPF goes through three main phases:

  1. Neighbor discovery — Routers on the same segment discover each other using Hello packets sent every 10 seconds (default on broadcast/point-to-point links) or 30 seconds (NBMA links).

  2. Database synchronization — Neighbors exchange Link-State Advertisements (LSAs) to build an identical Link-State Database (LSDB).

  3. Route calculation — Each router independently runs the SPF (Dijkstra) algorithm against its LSDB to build a shortest-path tree, from which the routing table is derived.

Any topology change (a link going up/down) triggers a fast, incremental LSA flood instead of a full periodic update — this is why OSPF converges much faster than legacy distance-vector protocols.

OSPF Areas Explained

To prevent the link-state database from growing too large in big networks, OSPF divides the AS into areas. Every OSPF network must have a Backbone Area (Area 0), and all other areas must connect to it (directly or via a virtual link).

Area TypeDescriptionBackbone Area (Area 0)The core of the OSPF domain; all other areas must connect to itStandard AreaNormal area that exchanges all LSA typesStub AreaBlocks external (Type 5) LSAs; uses a default route insteadTotally Stubby AreaBlocks external AND inter-area (Type 3) LSAs (Cisco-specific)Not-So-Stubby Area (NSSA)Like a stub area but allows limited external routes via Type 7 LSAs

Areas reduce SPF calculation overhead, shrink routing tables, and localize the impact of topology changes.

OSPF Packet Types

OSPF uses five packet types, all encapsulated directly in IP (protocol number 89):

  1. Hello — Discovers and maintains neighbor relationships

  2. Database Description (DBD) — Summarizes the contents of the LSDB during synchronization

  3. Link-State Request (LSR) — Requests specific, more recent LSAs from a neighbor

  4. Link-State Update (LSU) — Carries the actual LSAs

  5. Link-State Acknowledgment (LSAck) — Confirms receipt of LSAs (reliable flooding)

OSPF Neighbor States

Two OSPF routers pass through several states before becoming fully adjacent:

  1. Down — No Hellos received yet

  2. Init — Hello received, but router's own ID not seen in neighbor's Hello

  3. 2-Way — Bidirectional communication confirmed (neighbor sees your Router ID)

  4. ExStart — Master/slave relationship established for DBD exchange

  5. Exchange — DBD packets exchanged

  6. Loading — LSRs sent for missing/outdated LSAs

  7. Full — Fully synchronized LSDBs; routers are fully adjacent

On multi-access networks, most routers only reach Full state with the DR and BDR — with other DROTHER routers they stay in 2-Way.

DR and BDR Election

On multi-access networks (like Ethernet), OSPF elects a Designated Router (DR) and Backup Designated Router (BDR) to reduce the number of adjacencies and LSA flooding (avoiding an inefficient full mesh).

  • Election is based on OSPF priority (highest wins; default is 1, range 0–255; priority 0 = never becomes DR/BDR)

  • Ties are broken by the highest Router ID

  • All other routers (DROTHERs) only form full adjacencies with the DR and BDR, not with each other

OSPF Cost Calculation

OSPF's metric is called cost, calculated by default as:

Cost = Reference Bandwidth / Interface Bandwidth

The default reference bandwidth is 100 Mbps (100,000,000 bps) on Cisco devices. This means Fast Ethernet (100 Mbps) and faster links (Gigabit, 10G) all default to the same cost unless you manually adjust the auto-cost reference-bandwidth — a very common real-world gotcha and interview topic.

OSPF LSA Types

LSA Type 1 Router LSADescribes a router's links within an area

Type 2 Network LSAGenerated by the DR; describes the multi-access segment

Type 3 Summary LSAAdvertises routes between areas (via ABR)

Type 4 ASBR Summary LSAAdvertises the location of an ASBR

Type 5 External LSAAdvertises routes redistributed from outside OSPF

Type 7 NSSA External LSA Used inside NSSAs instead of Type 5

OSPFv2 vs OSPFv3

FeatureOSPFv2OSPFv3SupportsIPv4IPv6Defined inRFC 2328RFC 5340Runs perSubnetLinkAuthenticationBuilt-in (plain text/MD5)Relies on IPv6 IPsec (AH/ESP)Router/Area ID32-bit, IPv4-styleStill 32-bit, but IPv4-format regardless of IPv6

OSPF vs Other Routing Protocols

ProtocolTypeMetricStandardOSPFLink-stateCost (bandwidth-based)Open (RFC 2328/5340)EIGRPAdvanced distance-vectorComposite (bandwidth, delay, etc.)Cisco proprietary (now partly open)RIPDistance-vectorHop count (max 15)Open (legacy)BGPPath-vectorPath attributesOpen — used for inter-AS/internet routing

OSPF is typically chosen over RIP for faster convergence and better scalability, and over EIGRP when a multi-vendor, standards-based solution is required.

Basic OSPF Configuration (Cisco IOS)

Router(config)# router ospf 1 Router(config-router)# router-id 1.1.1.1 Router(config-router)# network 10.0.0.0 0.0.0.255 area 0 Router(config-router)# network 192.168.1.0 0.0.0.255 area 1

Verification commands:

show ip ospf neighbor show ip ospf interface brief show ip route ospf show ip ospf database

Advantages and Disadvantages of OSPF

Advantages

  • Fast convergence after topology changes

  • Scales well with hierarchical areas

  • Open standard, multi-vendor support

  • Supports VLSM/CIDR and load balancing (equal-cost paths)

  • Efficient bandwidth use via multicast and incremental updates

Disadvantages

  • More complex to design and troubleshoot than RIP

  • Higher CPU/memory usage on routers (full topology database + SPF calculations)

  • Requires careful area planning to scale properly

  • All areas must connect to Area 0, which can complicate some topologies

Top 10 OSPF Interview Questions and Answers

1. What is OSPF, and what type of routing protocol is it? OSPF (Open Shortest Path First) is an open-standard, link-state interior gateway protocol that uses the Dijkstra SPF algorithm to calculate the shortest, loop-free path to every destination within an Autonomous System.

2. What is the administrative distance of OSPF? The default administrative distance of OSPF is 110.

3. What is the difference between OSPFv2 and OSPFv3? OSPFv2 (RFC 2328) supports IPv4, while OSPFv3 (RFC 5340) supports IPv6 and runs on a per-link basis instead of per-subnet. OSPFv3 also removes built-in authentication and relies on IPv6's native security (AH/ESP).

4. Why does every OSPF area need to connect to Area 0? Area 0 (the backbone) acts as the central hub through which all inter-area traffic must pass, preventing routing loops between non-backbone areas. Areas that can't physically connect to Area 0 use a virtual link.

5. What is a Designated Router (DR), and why is it needed? On multi-access (broadcast) networks, the DR is elected to centralize LSA exchange, reducing the number of adjacencies from a full mesh (n×(n-1)/2) to a much smaller, more efficient set — improving scalability and reducing flooding traffic.

6. How is OSPF cost calculated by default? Cost = Reference Bandwidth ÷ Interface Bandwidth. The default reference bandwidth on Cisco routers is 100 Mbps, meaning all interfaces faster than 100 Mbps get the same default cost unless auto-cost reference-bandwidth is adjusted.

7. What are the OSPF neighbor states, in order? Down → Init → 2-Way → ExStart → Exchange → Loading → Full.

8. What is the difference between a Stub Area, Totally Stubby Area, and NSSA? A Stub Area blocks external (Type 5) LSAs and uses a default route instead. A Totally Stubby Area additionally blocks inter-area (Type 3) summary LSAs. An NSSA is like a stub area but permits limited external route injection using Type 7 LSAs, which the ABR converts to Type 5 for the rest of the domain.

9. What multicast addresses does OSPF use? 224.0.0.5 for "All OSPF Routers" (AllSPFRouters) and 224.0.0.6 for "All DR Routers" (AllDRouters).

10. Why is OSPF generally preferred over RIP in enterprise networks? OSPF converges much faster (triggered, incremental updates vs. periodic full-table updates), scales to much larger networks via hierarchical areas, has no hop-count limitation (RIP is capped at 15 hops), and uses bandwidth-aware cost instead of simple hop count for smarter path selection.

Download the Complete OSPF Interview Guide

The 10 questions above cover the fundamentals — but real interviews (and CCNP-level panels) go deeper into topics like LSA flooding scenarios, virtual links, OSPF over NBMA/frame-relay, route summarization, redistribution and route filtering, authentication types, and troubleshooting scenarios.

👉 For the complete list of advanced OSPF interview questions and answers, download the full OSPF Interview Prep PDF from the Download PDF section on this page.