OSPF Cheat Sheet
OSPF Ultimate Cheat Sheet
Configuration • Commands • Multi-Area Routing • Troubleshooting • Security
⬇ Download the PDF edition1. OSPF at a glance
Open Shortest Path First (OSPFv2) is a link-state interior gateway protocol. Routers flood link-state information within their area, build an LSDB, and run SPF (Dijkstra) to select routes. It uses IP protocol number 89, not TCP/UDP port 89. Default Cisco administrative distance is 110; multicast 224.0.0.5 reaches all SPF routers and 224.0.0.6 targets DR/BDR on broadcast networks.
2. Understand the five-router enterprise lab
R1, R2, and R3 form backbone Area 0. R1 connects Area 10 to R4; R3 connects Area 20 to R5. The R1–R3 link provides an alternate backbone path. All numbered /30 links are point-to-point, with no DR/BDR election. VLAN 100 on the shared backbone broadcast segment illustrates a place where DR/BDR applies if two or more OSPF routers share it. R1 and R3 are ABRs. Loopbacks provide stable router IDs. The diagram is conceptual: add an OSPF-speaking router to VLAN 100 for an actual multi-router DR/BDR lab.
3. Essential facts and timers
Typical Ethernet broadcast OSPFv2 hello/dead timers are 10/40 seconds, subject to platform and network type. On point-to-point Ethernet use ip ospf network point-to-point to prevent DR election. Router IDs must be unique; areas must match on neighbors; authentication and compatible hello/dead intervals matter. IP MTU differences often cause adjacency problems during database exchange. On multiaccess networks, 2-Way can be normal between two DROTHER routers.
4. Neighbor states
Down → Init → 2-Way → ExStart → Exchange → Loading → Full. Attempt can appear on NBMA manually configured neighbors. ExStart negotiates master/slave and DBD sequencing; Exchange shares DBD summaries; Loading requests missing LSAs. On point-to-point links the expected stable state is FULL/-. On broadcast, FULL/DR, FULL/BDR, or FULL/DROTHER depends on election; 2-Way can be normal between DROTHERs.
5. LSAs you must recognize
Type 1 Router: generated by every router and restricted to its area. Type 2 Network: generated by DR for a broadcast transit network. Type 3 Summary: ABR distributes inter-area prefixes. Type 4 ASBR Summary: provides reachability to an ASBR when needed. Type 5 AS External: external routes except where prohibited (for example, stub areas). Type 7 NSSA External: introduced within an NSSA, with eligible routes translated by the ABR to Type 5. OSPFv3 has different LSAs and header fields—do not reuse OSPFv2 packet diagrams for OSPFv3.
6. Area design and route types
Backbone Area 0 interconnects other areas. Standard areas accept normal external routes. Stub areas block Type 5 external LSAs and use an ABR-provided default route; totally stubby is a Cisco extension reducing summary LSAs. NSSA permits external redistribution via Type 7 LSAs. In the route table: O = intra-area, O IA = inter-area, O E1/E2 = external, O N1/N2 = NSSA external. E1 combines internal cost toward ASBR and external metric; E2 normally compares external metric first.
7. Route cost, DR/BDR and redundancy
OSPF cost is configurable using ip ospf cost VALUE, or computed from a reference bandwidth divided by interface bandwidth (integer minimum 1). Set the same auto-cost reference-bandwidth on all routers, such as 100000 Mbps for 100-Gbps links. On a broadcast segment highest eligible OSPF interface priority becomes DR, then BDR, with router ID breaking ties. Priority 0 is ineligible. Existing DR/BDR elections are non-preemptive. No DR on point-to-point links.
8. Security and defensive design
Restrict OSPF neighbor formation to trusted routed links; use passive-interface default and enable only transit interfaces. Authenticate every adjacency. Where the platform supports it, use key-chain cryptographic authentication with HMAC-SHA-256 (example below); MD5 (ip ospf message-digest-key) remains only for compatibility with older peers. Filter unauthorized OSPF protocol 89 at untrusted boundaries; avoid indiscriminate redistribution; scope and summarize routes, monitor adjacency flaps and LSDB changes. Do not treat OSPF authentication as confidentiality or route authorization.
! Same key chain on both neighbors (e.g. R1 and R2) key chain OSPF-KEYS key 1 key-string REPLACE-WITH-STRONG-SECRET cryptographic-algorithm hmac-sha-256 ! interface GigabitEthernet0/0/0 ip ospf authentication key-chain OSPF-KEYS
Replace the demonstration secret, keep it out of shared repositories, confirm support on your exact IOS XE release, and roll keys on both ends together. Verify with show ip ospf interface GigabitEthernet0/0/0, which reports the authentication in use.
9. Troubleshooting workflow
1) Check physical and L3 state (show ip interface brief). 2) Check OSPF participation (show ip ospf interface brief). 3) Verify area, network type, timers, subnet, MTU, authentication and router IDs (show ip ospf interface, show ip ospf neighbor detail). 4) Inspect database (show ip ospf database), then routing decisions (show ip route ospf). 5) Inspect logs before using debugs; debug ip ospf adj can be noisy, so use only in controlled maintenance.
10. Common failures and fixes
STUCK IN INIT: Unidirectional reachability or multicast/ACL filtering; verify bidirectional Hellos. STUCK EXSTART/EXCHANGE: investigate MTU mismatches and DBD exchange; do not use ip ospf mtu-ignore as a first fix. NEIGHBOR MISSING: wrong area/network type, interface passive, authentication mismatch, protocol 89 blocked. FULL BUT NO ROUTE: verify LSAs, area type, summarization, better administrative-distance route, and prefix visibility. UNSTABLE DR: priority changes alone do not preempt existing DR.
11. Operational best practices
Use clear interface descriptions, router-ID loopbacks, consistent reference bandwidth, point-to-point OSPF network types on dedicated routed links, defined area boundaries, stable ABRs, route and adjacency monitoring, and a tested change-backout plan. Avoid virtual links as a long-term backbone design; use them as exceptional transitional mechanisms.
12. Cisco IOS XE complete configuration examples
Replace the lab addressing and interface numbers for your hardware. Router IDs are manually configured; loopback addresses are not advertised in these templates.
R1 — ABR Area 0/10
hostname R1 interface Loopback0 ip address 1.1.1.1 255.255.255.255 interface GigabitEthernet0/0/0 description Area0-to-R2 ip address 10.0.12.1 255.255.255.252 ip ospf 100 area 0 ip ospf network point-to-point interface GigabitEthernet0/0/1 description Area10-to-R4 ip address 10.0.14.1 255.255.255.252 ip ospf 100 area 10 ip ospf network point-to-point interface GigabitEthernet0/0/2 description Area0-backup-to-R3 ip address 10.0.13.1 255.255.255.252 ip ospf 100 area 0 ip ospf network point-to-point router ospf 100 router-id 1.1.1.1 auto-cost reference-bandwidth 100000 passive-interface default no passive-interface GigabitEthernet0/0/0 no passive-interface GigabitEthernet0/0/1 no passive-interface GigabitEthernet0/0/2
R2 — Core Area 0
hostname R2 interface Loopback0 ip address 2.2.2.2 255.255.255.255 interface GigabitEthernet0/0/0 description Area0-to-R1 ip address 10.0.12.2 255.255.255.252 ip ospf 100 area 0 ip ospf network point-to-point interface GigabitEthernet0/0/1 description Area0-to-R3 ip address 10.0.23.1 255.255.255.252 ip ospf 100 area 0 ip ospf network point-to-point interface Vlan100 description Area0-Ethernet-DR-BDR-demo ip address 10.0.100.1 255.255.255.0 ip ospf 100 area 0 ip ospf priority 200 router ospf 100 router-id 2.2.2.2 auto-cost reference-bandwidth 100000 passive-interface default no passive-interface GigabitEthernet0/0/0 no passive-interface GigabitEthernet0/0/1 no passive-interface Vlan100
R3 — ABR Area 0/20
hostname R3 interface Loopback0 ip address 3.3.3.3 255.255.255.255 interface GigabitEthernet0/0/0 description Area0-to-R2 ip address 10.0.23.2 255.255.255.252 ip ospf 100 area 0 ip ospf network point-to-point interface GigabitEthernet0/0/1 description Area20-to-R5 ip address 10.0.35.1 255.255.255.252 ip ospf 100 area 20 ip ospf network point-to-point interface GigabitEthernet0/0/2 description Area0-backup-to-R1 ip address 10.0.13.2 255.255.255.252 ip ospf 100 area 0 ip ospf network point-to-point router ospf 100 router-id 3.3.3.3 auto-cost reference-bandwidth 100000 passive-interface default no passive-interface GigabitEthernet0/0/0 no passive-interface GigabitEthernet0/0/1 no passive-interface GigabitEthernet0/0/2
R4 — Area 10
hostname R4 interface Loopback0 ip address 4.4.4.4 255.255.255.255 interface GigabitEthernet0/0/0 description Area10-to-R1 ip address 10.0.14.2 255.255.255.252 ip ospf 100 area 10 ip ospf network point-to-point interface GigabitEthernet0/0/1 description Users-Area10 ip address 192.168.10.1 255.255.255.0 ip ospf 100 area 10 router ospf 100 router-id 4.4.4.4 auto-cost reference-bandwidth 100000 passive-interface default no passive-interface GigabitEthernet0/0/0
R5 — Area 20
hostname R5 interface Loopback0 ip address 5.5.5.5 255.255.255.255 interface GigabitEthernet0/0/0 description Area20-to-R3 ip address 10.0.35.2 255.255.255.252 ip ospf 100 area 20 ip ospf network point-to-point interface GigabitEthernet0/0/1 description Users-Area20 ip address 192.168.20.1 255.255.255.0 ip ospf 100 area 20 router ospf 100 router-id 5.5.5.5 auto-cost reference-bandwidth 100000 passive-interface default no passive-interface GigabitEthernet0/0/0
13. Verification and troubleshooting commands
show ip ospf neighborSee neighbor states; FULL/- expected on point-to-point links.
show ip ospf interface briefVerify enabled interfaces, areas, IPs and costs.
show ip ospf interface GigabitEthernet0/0/0Check hello/dead timers, state and network type.
show ip ospf databaseInspect LSA inventory and sequence/age.
show ip route ospfConfirm installed O, O IA, E1/E2 routes.
show ip ospf border-routersSee known ABRs/ASBRs.
show ip protocolsReview process participation and passive interfaces.
show logging | include OSPFCorrelate adjacency and link events.
ping 10.0.12.2 source 10.0.12.1Validate reachability across R1–R2 link.
clear ip ospf processDisruptive: resets adjacencies—maintenance only.
14. Practice questions and detailed answers
No. Both interfaces are OSPF point-to-point, so no election.
The route originates in Area 20 and is distributed by an ABR through Area 0 into Area 10.
No. Between DROTHER neighbors 2-Way may be correct; full adjacency forms with DR/BDR.
OSPF packets use IP protocol number 89, not TCP/UDP destination port 89.
MTU mismatch, network type mismatch, or DBD negotiation/connectivity.
R1 connects Areas 0 and 10; R3 connects Areas 0 and 20.
Prevents Hellos/adjacency on interfaces until explicitly enabled, while eligible connected networks can still be advertised.
For consistent cost scaling, especially links above 100 Mbps.
No. DR/BDR election is non-preemptive.
No. Stub areas block Type 5 and generally use a default from the ABR.
15. Sources & verification
This is an original MAG212 CYBER guide. The five-router lab, diagram and explanations were written independently and checked against the IETF standards and Cisco documentation below.
RFC 2328 — OSPF Version 2 · RFC 3101 — OSPF NSSA · RFC 5340 — OSPF for IPv6 · Cisco OSPF Configuration Guide (IOS XE 17) · Cisco — OSPFv2 Cryptographic Authentication
More guides in Learn · IS-IS · EIGRP · BGP · Network consulting & seminars
