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
| Command | Mode | Purpose |
|---|---|---|
| router ospf 1 | config | Enable an OSPF process with locally significant process ID 1. |
| router-id 1.1.1.1 | config-router | Manually set the OSPF router ID. |
| network 10.0.0.0 0.0.0.255 area 0 | config-router | Enable OSPF on interfaces within the matching wildcard range and assign area 0. |
| passive-interface gigabitethernet0/0 | config-router | Stop sending hellos on an interface while still advertising its network. |
| ip ospf priority 255 | config-if | Increase DR election priority on this interface. |
| ip ospf hello-interval 5 | config-if | Change the hello interval (must match neighbors). |
| ip ospf cost 20 | config-if | Manually set the OSPF cost of an interface. |
| auto-cost reference-bandwidth 10000 | config-router | Change the reference bandwidth (Mbps) used for cost calculation on all interfaces. |
| ip ospf 1 area 0 | config-if | Enable OSPF directly on the interface instead of using a network statement. |
| default-information originate | config-router | Inject 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.