Reference

Core

OSPFv2 (IPv4)

OSPF is a classless, link-state interior gateway protocol that builds a topology database via the SPF algorithm and converges quickly. It is heavily tested on the CCNA in single and multi-area designs.

What you need to know

  • OSPF administrative distance is 110; cost is calculated as reference bandwidth divided by interface bandwidth, default reference bandwidth 100,000,000 (100 Mbps).
  • Router ID selection order: manually configured router-id, then highest loopback IP, then highest active physical interface IP at process start.
  • OSPF neighbors must match area number, subnet/mask, hello and dead intervals, authentication, and area type (stub flags) to form an adjacency.
  • Default hello interval is 10 seconds and dead interval is 40 seconds on broadcast and point-to-point networks; 30/120 on NBMA.
  • DR and BDR are elected on broadcast and NBMA multi-access segments based on highest priority (default 1, range 0-255) then highest router ID; priority 0 means never becomes DR/BDR.
  • OSPF neighbor states progress Down, Init, 2-Way, ExStart, Exchange, Loading, Full; DROthers stay in 2-Way with each other.
  • Passive interfaces suppress hello packets but still advertise the connected network.

Configuration commands

CommandModePurpose
router ospf 1configEnable an OSPF process with locally significant process ID 1.
router-id 1.1.1.1config-routerManually set the OSPF router ID.
network 10.0.0.0 0.0.0.255 area 0config-routerEnable OSPF on interfaces within the matching wildcard range and assign area 0.
passive-interface gigabitethernet0/0config-routerStop sending hellos on an interface while still advertising its network.
ip ospf priority 255config-ifIncrease DR election priority on this interface.
ip ospf hello-interval 5config-ifChange the hello interval (must match neighbors).
ip ospf cost 20config-ifManually set the OSPF cost of an interface.
auto-cost reference-bandwidth 10000config-routerChange the reference bandwidth (Mbps) used for cost calculation on all interfaces.
ip ospf 1 area 0config-ifEnable OSPF directly on the interface instead of using a network statement.
default-information originateconfig-routerInject a default route into the OSPF domain.

Verify it

  • show ip ospf neighbor
  • show ip ospf interface brief
  • show ip protocols
  • show ip route ospf
  • show ip ospf database
  • show ip ospf
  • debug ip ospf adj

Common mistakes

  • Mismatched hello/dead timers or area numbers between neighbors preventing adjacency.
  • Wrong wildcard mask on the network statement, leaving an interface out of OSPF.
  • Not updating auto-cost reference-bandwidth on all routers consistently, causing asymmetric costs.
  • Two routers on the same segment configured in different areas by mistake.
  • Duplicate router IDs across routers in the same OSPF domain.

Practise OSPFv2 (IPv4) in a real CLI

Generated labs, graded against the simulated network state.

Start a free lab