Everything worth being able to explain about OSPF at a whiteboard: link-state mechanics, areas, LSAs, adjacencies, SPF, and convergence.
OSPF (Open Shortest Path First) is a link-state interior gateway protocol (IGP). Every router floods a description of its own links, so all routers in an area build an identical map of the topology — the Link-State Database (LSDB) — and then run Dijkstra's SPF algorithm independently to compute shortest paths. This differs fundamentally from distance-vector (RIP/EIGRP), where routers exchange computed routes and never see the full map.
Keep the mental model straight: link-state = flood the topology, compute routes locally. Because every router in an area has the same LSDB, routing loops within an area are structurally avoided. The metric is cost (lower is better), derived from interface bandwidth.
| Property | Value |
|---|---|
| Type | Link-state IGP |
| Algorithm | Dijkstra (SPF), run per area |
| Metric | Cost = reference-bandwidth ÷ interface-bandwidth (lower total wins) |
| Transport | Directly over IP, protocol number 89 (not TCP/UDP) |
| Administrative distance | 110 (Cisco) |
| Reliability | Its own reliable flooding (LSU/LSAck), not TCP |
| Multicast | 224.0.0.5 (AllSPFRouters), 224.0.0.6 (AllDRouters) |
| Hierarchy | Two-level: backbone area 0 + non-backbone areas |
| OSPFv2 (RFC 2328) | OSPFv3 (RFC 5340) | |
|---|---|---|
| Address family | IPv4 | IPv6 (extensible to IPv4 via AFs) |
| Runs over | IPv4 | IPv6 (link-local source) |
| Adjacency scope | Per subnet | Per link (multiple subnets per link OK) |
| Addressing in LSAs | Prefixes carried in Router/Network LSAs | Addresses removed from topology LSAs; carried separately |
| Authentication | Built-in (plaintext/MD5) | Relies on IPsec (AH/ESP) |
An area is a set of routers that share an identical LSDB and run SPF together. Areas bound the scope of flooding and SPF, so a topology change in one area does not force every router in the domain to re-run SPF. Inter-area routing is summarized at Area Border Routers, which reintroduces a distance-vector-like behavior between areas (routers trust the summary, they don't see the far area's topology).
| Role | Definition |
|---|---|
| Internal router | All interfaces in a single area. |
| Backbone router | Has at least one interface in area 0. |
| ABR (Area Border Router) | Interfaces in two or more areas, one of which must be area 0. Generates inter-area summaries (Type 3) and maintains a separate LSDB per attached area. |
| ASBR (Autonomous System Boundary Router) | Injects external routes into OSPF via redistribution (e.g. from BGP, static, another IGP). Originates Type 5 (or Type 7 in NSSA) LSAs. |
+----------------+
| Area 0 | (backbone — every area
| backbone | must touch it)
+--+---------+---+
ABR1 -----/ \----- ABR2
| |
+---------+ +---------+
| Area 1 | | Area 2 |
+---------+ +---------+
OSPF discovers neighbors and maintains liveness with Hello packets, sent to
224.0.0.5. Two routers become neighbors when their Hellos agree on a set of
parameters; only some neighbor pairs go on to form full adjacencies (exchange full LSDBs).
Down ─▶ Init ─▶ 2-Way ─▶ ExStart ─▶ Exchange ─▶ Loading ─▶ Full
│ │ │ │ │ │ │
│ │ │ │ │ │ └ full LSDB sync, adjacency up
│ │ │ │ │ └ send LSRs for missing LSAs, get LSUs
│ │ │ │ └ trade DBD (database description) headers
│ │ │ └ elect master/slave, pick initial DBD seq #
│ │ └ saw own RID in neighbor's Hello (bidirectional); DR/BDR election happens here
│ └ received a Hello but not yet bidirectional
└ no Hellos received
| State | What is happening |
|---|---|
| Down | No Hellos heard from this neighbor. |
| Init | A Hello was received, but it did not yet list our RID (one-way). |
| 2-Way | Bidirectional: each sees its own RID in the other's Hello. DR/BDR election occurs. On multi-access, DROTHER pairs stop here (stay 2-Way). |
| ExStart | Master/slave negotiation and starting DBD sequence number. |
| Exchange | Exchange DBD packets describing LSDB contents (headers only). |
| Loading | Send Link-State Requests for LSAs it lacks; receive Link-State Updates. |
| Full | LSDBs synchronized; fully adjacent. This is the healthy steady state. |
Interview trap: on a broadcast segment it is normal for two DROTHER routers to be stuck at 2-Way — they only go Full with the DR and BDR. Only stuck states like ExStart (MTU mismatch) or Init (one-way Hello / ACL) indicate a problem.
| Type | DR/BDR? | Neighbor discovery | Example |
|---|---|---|---|
| Broadcast | Yes | Dynamic (multicast Hellos) | Ethernet LAN |
| Point-to-point | No | Dynamic | Serial link, /30, /31 |
| NBMA | Yes | Manual (unicast) neighbors | Frame Relay, classic hub-spoke |
| Point-to-multipoint | No | Dynamic, treats as many p2p | Partial-mesh WAN |
On a multi-access segment with n routers, forming a full mesh of adjacencies would need
n(n-1)/2 adjacencies and each router would flood to every other — an O(n²)
explosion of LSAs. OSPF elects a Designated Router (DR) that becomes the hub: every router
forms a full adjacency only with the DR and the Backup DR (BDR), cutting adjacencies to
O(n). The DR also originates the Type 2 (Network) LSA representing the
segment as a pseudonode.
0
= never DR) wins; tie broken by highest Router ID.224.0.0.6 (AllDRouters); the DR floods to everyone on
224.0.0.5 (AllSPFRouters).The LSDB is built from Link-State Advertisements (LSAs). Each LSA type describes a different piece of the topology and has a defined flooding scope.
| Type | Name | Originated by | Scope | Describes |
|---|---|---|---|---|
| 1 | Router LSA | Every router | Area | The router's own links, states, and costs within the area. |
| 2 | Network LSA | DR only | Area | The multi-access segment (pseudonode) and its attached routers. |
| 3 | Summary / Inter-area | ABR | Area | An IP prefix in another area (inter-area route), with cost. |
| 4 | ASBR Summary | ABR | Area | How to reach the ASBR (advertised into other areas so they can use Type 5s). |
| 5 | AS External | ASBR | Domain (flooded everywhere except stub/NSSA) | A route external to OSPF (redistributed). |
| 7 | NSSA External | ASBR in NSSA | NSSA area only | External route inside an NSSA; the ABR translates it to a Type 5 at the area edge. |
(Types 6 group-membership/MOSPF, 8–11 opaque LSAs exist; opaque Type 10 carries TE data for MPLS-TE. Types 1–5 and 7 are the interview core.)
0x80000001 upward). A higher
sequence number = a newer instance of the same LSA — this is how routers decide which copy to keep.Each router runs Dijkstra's shortest-path-first over its LSDB, placing itself at the root of the SPF tree, then summing link costs to every destination.
cost = reference-bandwidth / interface-bandwidth
Cisco default reference-bandwidth = 100 Mbps
10 Mbps Ethernet -> 100/10 = 10
100 Mbps FastEth -> 100/100 = 1
1 Gbps GigE -> 100/1000 = 1 (rounds to 1 — a problem!)
10 Gbps 10GigE -> = 1 (same as GigE)
auto-cost reference-bandwidth (e.g. to 100000 for 100 G). It must match domain-wide.Special area types reduce LSDB size by blocking certain LSAs at the ABR and substituting a default route. The tradeoff is always the same: less state, less optimal/granular routing.
| Area type | Type 3 (inter-area) | Type 5 (external) | Type 4 | Default route | Can hold ASBR? |
|---|---|---|---|---|---|
| Standard | Yes | Yes | Yes | — | Yes |
| Stub | Yes | Blocked | Blocked | ABR injects default | No |
| Totally stubby | Blocked | Blocked | Blocked | ABR injects default | No |
| NSSA | Yes | Blocked (uses Type 7) | Blocked | Optional | Yes (via Type 7) |
| Totally NSSA | Blocked | Blocked (uses Type 7) | Blocked | ABR injects default | Yes (via Type 7) |
area X range aggregates intra-area prefixes into
one Type 3 (inter-area); summary-address on an ASBR aggregates externals into one Type 5.
Summarization shrinks LSDBs and hides flaps behind the summary.default-information originate makes an ASBR advertise a
default route (Type 5) into normal areas; stub/totally-stubby ABRs inject it automatically.When a route is redistributed into OSPF at an ASBR, it becomes an external route with one of two metric types:
| E2 (default) | E1 | |
|---|---|---|
| Metric seen by remote routers | Only the external metric (fixed, set at the ASBR) | External + internal cost to reach the ASBR |
| Changes across the domain? | No — same everywhere | Yes — grows with distance to the ASBR |
| Best for | Single exit / don't care about internal cost | Multiple ASBRs — picks the closest exit |
reference-bandwidth uniformly.