OSPF Cheat Sheet: Full Configuration Guide
Here’s a complete OSPF configuration cheat sheet that can be directly applied to routers. This covers common OSPF setups for multi-area configurations, including ABRs, internal routers, and useful commands.
General OSPF Configuration Template
Global OSPF Configuration
router ospf <process-id>
router-id <router-id> ! Unique router ID (use a loopback address)
log-adjacency-changes ! Logs neighbor adjacency changes (optional)
Interface-Based OSPF (Optional)
interface <interface>
ip ospf <process-id> area <area-id> ! Assigns the interface to an OSPF area
Network-Based OSPF
router ospf <process-id>
network <network> <wildcard-mask> area <area-id> ! Define networks for OSPF
Virtual Links
router ospf <process-id>
area <area-id> virtual-link <router-id> ! Establish a virtual link
Full OSPF Multi-Area Configuration
R1 (ABR between Area 0 and Area 1)
router ospf 1
router-id 1.1.1.1
log-adjacency-changes
network 10.1.1.1 0.0.0.0 area 1 ! Loopback in Area 1
network 192.168.1.0 0.0.0.255 area 1 ! Area 1 link to R2
network 192.168.0.0 0.0.0.255 area 0 ! Area 0 link to R3
R2 (Internal Router in Area 1)
router ospf 1
router-id 2.2.2.2
log-adjacency-changes
network 10.2.2.2 0.0.0.0 area 1 ! Loopback in Area 1
network 192.168.1.0 0.0.0.255 area 1 ! Area 1 link to R1
R3 (ABR between Area 0 and Area 2)
router ospf 1
router-id 3.3.3.3
log-adjacency-changes
network 10.3.3.3 0.0.0.0 area 2 ! Loopback in Area 2
network 192.168.2.0 0.0.0.255 area 2 ! Area 2 link to R4
network 192.168.0.0 0.0.0.255 area 0 ! Area 0 link to R1
R4 (Internal Router in Area 2)
router ospf 1
router-id 4.4.4.4
log-adjacency-changes
network 10.4.4.4 0.0.0.0 area 2 ! Loopback in Area 2
network 192.168.2.0 0.0.0.255 area 2 ! Area 2 link to R3
OSPF Advanced Configuration
Virtual Links (Example for R3 and R4)
If R4 cannot directly connect to Area 0, configure a virtual link via R3.
R3 Configuration:
router ospf 1
area 2 virtual-link 4.4.4.4
R4 Configuration:
router ospf 1
area 2 virtual-link 3.3.3.3
Passive Interfaces
Prevents OSPF Hello packets on specific interfaces.
router ospf 1
passive-interface default
no passive-interface <interface>
Redistribution into OSPF
Redistribute routes from other protocols (e.g., BGP, static) into OSPF.
router ospf 1
redistribute static subnets
redistribute bgp <asn> subnets
OSPF Timers
Modify Hello and Dead timers for faster convergence.
interface <interface>
ip ospf hello-interval 5
ip ospf dead-interval 20
OSPF Authentication
Enable MD5 authentication between neighbors.
interface <interface>
ip ospf message-digest-key 1 md5 <password>
Enable Authentication Globally:
router ospf 1
area <area-id> authentication message-digest
Verification Commands
Check OSPF Neighbors:
show ip ospf neighbor
Check OSPF Database:
show ip ospf database
Check OSPF Routes:
show ip route ospf
Check OSPF Configuration:
show running-config | section ospf
Debug OSPF:
debug ip ospf adj debug ip ospf events