L3 · igp · reviewed
OSPFv2
Open Shortest Path First Version 2
Each router floods a description of its links, then independently computes the same shortest-path tree — so the forwarding tables agree without exchanging routes.
Presenter modeEmbed this figure
Why it exists
Distance-vector protocols exchanged routes and learned about a failure from a neighbour who might themselves be using a looped path. Count-to-infinity was not a corner case; it was the way the information moved.
Link-state inverts the contract. Each router floods a description of its own links, everyone computes the same tree, and a failure is a missing LSA rather than a rumour. OSPF is that idea, specialised for IP, with areas so the database does not have to be the entire AS. Brief history of link-state routing technologyRFC 2328 · INTERNET STANDARD · April 1998
The area is the feature. Without it, every Router-LSA in the AS is in every database, and a flap anywhere runs SPF everywhere.
Down to Full on a broadcast segment
Three routers share a LAN. They elect a DR and a BDR, become fully adjacent only to those two, and flood Router-LSAs so every LSDB matches.
Three routers on one Ethernet segment, OSPF just enabled. Every neighbor table is empty. Nothing has been elected, and nothing has been flooded. R1 · 1.1.1.1: Neighbor state Down. R2 · 2.2.2.2: Neighbor state Down. Broadcast segment. R3 · 3.3.3.3: Neighbor state Down.
- Link
- Blocking
- Packet in flight
- Discarded
- Emphasis
Text equivalent of this diagram
| Element | Kind | State |
|---|---|---|
| R1 · 1.1.1.1 | router | Neighbor state: Down |
| R2 · 2.2.2.2 | router | Neighbor state: Down |
| Broadcast segment | switch | — |
| R3 · 3.3.3.3 | router | Neighbor state: Down |
| R1 · 1.1.1.1 — Broadcast segment | link | up · pri 1 |
| R2 · 2.2.2.2 — Broadcast segment | link | up · pri 1 |
| R3 · 3.3.3.3 — Broadcast segment | link | up · pri 1 |
Three routers on one Ethernet segment, OSPF just enabled. Every neighbor table is empty. Nothing has been elected, and nothing has been flooded.
What changed
- R1 · 1.1.1.1: Neighbor state → Down
- R2 · 2.2.2.2: Neighbor state → Down
- R3 · 3.3.3.3: Neighbor state → Down
- No DR yet
How it works
Neighbors start Down. A Hello moves them to Init; seeing yourself in a Hello moves them to 2-Way. On a point-to-point link that is enough to become adjacent. On a broadcast segment, only the DR and BDR go further with each neighbor; two DROTHERs stay in 2-Way forever, which is correct. Neighbor statesRFC 2328 · INTERNET STANDARD · April 1998
The DR is elected on priority, then Router ID, from the Hellos on the segment. A router that already lists itself as DR is preferred over one that does not, which is why a latecomer with priority 255 does not take over. The BDR exists so that a DR failure does not restart every adjacency on the LAN. Electing the Designated RouterRFC 2328 · INTERNET STANDARD · April 1998
Adjacency is Database Description, then Link State Request, then Full. The Interface MTU lives in the DBD, not the Hello, which is why a jumbo-to-standard pair looks healthy until ExStart and then never leaves it. Receiving Database Description PacketsRFC 2328 · INTERNET STANDARD · April 1998
The LSDB is typed. Router-LSAs (1) and Network-LSAs (2) stay in the area. Summary-LSAs (3, 4) are what an ABR injects into an area about somewhere else. AS-external-LSAs (5) flood the AS except into stub and NSSA. NSSA uses Type-7 inside the area and translates to Type-5 at the ABR. Opaque 9/10/11 are scoped to link, area, or AS. LS typeRFC 2328 · INTERNET STANDARD · April 1998
SPF runs on the Router- and Network-LSAs of one area, then attaches inter-area and external destinations to that tree. Two routers with the same LSDB compute the same next hops. That is the whole protocol. Calculating the shortest-path tree for an areaRFC 2328 · INTERNET STANDARD · April 1998
A stub area is not a smaller drawing of area 0. It is a filter on flooding. If Type-5 is visible inside it, the area is not stub — or the device is not doing what the configuration claims. Supporting stub areasRFC 2328 · INTERNET STANDARD · April 1998
Try it
Elect a DR and BDR
Give R3 a higher priority after R1 is already DR, then switch to a cold start and watch the same numbers produce the opposite result.
DR: R1 · BDR: R2
- bdrAmong routers that already list themselves as BDR, R2 wins (priority 1, Router ID 2.2.2.2).
- drRouters already listing themselves as DR are preferred, even against a higher-priority latecomer that has not claimed the role. R1 wins (priority 1, Router ID 1.1.1.1).
- resultDR is R1, BDR is R2.
| Router | Router ID | Priority | Role |
|---|---|---|---|
| R1 | 1.1.1.1 | 1 | dr |
| R2 | 2.2.2.2 | 1 | bdr |
| R3 | 3.3.3.3 | 255 | drother |
Run SPF
Change a link cost and step through the candidate list. A router joins the tree when it is the cheapest candidate, and nothing added later can make it cheaper.
R1 is the root, so it starts on the tree at cost 0.
- R2 enters the candidate list at 10, through R1.
- R4 enters the candidate list at 10, through R1.
| Router | Cost | Through |
|---|---|---|
| R2 | 10 | R1 |
| R4 | 10 | R1 |
| Destination | Cost | Next hop |
|---|---|---|
| R2 | 10 | R2 |
| R3 | 20 | R2 |
| R4 | 10 | R4 |
| R5 | 20 | R4 |
| R6 | 30 | R2 |
Change the area type
Pick stub, NSSA or a Cisco totally-stubby variant and watch which LSA types are actually withheld.
A stub area refuses AS-external-LSAs. The ABR injects a Type-3 default instead. Type-4 is omitted because it exists only to reach an ASBR.
| Type | Name | Flooded here? | Why |
|---|---|---|---|
| 1 | Router-LSA | Yes | Router-LSAs describe this area’s routers and stay inside it. |
| 2 | Network-LSA | Yes | Network-LSAs describe this area’s multi-access segments and stay inside it. |
| 3 | Summary-LSA (network) | Yes | Inter-area prefixes still enter as Type-3, plus a default from the ABR. |
| 4 | Summary-LSA (ASBR) | No | Type-4 is not originated into a stub area: there are no Type-5 destinations to reach through an ASBR. |
| 5 | AS-external-LSA | No | RFC 2328 section 3.6: AS-external-LSAs are not flooded into stub areas. |
| 7 | NSSA-LSA | No | Type-7 is an NSSA mechanism, not a stub-area one. |
| 9 | Opaque-LSA (link-local) | Yes | Type-9 is link-local. |
| 10 | Opaque-LSA (area-local) | Yes | Type-10 still floods inside the stub area. |
| 11 | Opaque-LSA (AS-scope) | No | Type-11 has AS flooding scope, so it is withheld from stub areas the same way Type-5 is. |
On the wire
Constructed examples, encoded from the field table below them — not captured traffic.
- IPv4
- Protocol 89. Destination 224.0.0.5 (AllSPFRouters) on a broadcast segment. RFC 2328
- OSPF packet header
- Version, type, length, Router ID, Area ID, checksum and authentication. RFC 2328
- Hello body
- Network mask, HelloInterval, options, priority, RouterDeadInterval, DR and BDR. RFC 2328
Configure it
router ospf 1 router-id 1.1.1.1Process 1 is a local identifier, not an area and not a Router ID. The Router ID is set explicitly so a cloned image cannot elect two boxes as the same originator.
Common mistake: Leaving Router ID to the highest loopback. Cloning a VM then produces duplicate Router-LSAs and an LSDB that cannot describe both devices.
RFC 2328 §12.4.1
interface GigabitEthernet0/0 ip address 192.0.2.1 255.255.255.252 ip ospf 1 area 0 ip ospf network point-to-pointPuts the link in area 0 and skips DR election. Broadcast is the default on Ethernet and would wait out the Wait Timer for a DR that a p2p link will never need.
Common mistake: Leaving network type at broadcast. Neighbors still form, but they elect a DR and spend 40 seconds doing it.
RFC 2328 §9.1
ip mtu 1500Pins the IP MTU so the Database Description Interface MTU matches the neighbour. This is the field ExStart actually checks.
Common mistake: Setting `ip ospf mtu-ignore` instead of matching MTU. Adjacency comes up; large packets still drop.
RFC 2328 §10.6
Verify
show ip ospf neighbor- The neighbor is Full, network type POINT_TO_POINT, and no DR/BDR is listed.
show ip ospf interface GigabitEthernet0/0- Hello 10, Dead 40, network type POINT_TO_POINT, MTU 1500.
Caveats
- IOS-XE default Hello/Dead on broadcast and p2p is 10/40. Mixing a p2p interface with an NBMA default of 30/120 prevents adjacency.
When it breaks
Symptom first, because that is what you have when it happens.
show ip ospf neighbor stuck in EXSTART or EXCHANGE. Hellos increment. Ping works.
Narrow it down
- Compare IP MTU on both sides of the link, not just Layer-2 MTU.
- Debug or capture Database Description packets and read Interface MTU.
- Confirm the network type is what you think — a virtual link sets MTU 0 on purpose.
Cause
The DBD Interface MTU is larger than the receiver will accept, so RFC 2328 section 10.6 discards the packet and master/slave never completes.
Fix
Match the IP MTU. `ip ospf mtu-ignore` only hides the symptom and leaves a forwarding mismatch.
Receiving Database Description PacketsRFC 2328 · INTERNET STANDARD · April 1998Neighbors never leave Down, or flap every few seconds. The link is up.
Narrow it down
- Read HelloInterval and RouterDeadInterval in a captured Hello, not in the running-config you think is there.
- Check both directions. One side at 10/40 and the other at 30/120 is the NBMA/broadcast mix-up.
Cause
HelloInterval or RouterDeadInterval differ, so each side ignores the other’s Hello.
Fix
Make the timers match on the segment. Do not mix broadcast and NBMA defaults on one link.
Receiving Hello PacketsRFC 2328 · INTERNET STANDARD · April 1998One side shows a neighbor, the other does not. Or both ignore each other on a link you cabled today.
Narrow it down
- Compare Area ID in the OSPF header of the Hello.
- On IOS, check whether the `network` statement or the interface `ip ospf` statement actually placed the link in the area you intended.
Cause
Area ID mismatch. The packet is dropped in RFC 2328 section 8.2 before a neighbor structure is created.
Fix
Put both interfaces in the same area. An ABR is a router in two areas, not a link in two areas.
Receiving protocol packetsRFC 2328 · INTERNET STANDARD · April 1998Adjacency never forms on the ABR-to-stub link. Hellos are visible in a capture.
Narrow it down
- Compare the E-bit in the Hello Options field.
- Confirm `area N stub` is present on every router in that area, including the ABR.
Cause
The E-bit must match. A stub router clears it; a normal router sets it. RFC 2328 section 10.5 rejects the Hello.
Fix
Configure stub (or NSSA) on every router in the area. The ABR needs the same statement for that area.
Receiving Hello PacketsRFC 2328 · INTERNET STANDARD · April 1998SPF churn, LSAs that bounce, and a Router ID you recognise belonging to the wrong box.
Narrow it down
- show ip ospf | include ID on every router in the area.
- Look for a Router-LSA whose advertising router is yours but whose links are not.
Cause
Two routers originated Type-1 with the same Router ID. Sequence numbers fight, and the LSDB cannot describe both sets of links.
Fix
Set Router IDs explicitly. Do not leave them to the highest loopback on a fleet cloned from one image.
Router-LSAsRFC 2328 · INTERNET STANDARD · April 1998A stub area’s LSDB contains Type-5, or it contains no default and no externals.
Narrow it down
- show ip ospf database on a non-ABR in the area.
- Confirm the ABR has `area N stub` and is originating 0.0.0.0/0 as Type-3.
Cause
Either the area is not actually stub (so Type-5 is expected) or the ABR is not injecting a default (so the stub has nowhere to send externals).
Fix
Make the area type consistent, and confirm the ABR originates the stub default.
Supporting stub areasRFC 2328 · INTERNET STANDARD · April 1998
Design notes
Point-to-point on Ethernet links in a spine-leaf underlay skips DR election entirely. Two routers, one adjacency, no Wait Timer, no DROTHER. Broadcast is the wrong network type on a link that will never have a third router. Interface statesRFC 2328 · INTERNET STANDARD · April 1998
The default reference bandwidth is 100 Mb/s, so every interface faster than that costs 1. Raising it is a domain-wide change: do it on every router or SPF will prefer a “cheap” gigabit path over a ten-gigabit path that still costs 1.
NSSA exists because a stub area cannot originate externals. A site that must redistribute and also refuse Type-5 from the backbone is an NSSA, not a stub with an exception. Proposed SolutionRFC 3101 · PROPOSED STANDARD · January 2003
Totally stubby and totally NSSA are Cisco refinements. They suppress Type-3 as well. They are useful; they are not in RFC 2328, and the atlas labels them that way.
Misconceptions
- “Traffic goes through the DR.”
- The DR is a flooding hub. It originates the Network-LSA and is the adjacency hub on the LAN. Forwarding follows the shortest-path tree, which may not even touch the DR. The Designated RouterRFC 2328 · INTERNET STANDARD · April 1998
- “Raising ip ospf priority takes over the DR immediately.”
- Not unless the current DR disappears. Section 9.4 prefers routers that already list themselves as DR. Clear the incumbent, or wait for it to die, or clear OSPF on it. Electing the Designated RouterRFC 2328 · INTERNET STANDARD · April 1998
- “Areas are just a way to draw the diagram in pieces.”
- An area is a flooding domain for Router- and Network-LSAs. Type-5 either enters or it does not, based on area type. If the LSDB in area 1 contains every Type-1 in the AS, you do not have areas; you have labels. Splitting the AS into AreasRFC 2328 · INTERNET STANDARD · April 1998
- “Every OSPF neighbor should be Full.”
- On a broadcast segment, DROTHER–DROTHER stays 2-Way. That is the adjacency graph working. Clearing it to force Full is how people accidentally change network type and elect a DR on a p2p link. The graph of adjacenciesRFC 2328 · INTERNET STANDARD · April 1998
More walkthroughs
Stuck in ExStartfailure
Two routers on a point-to-point link exchange Hellos happily, then hang in ExStart. The Database Description packet carries an MTU the other side will not accept.
Hellos agree: same area, same mask, same 10/40 timers, same E-bit. The neighbor state moves through Init to ExStart. Operators looking only at Hello counters will say OSPF is fine. R1 · MTU 1500: Neighbor ExStart. R2 · MTU 9000: Neighbor ExStart.
- Link
- Blocking
- Packet in flight
- Discarded
- Emphasis
Text equivalent of this diagram
| Element | Kind | State |
|---|---|---|
| R1 · MTU 1500 | router | Neighbor: ExStart |
| R2 · MTU 9000 | router | Neighbor: ExStart |
| R1 · MTU 1500 — R2 · MTU 9000 | link | up · point-to-point |
Hellos agree: same area, same mask, same 10/40 timers, same E-bit. The neighbor state moves through Init to ExStart. Operators looking only at Hello counters will say OSPF is fine.
What changed
- Hello: R1 · MTU 1500 → R2 · MTU 9000
- Hello: R2 · MTU 9000 → R1 · MTU 1500
- R1 · MTU 1500: Neighbor → ExStart
- R2 · MTU 9000: Neighbor → ExStart
- Emphasis on R1 · MTU 1500 ↔ R2 · MTU 9000
A stub area is a flooding boundarydesign-choice
An ASBR originates a Type-5. Area 0 receives it. Area 1 is stub, so the ABR withholds the Type-5 and originates a Type-3 default instead.
The ASBR redistributes a prefix and originates a Type-5 AS-external-LSA. Type-5 has AS flooding scope: it will travel through every non-stub, non-NSSA area. ASBR · Type-5. ABR. Area 0. R3 · stub. Area 1 stub.
- Link
- Blocking
- Packet in flight
- Discarded
- Emphasis
Text equivalent of this diagram
| Element | Kind | State |
|---|---|---|
| ASBR · Type-5 | router | — |
| ABR | router | — |
| Area 0 | zone | — |
| R3 · stub | router | — |
| Area 1 stub | zone | — |
| ASBR · Type-5 — ABR | link | up · area 0 |
| ABR — R3 · stub | link | up · area 1 |
The ASBR redistributes a prefix and originates a Type-5 AS-external-LSA. Type-5 has AS flooding scope: it will travel through every non-stub, non-NSSA area.
What changed
- Emphasis: Type-5 originator
- LSA type 5: ASBR · Type-5 → ABR
Terms
- Router-LSA
- Type 1. Every router originates one per area, listing its links in that area. In OSPFv2 it also carries stub prefixes; in OSPFv3 it does not.
- Designated Router
- On an OSPF multi-access segment, the router that originates the Network-LSA and with which every other router becomes fully adjacent. A higher-priority latecomer does not take over.
- ExStart
- The neighbor state in which two routers elect a master and slave by exchanging empty Database Description packets. Interface MTU is checked here, not in Hello.
- Stub area
- An OSPF area that does not flood AS-external-LSAs. The ABR injects a Type-3 default instead. Type-4 is omitted because it exists only to reach an ASBR.
- LS age
- Seconds since the LSA was originated. At 3600 seconds (MaxAge) it is flushed. Flooding prefers the younger of two copies with the same sequence.