OSPF
OSPF
Open Shortest Path First
1. What is OSPF?2. How OSPF Works3. Characteristics4. Areas & Hierarchy5. Neighbor States6. Timers (Default)7. Packet Types8. LSA Types9. Cost Calculation10. DR & BDR11. Configuration12. Important Commands13. Authentication14. Advanced Concepts
1. What is OSPF?
OSPF is an open standard Link-State IGP that uses Dijkstra's SPF algorithm. IP protocol 89, multicast 224.0.0.5 (AllSPFRouters) and 224.0.0.6 (AllDRouters).
2. How OSPF Works
- •Routers exchange LSAs to build a complete topology map
- •SPF algorithm computes shortest path tree
- •Best paths installed in routing table
- •Converges fast when topology changes
- •Uses areas for scalability
3. Characteristics
| Feature | Value |
|---|---|
| Type | Link-State IGP |
| Protocol | IP Protocol 89 |
| Algorithm | Dijkstra SPF |
| Metric | Cost (based on bandwidth) |
| AD | 110 |
| Multicast | 224.0.0.5 / 224.0.0.6 |
| Standard | RFC 2328 (OSPFv2) |
4. Areas & Hierarchy
| Area | Description |
|---|---|
| Area 0 (Backbone) | Core area — all other areas must connect to it |
| Standard Area | Regular area with full LSA flooding |
| Stub Area | Blocks external LSAs (Type 5) |
| Totally Stubby | Blocks Type 3, 4, 5 — only default route |
| NSSA | Allows redistribution but blocks Type 5 |
5. Neighbor States
| State | Description |
|---|---|
| Down | No Hello received |
| Init | Hello received from neighbor |
| 2-Way | Bi-directional Hello received |
| ExStart | Master/Slave election for DB exchange |
| Exchange | DBD packets exchanged |
| Loading | LSR/LSU exchange for missing LSAs |
| Full | Databases synchronized |
6. Timers (Default)
| Timer | Broadcast/NBMA | Non-Broadcast |
|---|---|---|
| Hello | 10 sec | 30 sec |
| Dead | 40 sec | 120 sec |
| Retransmit | 5 sec | 5 sec |
7. Packet Types
| Type | Purpose |
|---|---|
| Hello (Type 1) | Discover and maintain neighbors |
| DBD (Type 2) | Database Description — summary of LSDB |
| LSR (Type 3) | Link-State Request — request specific LSAs |
| LSU (Type 4) | Link-State Update — carries LSAs |
| LSAck (Type 5) | Acknowledge received LSAs |
8. LSA Types
| Type | Name | Scope |
|---|---|---|
| 1 | Router LSA | Area |
| 2 | Network LSA | Area |
| 3 | Summary LSA | Inter-area |
| 4 | ASBR Summary | Inter-area |
| 5 | External LSA | Autonomous System |
| 7 | NSSA External | NSSA area only |
9. Cost Calculation
Cost = Reference Bandwidth / Interface Bandwidth Default reference: 100 Mbps 10 Mbps → Cost = 10 100 Mbps → Cost = 1 1 Gbps → Cost = 1 (use auto-cost reference-bandwidth 10000)
10. DR & BDR
On broadcast networks, OSPF elects a Designated Router (DR) and Backup DR (BDR) to reduce LSA flooding.
- •Highest priority wins (default: 1)
- •Tie-break: highest Router ID
- •Priority 0 = never becomes DR/BDR
- •DR uses 224.0.0.5, others send to 224.0.0.6
11. Configuration
Basic OSPF
R1(config)# router ospf 1 R1(config-router)# network 192.168.1.0 0.0.0.255 area 0 R1(config-router)# network 10.0.0.0 0.255.255.255 area 1 R1(config-router)# router-id 1.1.1.1
12. Important Commands
| Command | Purpose |
|---|---|
| show ip ospf neighbor | Show OSPF neighbors |
| show ip ospf database | Show LSDB |
| show ip route ospf | Show OSPF routes |
| show ip ospf interface | Show OSPF interface info |
| show ip protocols | Show routing protocol info |
| debug ip ospf adj | Debug adjacency formation |
| clear ip ospf process | Reset OSPF process |
13. Authentication
interface g0/0 ip ospf authentication message-digest ip ospf message-digest-key 1 md5 cisco123
14. Advanced Concepts
| Concept | Description |
|---|---|
| Virtual Link | Connects disconnected area to Area 0 |
| Route Summarization | At ABR (area range) or ASBR (summary-address) |
| Default Route | default-information originate |
| Passive Interface | Stops Hello on interface (no adjacency) |
| OSPFv3 | OSPF for IPv6 |