OSPF Routing


Open Shortest Path First, or OSPF, is a link-state interior gateway protocol. Routers exchange information about their links, build a shared view of the topology, and calculate the shortest path to each destination using interface cost.

When OSPF Is a Good Fit

OSPF is useful when a network has enough routers and redundant paths that maintaining static routes would become fragile. It is commonly used in campus networks, enterprise WANs, infrastructure networks, and service-provider environments.

Core OSPF Concepts

  • Router ID: A 32-bit identifier for the OSPF router. It looks like an IPv4 address but does not need to be a reachable address.
  • Area: A logical grouping that limits the scope of link-state information.
  • Area 0: The backbone area. Other normal areas should connect to it.
  • Neighbor adjacency: The relationship formed between compatible OSPF routers.
  • Link-State Database: The topology information used to calculate routes.
  • Cost: The metric OSPF uses when selecting paths.

Neighbor Formation

Two routers will not become full OSPF neighbors unless important settings agree. Check the following when an adjacency does not form:

  • Interfaces are in the same IP subnet.
  • Area IDs match.
  • Hello and dead timers match.
  • Authentication settings match.
  • Network types are compatible.
  • MTU differences are not preventing database exchange.
  • OSPF packets are not being blocked.

OSPF Areas

Areas reduce the amount of topology information every router must maintain. A small network may place everything in area 0. Larger networks may use additional areas to create cleaner failure domains and reduce recalculation.

Area typePurpose
BackboneArea 0 connects the OSPF topology.
NormalAccepts intra-area, inter-area, and external routes.
StubLimits external route information and normally uses a default route.
Totally stubbyVendor-specific extension that further limits summary information.
NSSAAllows limited external route injection inside a stub-like area.

Basic Cisco IOS Configuration

interface Loopback0
 ip address 10.255.0.1 255.255.255.255
!
interface GigabitEthernet0/0
 ip address 10.0.12.1 255.255.255.252
 ip ospf 10 area 0
!
router ospf 10
 router-id 10.255.0.1
 passive-interface default
 no passive-interface GigabitEthernet0/0

Using interface-level OSPF configuration makes it clear which interfaces participate. Making interfaces passive by default also prevents accidental neighbor formation on user-facing networks while still advertising those connected networks.

Basic VyOS Configuration

configure
set protocols ospf parameters router-id 10.255.0.2
set protocols ospf area 0 network 10.0.12.0/30
set protocols ospf area 0 network 10.20.0.0/16
set protocols ospf passive-interface 10.20.0.1
commit
save

Cost and Path Selection

OSPF cost is assigned to interfaces. Lower total cost is preferred. When multiple paths have the same cost, OSPF can install equal-cost routes and allow the forwarding plane to distribute traffic across them.

Do not assume default cost calculations reflect modern link speeds. In many networks, operators set a higher reference bandwidth or explicitly configure interface costs so that 10 Gb, 40 Gb, and 100 Gb links are differentiated correctly.

Route Summarization

Summarization reduces routing-table size and limits the spread of topology changes. It works best when the address plan was designed with summarization in mind. Randomly assigning subnets makes clean summaries difficult or impossible.

Design lesson: Routing scalability begins with address planning. Reserve contiguous blocks for sites, racks, tenants, or functions before they are needed.

Useful Verification Commands

show ip ospf neighbor
show ip ospf interface brief
show ip ospf database
show ip route ospf
show ip protocols

show protocols ospf neighbor
show protocols ospf database
show ip route ospf

Common OSPF Problems

  • Stuck in EXSTART or EXCHANGE: Often an MTU mismatch.
  • No neighbor discovered: Check Layer 2 connectivity, addressing, area, timers, passive interfaces, and filters.
  • Route is missing: Confirm the network is included, the interface is up, and route filtering or area type is not suppressing it.
  • Unexpected path: Compare interface costs and confirm the topology has converged.
  • Frequent adjacency resets: Investigate packet loss, interface errors, CPU pressure, duplicate router IDs, or unstable links.