Skip to main content
OSPF (Open Shortest Path First) is a link-state dynamic routing protocol defined in RFC 2328 (OSPFv2). It uses Dijkstra’s Shortest Path First (SPF) algorithm to determine the best path to each destination and supports fast convergence and hierarchical design using areas.

Key Characteristics

FeatureDescription
TypeLink-state
AlgorithmDijkstra SPF
MetricCost (based on interface bandwidth)
TransportIP protocol 89
AuthenticationPlaintext or MD5
Convergence SpeedFast
ScalabilityHigh (multi-area support)

OSPF Concepts

TermDescription
Router ID (RID)Unique 32-bit identifier (often highest IP or manually set)
AreaLogical segmentation (e.g. Area 0 is the backbone)
NeighbourAdjacent routers exchanging Hello packets
AdjacencyFully synchronised routers that share LSDBs
LSA (Link-State Advertisement)Packet describing network topology details
LSDB (Link-State Database)The collection of LSAs known to the router
SPF CalculationDetermines the shortest path to all destinations

OSPF States

StateDescription
DownNo Hello packets received
InitHello received, but no bidirectional comms
2-WayBidirectional Hello exchange
ExStart / ExchangeDatabase description (DBD) exchange starts
LoadingLSRs and LSUs exchanged to synchronise databases
FullLSDBs fully synchronised — adjacency established

Configuration Examples

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 0
Router(config-router)# passive-interface default
Router(config-router)# no passive-interface GigabitEthernet0/0
Router(config-router)# end
Router# show ip ospf neighbor
Router# show ip route ospf
Explanation:
  • network statements define which interfaces participate in OSPF
  • The area 0 command places them in the backbone area
  • passive-interface prevents unnecessary Hello packets on user-facing interfaces

OSPF in AWS and Hybrid Environments

While AWS VPCs don’t natively use OSPF, they support BGP-based dynamic routing via:
  • AWS Site-to-Site VPN
  • Transit Gateway
  • Direct Connect
However, OSPF remains highly relevant for:
  • On-premises routing domains connecting to AWS
  • Hybrid networks via edge routers or firewalls (e.g. pfSense/FRR)
  • Lab simulations (before implementing BGP)

OSPF Cost Calculation

Cost = Reference Bandwidth / Interface Bandwidth Default reference bandwidth = 100 Mbps
InterfaceBandwidthDefault Cost
FastEthernet100 Mbps1
GigabitEthernet1 Gbps1 (adjust reference)
10-Gigabit10 Gbps1 (unless adjusted)

Adjusting Reference Bandwidth

Router(config-router)# auto-cost reference-bandwidth 10000
This ensures 10G+ interfaces have realistic costs.

OSPF Security

ControlDescription
AuthenticationPlaintext or MD5 keychain (per-interface or area)
Passive InterfacesStops Hello packets on end-user ports
LSA FilteringPrevents unnecessary flooding
Route FilteringLimits external redistribution

Example: MD5 Authentication

Router(config)# interface GigabitEthernet0/0
Router(config-if)# ip ospf authentication message-digest
Router(config-if)# ip ospf message-digest-key 1 md5 MySecureKey

Lab Exercise

1

Build Topology

Build a 3-router topology (using Cisco hardware, GNS3, or Packet Tracer)
2

Configure Single Area

Configure OSPF single area
3

Verify Adjacencies

Observe neighbour adjacencies using show ip ospf neighbor
4

Introduce Multi-Area

Introduce multi-area design
5

Enable Authentication

Enable authentication between two routers
6

Test Convergence

Observe route convergence when a link is brought down

Troubleshooting Commands

# Verify adjacencies
show ip ospf neighbor

# Inspect LSDB contents
show ip ospf database

# Check OSPF configuration
show ip protocols

Further Reading

Build docs developers (and LLMs) love