← all cheatsheets
OSPF

OSPF

Open Shortest Path First

1. What is OSPF?2. How OSPF Works3. Characteristics4. Areas & Hierarchy5. Neighbor States6. Timers (Default)7. Packet Types8. LSA Types9. Cost Calculation10. DR & BDR11. Configuration12. Important Commands13. Authentication14. Advanced Concepts

1. What is OSPF?

OSPF is an open standard Link-State IGP that uses Dijkstra's SPF algorithm. IP protocol 89, multicast 224.0.0.5 (AllSPFRouters) and 224.0.0.6 (AllDRouters).

2. How OSPF Works

  • Routers exchange LSAs to build a complete topology map
  • SPF algorithm computes shortest path tree
  • Best paths installed in routing table
  • Converges fast when topology changes
  • Uses areas for scalability

3. Characteristics

FeatureValue
TypeLink-State IGP
ProtocolIP Protocol 89
AlgorithmDijkstra SPF
MetricCost (based on bandwidth)
AD110
Multicast224.0.0.5 / 224.0.0.6
StandardRFC 2328 (OSPFv2)

4. Areas & Hierarchy

AreaDescription
Area 0 (Backbone)Core area — all other areas must connect to it
Standard AreaRegular area with full LSA flooding
Stub AreaBlocks external LSAs (Type 5)
Totally StubbyBlocks Type 3, 4, 5 — only default route
NSSAAllows redistribution but blocks Type 5

5. Neighbor States

StateDescription
DownNo Hello received
InitHello received from neighbor
2-WayBi-directional Hello received
ExStartMaster/Slave election for DB exchange
ExchangeDBD packets exchanged
LoadingLSR/LSU exchange for missing LSAs
FullDatabases synchronized

6. Timers (Default)

TimerBroadcast/NBMANon-Broadcast
Hello10 sec30 sec
Dead40 sec120 sec
Retransmit5 sec5 sec

7. Packet Types

TypePurpose
Hello (Type 1)Discover and maintain neighbors
DBD (Type 2)Database Description — summary of LSDB
LSR (Type 3)Link-State Request — request specific LSAs
LSU (Type 4)Link-State Update — carries LSAs
LSAck (Type 5)Acknowledge received LSAs

8. LSA Types

TypeNameScope
1Router LSAArea
2Network LSAArea
3Summary LSAInter-area
4ASBR SummaryInter-area
5External LSAAutonomous System
7NSSA ExternalNSSA area only

9. Cost Calculation

Cost = Reference Bandwidth / Interface Bandwidth

Default reference: 100 Mbps

10 Mbps  → Cost = 10
100 Mbps → Cost = 1
1 Gbps   → Cost = 1 (use auto-cost reference-bandwidth 10000)

10. DR & BDR

On broadcast networks, OSPF elects a Designated Router (DR) and Backup DR (BDR) to reduce LSA flooding.

  • Highest priority wins (default: 1)
  • Tie-break: highest Router ID
  • Priority 0 = never becomes DR/BDR
  • DR uses 224.0.0.5, others send to 224.0.0.6

11. Configuration

Basic OSPF
R1(config)# router ospf 1
R1(config-router)# network 192.168.1.0 0.0.0.255 area 0
R1(config-router)# network 10.0.0.0 0.255.255.255 area 1
R1(config-router)# router-id 1.1.1.1

12. Important Commands

CommandPurpose
show ip ospf neighborShow OSPF neighbors
show ip ospf databaseShow LSDB
show ip route ospfShow OSPF routes
show ip ospf interfaceShow OSPF interface info
show ip protocolsShow routing protocol info
debug ip ospf adjDebug adjacency formation
clear ip ospf processReset OSPF process

13. Authentication

interface g0/0
 ip ospf authentication message-digest
 ip ospf message-digest-key 1 md5 cisco123

14. Advanced Concepts

ConceptDescription
Virtual LinkConnects disconnected area to Area 0
Route SummarizationAt ABR (area range) or ASBR (summary-address)
Default Routedefault-information originate
Passive InterfaceStops Hello on interface (no adjacency)
OSPFv3OSPF for IPv6