OSPF Complete Guide 60pages
OSPF Complete Guide 60pages
OSPF
Open Shortest Path First
LSA Types 1-11 & Link-State Database Route Summarisation & Redistribution
OSPF
OSPF Areas: Backbone, Stub, NSSA & More
OSPF Packet Types & Header Structure Real-World Design Best Practices
Table of Contents
1. Introduction to OSPF
› 1.1 What is OSPF?
› 1.2 History & Standards
› 1.3 OSPF vs Other IGPs
› 1.4 When to Use OSPF
2. OSPF Fundamentals
› 2.1 Link-State vs Distance-Vector
› 2.2 Three Databases
› 2.3 OSPF Operation Overview
› 2.4 Router ID
5. DR/BDR Election
› 5.1 Why DR/BDR?
› 5.2 Election Process
› 5.3 Multicast Addresses
› 5.4 Network Types
8. SPF Algorithm
› 8.1 Dijkstra Explained
› 8.2 OSPF Cost & Metric
› 8.3 Equal-Cost Multipath
› 8.4 SPF Timers
9. OSPF Configuration
› 9.1 Basic OSPFv2
1 Introduction to OSPF
What it is, why it exists, and when to use it
OSPF (Open Shortest Path First) is an interior gateway protocol (IGP) based on the link-state routing
algorithm. It is defined by the IETF in RFC 2328 (OSPFv2, for IPv4) and RFC 5340 (OSPFv3, for IPv6).
OSPF is the most widely deployed IGP in enterprise and service-provider networks worldwide due to its
open standard nature, scalability, rapid convergence, and rich feature set. Unlike distance-vector protocols
such as RIP, OSPF routers maintain a complete map of the network and independently compute the
shortest path to every destination.
OSPF belongs to the link-state family of routing protocols. Every OSPF router describes its directly
connected links in Link State Advertisements (LSAs) and floods them throughout the area. All routers
within an area therefore accumulate an identical Link-State Database (LSDB) — essentially a complete
map of that area. Each router then independently runs Dijkstra's Shortest Path First (SPF) algorithm to
compute a loop-free shortest-path tree to every destination, placing the best routes into its Routing
Information Base (RIB).
OSPFv2 RFC 2328 1998 Current standard for IPv4 — still in use
• Complex topology with redundant links • Very large flat topology without hierarchy
• Hierarchical design required (areas) • Operator prefers IS-IS (common in ISP cores)
2 OSPF Fundamentals
Core concepts every OSPF engineer must know
What is shared LSAs — full topology info Routes — only best paths to each dest
Database Identical LSDB on all routers Each router has unique view
Every OSPF router maintains three separate databases. Understanding these is fundamental to OSPF
operation and troubleshooting:
Neighbour Table Adjacency DB List of directly adjacent OSPF routers with show ip ospf neighbor
state
Link-State DB LSDB / Topology All LSAs collected — complete area show ip ospf database
DB topology map
Routing Table RIB / Forwarding Best paths computed by SPF algorithm show ip route ospf
DB
OSPF operation follows a well-defined sequence of events from startup to full routing convergence:
Step 1 Configure OSPF Enable OSPF process, assign Router ID, advertise networks.
Step 2 Send Hello Packets Hellos sent every HelloInterval on all OSPF interfaces ([Link]).
Step 3 Discover Neighbours Routers receiving Hellos verify parameters and record neighbours.
Step 5 Exchange LSDB DBD packets exchange LSA headers; LSR/LSU/LSAck used to sync
databases.
Step 6 Build LSDB All routers in area receive identical set of LSAs.
Step 7 Run SPF Dijkstra algorithm computes shortest-path tree rooted at self.
Step 8 Install Routes Best paths installed into RIB; router is now fully converged.
Step 9 Maintain State Hellos keep neighbours alive; LSAs refreshed every 30 min; triggered
updates on change.
2.4 Router ID
The Router ID (RID) is a 32-bit number that uniquely identifies an OSPF router within the OSPF domain. It
is formatted like an IPv4 address but is NOT necessarily a routable address. OSPF uses the Router ID in
LSAs, neighbour relationships, and DR/BDR elections.
■ Best Practice
Always manually configure the Router ID using a Loopback address. This ensures stability — if a physical
interface goes down, the RID remains unchanged. Changing the RID requires clearing the OSPF process
('clear ip ospf process') which causes a brief reconvergence.
OSPF communicates using five distinct packet types, all carried directly in IP with protocol number 89. All
packets share a 24-byte common header.
The Hello packet is the most fundamental OSPF message. It is sent periodically on all OSPF-enabled
interfaces and serves three critical purposes: neighbour discovery, neighbour keepalive, and DR/BDR
election participation. Two routers can only form a neighbour relationship if their Hello parameters
match.
Neighbour List Router IDs from which Hellos have been received No
2 Database Description Unicast Summarises the sender's LSDB by listing LSA headers. Used
(DBD) during ExStart and Exchange states to determine which LSAs
need to be requested.
3 Link-State Request (LSR) Unicast Requests specific LSAs from a neighbour. Sent when a router
receives a DBD containing LSA headers it does not have or that
are newer than its own.
4 Link-State Update (LSU) Uni/Multi Carries one or more complete LSAs. Sent in response to an
LSR, or triggered by topology changes. Flooded using
[Link] or [Link].
5 LS Acknowledge (LSAck) Uni/Multi Acknowledges receipt of LSUs. OSPF uses explicit ACKs for
reliable LSA flooding. Can be delayed (batched) or immediate.
Router A Router B
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
[DISCOVER] ■■■ Hello ([Link]) ■■■■■■■■■■■■■■■■■■■■■■■
■■■ Hello ([Link]) ■■■■■■■■■■■■■■■■■■■■■■ [INIT→2-WAY]
OSPF neighbours progress through up to eight states before reaching Full adjacency. Each state
represents a phase in the negotiation and database synchronisation process:
Initial state. No Hello packets have been received from this neighbour. The neighbour may
Down
have timed out (Dead interval expired) or never been seen.
NBMA networks only. A Hello has been sent to the manually configured neighbour but no
Attempt
reply received yet. Applies to hub-spoke Frame Relay configurations.
A Hello has been received from this neighbour but our own Router ID does not yet appear in
Init
the neighbour's Hello packet. One-way communication established.
Master and Slave exchange DBD packets containing LSA headers, giving each router a
Exchange
summary of the neighbour's LSDB. Routers build a list of LSAs they need.
LSR packets sent to request missing or outdated LSAs. Neighbour responds with LSU
Loading
packets containing the full LSAs. LSAck packets acknowledge receipt.
LSDBs are fully synchronised. This is the desired operational state. All adjacencies should
Full be Full in a healthy OSPF network. Routes can only be computed once adjacencies reach
Full.
The following parameters MUST match between two routers for an OSPF adjacency to form:
Subnet & Mask Both sides must be on same subnet No Hello exchange
Area Type Flags Stub flag in options byte must match Stuck in ExStart
Hello packets are sent using IP multicast [Link] (AllSPFRouters) on broadcast and P2P links. On
NBMA networks, they are unicast to configured neighbours. The Hello packet contains the sending router's
neighbour list — this is how 2-Way state is established (seeing your own RID in a received Hello).
During ExStart, routers negotiate who is Master and who is Slave by exchanging empty DBD packets. The
router with the higher Router ID wins and becomes Master. The Master controls the DBD sequence
numbers and drives the exchange. The Slave only sends DBD packets in response to the Master's, using
the Master's sequence number.
5 DR / BDR Election
Reducing adjacencies on multi-access networks
On a broadcast multi-access network (e.g. Ethernet with 5 routers), without a DR/BDR every router
would form a Full adjacency with every other router. With n routers, that means n(n-1)/2 full adjacencies
— for 10 routers, that is 45 adjacencies, each generating LSA flooding. This creates excessive network
overhead and CPU load.
R1 ■■■■ R2 R1 R2
| \ / | \ /
| \/ | DR/BDR
| /\ | / \
R4 ■■■■ R3 R4 R3
| |
R5 R5
Every pair = Full adjacency All Full with DR & BDR only
The DR (Designated Router) acts as the central LSA collection and distribution point. All DROther routers
form Full adjacencies only with the DR and BDR. DROther-to-DROther relationships stay at 2-Way.
• Highest OSPF Interface Priority wins DR. Priority range: 0–255. Default: 1.
• If priorities are equal, the router with the highest Router ID becomes DR.
• Router with second-highest priority/RID becomes BDR.
• Priority 0 = the router is ineligible for DR/BDR (never participates in election).
• Election is non-preemptive — once elected, the DR remains even if a router with a higher priority joins.
The only way to force re-election is to clear the OSPF process on the current DR.
[Link] AllSPFRouters All OSPF routers Hello packets; LSU from DR/BDR to all
routers
FF02::5 OSPFv3 All OSPF All OSPFv3 rtrs OSPFv3 equivalent of [Link]
Network type is configured per interface: ip ospf network <type>. Choose carefully — mismatched network types
between peers will prevent adjacency formation.
Link State Advertisements (LSAs) are the data records that populate the OSPF LSDB. Each LSA
describes one aspect of the network topology. Routers generate LSAs about themselves and flood them to
all routers in their area (or the entire AS for some types). Understanding LSA types is essential for
multi-area design and troubleshooting.
LS Age 2 bytes Age in seconds since origination. Max = 3600s (LSA flushed). Refreshed
every 1800s.
Options 1 byte Capability bits: E (external routing), N (NSSA), DC (demand circuit), etc.
LS Type 1 byte LSA type 1–11 (OSPFv2); upper bits encode flooding scope in OSPFv3
Link State ID 4 bytes Depends on type: Type-1=Router ID, Type-2=DR IP, Type-3=Network IP,
etc.
Advertising Router 4 bytes Router ID of the router that originated this LSA
LS Checksum 2 bytes Fletcher checksum. Excludes LS Age field. Recalculated every 30 min.
Type 1 Router LSA Every router Own area Router's own links: each interface, its state,
neighbours, and cost. One per router per area.
Type 2 Network LSA DR only Own area Multi-access segment. Lists all routers
attached to the segment. Only exists when DR
is elected.
Type 3 Summary LSA (Net) ABR Other areas Network prefixes from other areas.
ABR generates one Type-3 per prefix
learned from the backbone or other
areas. Enables inter-area routing.
Type 4 Summary LSA (ASBR) ABR Other areas Reachability to an ASBR. Generated
so routers in other areas can find the
ASBR when processing Type-5 LSAs.
Contains ASBR's Router ID and cost.
Type 7 NSSA External LSA ASBR inside NSSA NSSA area only N1 and N2 (same logic as
E1/E2). Converted to Type-5
by ABR when leaving the
NSSA.
■ E1 vs E2 External Routes
E2 (default) routes keep the same metric everywhere — the external metric only. E1 routes add the
internal OSPF cost to reach the ASBR to the external metric, so the metric grows as you move farther from
the ASBR. Use E1 when you have multiple ASBRs redistributing the same routes, so routers pick the
closest ASBR. Use E2 when the external metric is the primary selection criterion.
Type 9 Link-local Single link Grace-LSA for graceful restart. Not forwarded.
Type 10 Area Single area OSPF Traffic Engineering (MPLS-TE). Carries TE attributes:
bandwidth, delay, SRLG, admin groups.
Type 11 AS-wide Entire OSPF Graceful restart signalling. Extended capability advertisement.
AS
In a flat single-area OSPF network, every router stores LSAs from every other router in the entire
network. With hundreds of routers, this creates enormous LSDBs, frequent SPF recalculations on every
topology change, and slow convergence. OSPF's area hierarchy solves this by:
AS Boundary Router ASBR Redistributes external routes into OSPF Type 1, 5 (or 7)
OSPF supports five area types with different LSA filtering capabilities:
Normal Area Receives all LSA types (1, 2, 3, 4, 5, 7). Full LSDB including all external routes. Area
0 is always a normal area. Use for areas that need full external route visibility.
Stub Area Blocks Type-5 (external) and Type-4 LSAs. ABR injects a default route (Type-3)
instead. All routers in the area must be configured as stub. Reduces LSDB
significantly. Cannot contain an ASBR.
Totally Stubby Cisco extension of Stub. Blocks Type-3, Type-4, AND Type-5 LSAs. Only Type-1, 2,
and a single default route (Type-3) remain. Only ABR needs 'no-summary'; other
routers just use 'stub'. Maximum reduction.
NSSA Not-So-Stubby Area. Blocks Type-5 LSAs but allows a local ASBR to redistribute
external routes as Type-7 LSAs. ABR converts Type-7 to Type-5 when exiting the
NSSA. Useful for branch sites with a local ISP connection.
Totally Stubby NSSA Combines NSSA (allows local ASBR) with Totally Stubby (blocks inter-area
summaries). Only default route and local external routes visible. Maximum reduction
with local ASBR.
A virtual link is a logical point-to-point connection that extends Area 0 through a transit area. It is required
when:
8 SPF Algorithm
How Dijkstra computes the shortest-path tree
After building the LSDB, each router runs Dijkstra's algorithm to construct a Shortest Path Tree (SPT)
with itself as the root. The SPT gives the best next-hop and cost to every destination in the area. OSPF
triggers SPF when it receives a new or changed LSA.
• SPT Set (TENT → TREE): Nodes for which the shortest path is confirmed
• Candidate List (TENT): Nodes discovered but not yet confirmed
Algorithm execution:
Init Add self to SPT with cost 0. All other nodes have cost ∞.
Step 1 Add all directly connected neighbours to Candidate List with their link cost.
Step 2 Select the node with the LOWEST cost from Candidate List. Move to SPT.
For each neighbour of the newly added SPT node: calculate total cost = (SPT node cost) + (link cost).
Step 3
If neighbour not in SPT and new cost < current candidate cost, update it.
Result SPT contains the shortest path to every node. Extract next-hop from the tree.
OSPF's metric is called cost. The cost of a path is the sum of the costs of all outgoing interfaces along
the path. By default, cost is derived from interface bandwidth:
The default reference bandwidth is 100 Mbps, which creates a well-known problem — FastEthernet (100
Mbps) and GigabitEthernet (1 Gbps) both get cost 1, making them indistinguishable:
When SPF finds two or more paths with identical cost, OSPF installs all of them in the routing table,
creating Equal-Cost Multipath (ECMP). By default, Cisco IOS supports up to 4 ECMP paths (maximum
16 with 'maximum-paths' command):
OSPF does not run SPF immediately when it receives an LSA. Throttle timers prevent CPU overload
during network instability:
SPF Delay 5000 ms Delay after receiving LSA before running first SPF
9 OSPF Configuration
Complete IOS/IOS-XE configuration reference
Interface-level OSPF configuration is preferred over the network command because it gives more granular
control and is easier to read:
! Area 0 interface
ABR(config)# interface GigabitEthernet0/0
ABR(config-if)# ip ospf 1 area 0
! Area 1 interface
ABR(config)# interface GigabitEthernet0/1
ABR(config-if)# ip ospf 1 area 1
show ip ospf neighbor detail Detailed: dead timer, options, DR/BDR info, interface
show ip ospf Process info: Router ID, area count, SPF statistics
show ip ospf interface brief Quick: which interfaces run OSPF, their area, DR/BDR,
cost
show ip ospf interface Gi0/0 Detailed interface: network type, timers, auth, DR/BDR
show ip ospf border-routers Routes to ABRs and ASBRs within the area
show ip ospf statistics SPF run count, last SPF trigger, LSA counts
The most important metric tuning command. Without this, FastEthernet, GigEthernet, and 10GigE all have
the same cost (1), making OSPF unable to differentiate high-speed paths:
Override the auto-calculated cost on a specific interface. Useful when you want to prefer one path over
another regardless of bandwidth:
The offset-list adds a fixed metric offset to routes matching an access-list. Useful to make specific
redistributed routes less preferred:
Inter-area summarisation is configured on the ABR and reduces the number of Type-3 LSAs sent into
the backbone or other areas. All specific prefixes within the summary range are suppressed; only the
aggregate is advertised:
Summarise external routes before they are redistributed into OSPF. Reduces Type-5 LSA count across
the entire AS:
When redistributing routes from another protocol or source into OSPF, you must specify a seed metric.
Without it, redistributed routes may have metric 0 and be ignored:
! Redistribute BGP
ASBR(config-router)# redistribute bgp 65000 subnets metric 20 metric-type 2
! Redistribute RIP
ASBR(config-router)# redistribute rip subnets metric 30
12 OSPF Authentication
Securing OSPF neighbourhoods against unauthorized routers
OSPF authentication prevents unauthorized routers from forming adjacencies and injecting false routing
information. Authentication is configured per-interface or per-area. Three modes are supported:
MD5 2 Moderate MD5 hash of packet + key, includes Yes (minimum for
sequence number to prevent replay production)
! Enable MD5 auth for entire area (all interfaces in area must have key)
Router(config-router)# area 0 authentication message-digest
RFC 5709 provides cryptographically strong authentication using HMAC-SHA algorithms. It uses a key
chain for easy key rotation:
! Verify
Router# show ip ospf interface GigabitEthernet0/0 | include auth
OSPFv3 (RFC 5340) is a major redesign of OSPF to support IPv6. It is NOT backward compatible with
OSPFv2. Key architectural change: network addresses are removed from Router and Network LSAs.
Address information is carried in new LSA types. OSPFv3 runs directly over IPv6 link-local addresses.
New LSA Types Types 1–7, 9–11 Adds Type-8 (Link LSA), Type-9
(Intra-Area-Prefix LSA)
Config Style network command or per-interface Per-interface (ipv6 ospf process area)
Type 8 Link LSA Every router Link-local address and list of IPv6 prefixes on the link.
Flooded link-local scope only.
Type 9 Intra-Area-Prefix Router or DR IPv6 prefixes associated with a router (stub links) or a
transit network. Replaces prefix info that was in
Type-1/2 for OSPFv2.
! Verification
Router# show ipv6 ospf neighbor
Router# show ipv6 ospf database
Router# show ipv6 route ospf
! Enable AF on interface
Router(config-if)# ospfv3 1 ipv4 area 0
Router(config-if)# ospfv3 1 ipv6 area 0
LSA Throttle — hold 5000 ms 5000 ms timers throttle lsa 0 5000 5000
SPF Holdtime 10000 ms 10000 ms timers throttle spf 200 1000 10000
The fast hello feature reduces the dead interval to 1 second, sending multiple Hellos per second:
BFD (RFC 5880) is a lightweight protocol that provides sub-millisecond to sub-second failure detection,
independently of any routing protocol. OSPF delegates failure detection to BFD and reacts immediately
when BFD signals a link failure:
! Verify
Router# show bfd neighbors
Router# show bfd neighbors details
Throttling prevents CPU overload during network instability. The exponential backoff increases the hold
time after each consecutive event:
LFA (RFC 5286) pre-computes a backup next-hop for every prefix. When the primary path fails, traffic
immediately switches to the LFA without waiting for SPF, achieving near-zero packet loss:
! Interface-level
Router(config-if)# ip ospf fast-reroute per-prefix
15 Troubleshooting OSPF
Systematic diagnosis from adjacency to routing issues
• Layer 1 — Physical/Data Link: Check interface is up/up. Check cable, speed, duplex.
• Layer 2 — IP Connectivity: Ping neighbour IP. Check same subnet, correct mask.
• Layer 3 — OSPF Parameters: Check area ID, timers, auth, stub flags match.
• Layer 4 — Neighbour State: Is neighbour in table? What state? Use show ip ospf neighbor.
• Layer 5 — Database: Check LSDB has expected LSAs. Missing routes = missing LSAs.
• Layer 6 — SPF/Routes: Are routes in routing table? Check cost, filter, summarisation.
show ip ospf neighbor detail Check dead time counting down (not stuck), options match,
interface.
show ip ospf interface Gi0/0 Network type, Hello/Dead intervals, Auth type, DR/BDR,
cost.
show ip ospf interface brief Quick check of all OSPF interfaces — state, cost, nbrs.
show ip ospf database Count LSAs. Missing type = area type or filter issue.
show ip ospf database router self-originate Your own Type-1 LSA — verify all links advertised.
show ip ospf database external Type-5 LSAs — external routes. Should be empty in stub.
show ip ospf flood-list interface Gi0/0 LSAs waiting to be flooded — high count = congestion.
■ Debug Warning
Debug commands generate massive console output and can crash busy routers. Always use 'terminal
monitor' to see output on VTY. Set a time limit: 'debug ip ospf events' then check for 30 seconds, then
'undebug all'. Never run debug on a core router during business hours.
Neighbour stuck in Init Unicast Hello not received back Check ACL blocking; check NBMA
neighbour statement
Stuck at 2-Way (not Full) DROther-to-DROther on broadcast Normal — not a problem unless should be
Full
Stuck in ExStart/Exchange MTU mismatch (most common) ip ospf mtu-ignore OR match MTU both
sides
Neighbour keeps flapping BFD/Dead interval too low, unstable Increase timers; check physical layer;
link check QoS
Routes missing (O IA) ABR not advertising; stub blocks it Check area config; remove filter; check
area type
Type-5 in stub area Router not configured as stub Add 'area X stub' to router config
Wrong next-hop / suboptimal Cost not tuned; reference BW auto-cost reference-bandwidth on all
mismatch routers
OSPF adjacency drops at SNMP/NMS traffic causing load Check process CPU; tune timers; check
night QoS
High CPU — SPF thrashing Flapping link generating LSAs Fix physical issue; tune SPF/LSA throttle
timers
'OSPF: not in valid state' log Duplicate Router ID Change router-id on one router; clear ospf
process
Routes installed then LSA MaxAge — routing loop / filter Check for duplicate LSAs; check
removed distribute-list
No routes despite Full adj SPF not running; route filtered check distribute-list, area filter-list, ACL
OSPF-TE extends OSPF to carry Traffic Engineering attributes using Opaque LSAs (Type-10). These
attributes allow RSVP-TE to compute constrained paths for MPLS LSPs based on bandwidth, delay,
admin groups, and SRLG:
TE Attribute Description
TE Metric Separate metric for TE path computation (can differ from OSPF cost)
Admin Group Colour/affinity bits — group links for policy-based path selection
SRLG Shared Risk Link Group — links sharing same physical risk (same fibre)
When a router restarts its control plane (RP failover, process restart), OSPF normally tears down all
adjacencies and reconverges. Graceful Restart allows the router to restart without affecting forwarding:
NSF (Non-Stop Router signals restart in Grace-LSA. Neighbours act nsf (Cisco) OR
Forwarding) as helpers and continue forwarding. Router graceful-restart
re-establishes adjacencies quickly.
NSR (Non-Stop Routing) Standby RP maintains full OSPF state. Switchover is nsf ietf OR nsr
transparent — no restart signalling needed, no helper (platform-specific)
required.
Graceful Restart Grace Time allowed to complete restart. Default 120s. graceful-restart
Period Should be less than Dead Interval on helpers. grace-period 60
SR-OSPF (RFC 8665) uses OSPF Opaque LSAs to advertise Segment IDs (SIDs), enabling MPLS
forwarding without LDP or RSVP. Each router gets a Node SID; each adjacency gets an Adj-SID:
! Enable SR globally
Router(config)# segment-routing mpls
! Enable SR in OSPF
Router(config-router)# segment-routing mpls
Router(config-router)# segment-routing forwarding mpls
! Verify
Router# show ip ospf segment-routing
Router# show mpls forwarding-table
Allows a single physical interface to participate in multiple OSPF areas simultaneously. The interface
keeps its primary area assignment but also forms an adjacency in a secondary area. Used for Traffic
Engineering purposes where a link needs to appear in multiple area topologies:
Standard LFA only works when a direct neighbour provides a loop-free alternate. rLFA (RFC 7490) uses a
tunnel to a Remote LFA (P-space) node to provide backup for topologies where no direct LFA exists:
Routers per area 50–200 Depends heavily on CPU/RAM; LSA count matters more
Areas per ABR 2–4 max More areas = more LSDB copies + higher CPU
LSAs per area < 10,000 Watch 'show ip ospf' for LSDB size
Hello/Dead (BFD nets) 1/3 ms via BFD Use BFD instead of fast-hello for accuracy
• Authentication: Always enable MD5 or SHA-256 on all OSPF interfaces. Prevents rogue routers joining.
• Passive Interface: Run 'passive-interface default' and selectively enable only real OSPF links.
• Prefix Filtering: Use area filter-list or distribute-list to prevent route leakage.
• Monitoring: Alert on unexpected neighbour state changes (SNMP traps / syslog).
• Rate Limiting: Use control-plane policing (CoPP) to rate-limit OSPF traffic to CPU.
• OSPF TTL Security: 'ip ospf ttl-security hops 1' — drops OSPF packets not from direct neighbour.
Router(config-router)# ttl-security all-interfaces ! global TTL security
Router(config-if)# ip ospf ttl-security hops 1 ! interface level
• Dual ABRs per area: Always have two ABRs connecting non-backbone areas to Area 0.
• Loopback-sourced adjacencies: Use Loopback IPs for router-IDs, always reachable.
• BFD everywhere: Deploy BFD for fast failure detection on all critical links.
• NSF/NSR: Enable on all routers with redundant route processors.
• IP Fast Reroute: Deploy LFA or TI-LFA for sub-50ms traffic recovery.
• Incremental SPF: Enable 'ispf' to reduce SPF load during reconvergence.
• ECMP: Design equal-cost paths for built-in load balancing and redundancy.
Parameter Value
IP Protocol Number 89
A Hello packet is an OSPF Type-1 packet. Below is the complete byte-level layout after the 24-byte
common header:
20+ Neighbor List Variable List of Router IDs from which Hellos have been received
The Database Description (DBD) packet is used during the ExStart and Exchange states to summarise the
LSDB:
0 Interface MTU 2 bytes MTU of sending interface. Receiving router drops DBD if its own MTU is
smaller (unless mtu-ignore)
3 Flags (I/M/MS) 1 byte I=Init (first DBD), M=More (more DBDs to follow), MS=Master/Slave
8+ LSA Headers Variable 20-byte LSA headers (one per LSA being described)
4+ LSAs Variable One or more complete LSAs (each with 20-byte header + body)
Bit 1 E External Routing Capability — router can flood AS-external LSAs. MUST be 0 for stub area
routers.
Bit 3 N NSSA Capability — router supports NSSA (Type-7 LSAs). MUST be 1 in NSSA areas.
Bit 4 L LLS (Link-Local Signaling) data block present after OSPF packet
Bit 6 O Opaque LSA Capability — router can receive and store Opaque LSAs (Types 9-11)
The Router LSA describes a router's interfaces. After the 20-byte header, the body contains a list of link
descriptions. There are four link types:
The Network LSA is originated by the DR and describes the multi-access segment:
Field Description
... (repeated) One entry per router in Full state with the DR
Field Description
E bit 0=E1 metric type, 1=E2 metric type (bit in options byte)
Forwarding Address Next-hop to use for this external route. Usually [Link] (use ASBR as next-hop).
Non-zero if ASBR has an interface on the path.
External Route Tag 32-bit tag — can carry BGP AS number or policy values across OSPF
The LS Age field increments as the LSA traverses the network. When a router forwards an LSA, it
increments the age by InfTransDelay (default 1 second). The lifecycle:
A company has a headquarters (HQ) and three branch offices. The HQ connects to the internet. Design
uses Area 0 at HQ, Area 1 for North branch, Area 2 (stub) for East branch, and Area 3 (NSSA) for West
branch which has its own DSL line:
Internet
|
ASBR (HQ) — Area 0 (Backbone)
/ \ \
ABR-N ABR-E ABR-W
| | |
Area 1 (Normal) Area 2 Area 3 (NSSA)
North Branch (Stub) West Branch
East Branch + local DSL ASBR
DMVPN (Dynamic Multipoint VPN) with OSPF requires special network type configuration. The hub should
use broadcast or point-to-multipoint, and spokes use point-to-multipoint or point-to-point (per-spoke
tunnels):
Use route maps for selective redistribution with metric manipulation and tagging:
! Apply in OSPF
Router(config-router)# redistribute bgp 65000 subnets route-map BGP-TO-OSPF
Standard SPF recalculates the entire shortest-path tree even if only a small part of the topology changed.
Incremental SPF (iSPF) recalculates only the affected portion of the tree, dramatically reducing CPU
usage in large networks:
■ iSPF Impact
iSPF is most beneficial in large areas (100+ routers) where topology changes are localized. In small areas,
the overhead of incremental computation may exceed the savings. Always measure CPU before and after
enabling iSPF on production routers.
When a router is starting up, reloading, or about to go down for maintenance, it can advertise itself as a
stub router by setting all interface costs to MaxLinkMetric (65535). This causes traffic to flow around the
router until it is fully converged:
! Advertise as stub until BGP has converged (useful for Internet routers)
Router(config-router)# max-metric router-lsa on-startup wait-for-bgp
! Verify
Router# show ip ospf | include max-metric
On dial-on-demand or cost-per-packet circuits, OSPF's periodic Hello and LSA refresh traffic would cause
unnecessary dial-outs. Demand Circuits suppress periodic Hellos and LSA refreshes:
LSA pacing controls how quickly LSAs are flooded in a burst. This prevents CPU spikes and drops during
mass LSA flooding events (e.g., after a router comes online with a large LSDB):
! LSDB group pacing — interval for grouping LSA refresh/MaxAge (default: 240s)
Router(config-router)# timers pacing lsa-group 120
On ABRs, you can prevent specific Type-3 LSAs from being generated into an area using a prefix list filter:
OSPFv3 removed the built-in authentication from the packet header and instead relies on IPsec
Authentication Header (AH) or Encapsulating Security Payload (ESP) per RFC 4552:
! Area-level authentication
Router(config-rtr)# area 0 authentication ipsec spi 256 sha1 <40-hex-key>
In OSPFv3 with Address Families, you can suppress IPv4 or IPv6 prefixes from being advertised while
keeping the OSPF topology:
Command Purpose
• Dual-Stack Migration: Run both OSPFv2 (IPv4) and OSPFv3 (IPv6) simultaneously during transition.
• OSPFv3 AF Mode: Use single OSPFv3 process carrying both IPv4 and IPv6 (simplifies management).
• Router ID Required: OSPFv3 requires a manually configured Router ID (no IPv6 address for
auto-selection).
• Authentication Change: IPsec replaces built-in auth — plan IPsec key management before migration.
• LSA Type Changes: New Type-8/9 LSAs replace IPv4-embedded addresses in Type-1/2.
OSPF is monitored via the OSPF MIB (RFC 1850) and OSPFv3 MIB (RFC 5643). Key OIDs to monitor:
%OSPF-5-ADJCHG: neighbor Down: Dead timer Neighbour lost — check link, check hello/dead timers,
expired check MTU
%OSPF-5-ADJCHG: neighbor Full Adjacency formed — normal, but watch for flapping
%OSPF-4-FLOOD_WAR: router X self-originated LSA Duplicate Router ID — find and fix immediately
%OSPF-4-ERRRCV: mismatch Hello params Hello parameter mismatch — check area, timers, auth
%OSPF-3-RECV_ERR: authentication failed Auth failure — check key ID and key string
Symptom: Two routers are stuck in ExStart state. The adjacency forms to Init and 2-Way but never
progresses beyond ExStart despite correct area and timer configuration.
Diagnosis steps:
• Run 'show ip ospf neighbor detail' — look at the DR/BDR field and the dead timer.
• Run 'debug ip ospf adj' — look for DBD exchange errors.
• Check 'show interface Gi0/0' on both routers — note the MTU value.
• Common finding: Router A has MTU 1500, Router B has MTU 9000 (jumbo frames enabled).
! Evidence from debug:
OSPF: Rcv DBD from [Link] on GigE0/0, we are slave
OSPF: Nbr [Link] ignore DBD due to MTU mismatch (9000 vs 1500)
Symptom: Traffic from Site A to Site B takes one path, but return traffic from B to A takes a different path.
Users report intermittent connectivity and firewall drops.
Diagnosis:
Symptom: A router in Area 2 (configured as stub) cannot reach a network that is internal to Area 1. The
default route is present but specific routes are missing.
! Fix: Ensure both routers have same key ID and key string
Router(config-if)# ip ospf message-digest-key 1 md5 CorrectKeyHere
ABR Adjacency
Area Border Router. A router with interfaces in more A fully synchronised OSPF relationship between two
than one OSPF area. ABRs maintain separate LSDBs neighbouring routers where LSDBs are identical.
for each area and generate Type-3 and Type-4 LSAs to Adjacency means Full state has been reached.
summarize topology between areas.
Area AS
A logical grouping of OSPF routers and links. All routers Autonomous System. The collection of routers under a
in an area share an identical LSDB. Area 0 is the single administrative authority running the same routing
backbone. protocol instance.
ASBR BDR
AS Boundary Router. A router that redistributes external Backup Designated Router. Elected on multi-access
routes (from BGP, static, or other IGPs) into OSPF. segments to take over if the DR fails. Maintains full
Generates Type-5 LSAs (or Type-7 in NSSA). adjacency with all routers.
BFD Cost
Bidirectional Forwarding Detection. A lightweight OSPF's path metric. Calculated as Reference
protocol for sub-second failure detection, used by Bandwidth / Interface Bandwidth. Cumulative along a
OSPF to detect link failures faster than the Dead path.
Interval.
DR DROther
Designated Router. Elected on multi-access networks. A router on a multi-access segment that is neither DR
All other routers (DROthers) form Full adjacency only nor BDR. Forms Full adjacency only with DR and BDR;
with DR and BDR, reducing O(n²) adjacencies. 2-Way with other DROthers.
iSPF LFA
Incremental SPF. An optimisation that recalculates only Loop-Free Alternate. A pre-computed backup next-hop
the affected portion of the SPT, reducing CPU overhead that provides fast failover (IP Fast Reroute) without
for localised changes. waiting for SPF reconvergence.
LSA LSAck
Link-State Advertisement. A data record describing Link-State Acknowledgment packet. Confirms receipt of
topology information, flooded throughout the OSPF LSUs, enabling reliable flooding.
domain. 11 types defined.
LSDB LSR
Link-State Database. A complete topological map of an Link-State Request packet. Requests specific LSAs
OSPF area, built from received LSAs. All routers in an from a neighbour during the Loading state.
area have identical LSDBs.
LSU MaxAge
Link-State Update packet. Carries one or more Maximum age of an LSA — 3600 seconds (1 hour).
complete LSAs. Sent in response to LSR or triggered LSAs reaching MaxAge are flushed from all LSDBs.
by topology changes.
Metric Neighbour
OSPF's path cost. Sum of interface costs along a path. A router detected via Hello packets. A neighbour may or
Lower is preferred. See Cost. may not become a Full adjacency.
NSF NSR
Non-Stop Forwarding. Graceful restart mechanism Non-Stop Routing. High availability mechanism where
where the data plane continues forwarding during a the standby RP maintains full OSPF state, enabling
control plane restart. transparent failover.
P2P RID
Point-to-Point network type. No DR/BDR election. Router ID. A 32-bit unique identifier for an OSPF router,
10s/40s Hello/Dead. Used for serial links, PPP, GRE, formatted as an IPv4 address. Best practice: manually
MPLS LSPs. set to a Loopback IP.
RIB SPF
Routing Information Base. The routing table. OSPF Shortest Path First. The Dijkstra algorithm used by each
installs its computed best paths into the RIB. OSPF router to compute the best path tree from itself to
every destination.
For a large enterprise with 500+ routers across 20 sites, a three-tier hierarchy is recommended:
RESULT: Core routers see ~100 LSAs. Branch routers see <10 LSAs.
Modern data centers use OSPF with aggressive tuning or migrate to BGP (RFC 7938). When using
OSPF in DC:
Service providers typically prefer IS-IS for the core but OSPF is common in enterprise VPNs and PE-CE
routing:
PE-CE routing (MPLS VPN) Per-VRF OSPF instance; use DN bit to prevent loops; sham-links for backdoor
path
Core IGP Often IS-IS preferred; if OSPF: single area, aggressive BFD, TI-LFA
Internet peering BGP for external; OSPF for internal reachability to peering IPs
LSDB entries < 10,000 LSAs per area Split area, add summarisation
SPF runtime < 100ms normal, < 500ms max Enable iSPF, tune throttle timers
Memory per LSA ~200 bytes per LSA entry Check platform memory limits
CPU per SPF Varies by platform; monitor baseline iSPF, area splitting, hardware upgrade
Neighbour count < 40 per router (ideal < 10 on P2P) Use stub areas, summarise
Area count/ABR < 4 areas per ABR Add ABR routers, redesign
In MPLS VPN, when two CE sites have a backdoor link running OSPF between them, the VPN provider's
OSPF instance (via PE) appears as a higher-cost inter-area path. Without a sham-link, the customer's
backdoor link is always preferred (intra-area < inter-area). A sham-link makes the provider path appear
intra-area:
The DN (Down) bit in Type-3, Type-5, and Type-7 LSAs prevents routing loops when OSPF runs between
PE and CE routers. The PE sets the DN bit when distributing routes from the VPN backbone into the
customer OSPF. CE routers ignore LSAs with DN bit set, preventing re-advertisement back into the VPN.
The Forwarding Address (FA) in Type-5/7 LSAs tells other routers where to forward traffic for external
destinations. Non-zero FA conditions:
SR-OSPF uses OSPF to distribute Segment IDs (SIDs) via Opaque LSAs. Two types of SIDs: