OSPF Concepts & Configuration
Understanding and implementing Open Shortest Path First routing protocol
OSPF Introduction
Open Shortest Path First - A Link-State Routing Protocol
- Link-state routing protocol
- Faster convergence than RIP
- Scales to larger network implementations
- Uses concept of areas for scalability
- Uses Dijkstra's SPF algorithm
- Adjacency Database (Neighbor Table)
- Link-State Database (Topology Table)
- Forwarding Database (Routing Table)
- Five Packet Types for communication
- Router ID for unique identification
OSPF Features and Characteristics
Key aspects that make OSPF a robust routing protocol
Establish Neighbor Adjacencies
Discover and form relationships with neighboring OSPF routers
Exchange Link-State Advertisements
Share information about connected links and their states
Build Link-State Database
Create a complete topology map of the network
Execute SPF Algorithm
Calculate shortest paths to all destinations
Choose Best Route
Populate routing table with optimal paths
Single-Area OSPF
- All routers in one area
- Best practice: Use area 0
- Useful in smaller networks
- Simpler configuration
Multiarea OSPF
- Hierarchical design
- All areas connect to backbone (area 0)
- Smaller routing tables
- Reduced SPF calculations
- Better scalability
OSPF Packets
Five packet types used for OSPF communication
| Packet Type | Purpose |
|---|---|
| Hello | Discover neighbors, establish adjacencies, elect DR/BDR |
| Database Description (DBD) | Summarize database content during adjacency formation |
| Link-State Request (LSR) | Request specific link-state records from neighbor |
| Link-State Update (LSU) | Send requested link-state records |
| Link-State Ack (LSAck) | Acknowledge receipt of LSUs |
- Sent to multicast address 224.0.0.5
- Used to discover OSPF neighbors
- Elects DR and BDR on multiaccess networks
- Default interval: 10 seconds
- Dead interval: 40 seconds (4x Hello)
R1# show ip ospf interface gigabitethernet 0/0/0
# Sample output showing Hello and Dead intervals
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
OSPF Operation
Understanding how OSPF routers establish adjacencies and exchange routing information
Down State
No Hello packets received from neighbor
Init State
Hello packet received but bidirectional communication not established
Two-Way State
Bidirectional communication established with neighbor
ExStart State
Master/slave relationship established for DBD exchange
Exchange State
Routers exchange DBD packets
Loading State
Routers exchange LSR and LSU packets
Full State
Adjacency established, databases synchronized
Why & When is DR/BDR Used?
- Why: Reduces adjacency overhead. Instead of every router forming adjacency with every other router (n*(n-1)/2), they form adjacency only with DR/BDR (n-1).
- When: Used on Broadcast Multiaccess (Ethernet) and NBMA networks. Not used on Point-to-Point links.
- Function: DR generates LSAs for the segment, reducing traffic.
Why Use Priority Command?
- Controls which router becomes DR/BDR.
- Priority 0 makes a router ineligible (always DROTHER).
- Higher priority (default 1) increases chance of election.
- Tie-breaker: Highest Router ID wins if priorities match.
R1# show ip ospf neighbor
# Sample output showing neighbor states
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/DR 00:00:37 192.168.1.2 GigabitEthernet0/0/0
3.3.3.3 1 FULL/BDR 00:00:36 192.168.1.3 GigabitEthernet0/0/0
OSPF Configuration
Implementing single-area OSPFv2 in different network types
R1(config)# router ospf 10
# Configure router ID explicitly
R1(config-router)# router-id 1.1.1.1
# Advertise networks using wildcard mask
R1(config-router)# network 10.1.1.0 0.0.0.255 area 0
R1(config-router)# network 192.168.1.0 0.0.0.255 area 0
# Configure passive interface to prevent unnecessary Hellos
R1(config-router)# passive-interface gigabitethernet 0/1
Purpose
Propagates a default route (0.0.0.0/0) into the OSPF domain. Useful for edge routers connecting to the Internet.
Command
R1(config-router)# default-information originate
# Always advertise default route (even if not in table)
R1(config-router)# default-information originate always
- Router must have a default route unless
alwaysis used. - Other routers will see this as O*E2 route.
- Direct connection between two routers (e.g., Serial, HDLC, PPP).
- No DR/BDR election needed (efficient).
- Faster convergence due to fewer states.
- Default on Serial interfaces, can force on Ethernet.
R1(config)# interface gigabitethernet 0/0/0
R1(config-if)# ip ospf network point-to-point
# Verify the change
R1# show ip ospf interface gigabitethernet 0/0/0
# Should show: Network Type POINT_TO_POINT
- Non-Broadcast Multi-Access (e.g., Frame Relay, X.25).
- No broadcast capability; neighbors must be defined manually or use point-to-multipoint.
- DR/BDR election occurs but requires careful planning (Hub should be DR).
- Split Horizon issues may arise.
R1(config-router)# neighbor 192.168.1.2
# Or change network type
R1(config-if)# ip ospf network point-to-multipoint
- Multiple routers on same segment (e.g., Ethernet).
- DR/BDR election occurs automatically.
- Control election with
ip ospf priority. - Uses multicast: 224.0.0.5 (All OSPF) and 224.0.0.6 (DR/BDR).
R1(config)# interface gigabitethernet 0/0/0
R1(config-if)# ip ospf priority 100
# Reset OSPF process for changes to take effect
R1# clear ip ospf process
Reset ALL OSPF processes? [no]: y
OSPF Cost and Metrics
Understanding and manipulating OSPF path selection
OSPF uses cost as its metric, with lower values indicating better paths:
Cost = Reference Bandwidth / Interface Bandwidth
# Default Reference Bandwidth: 100,000,000 bps (100 Mbps)
# Example calculations:
FastEthernet (100 Mbps): 100,000,000 / 100,000,000 = 1
GigabitEthernet (1 Gbps): 100,000,000 / 1,000,000,000 = 0.1 (rounded to 1)
10 GigabitEthernet: 100,000,000 / 10,000,000,000 = 0.01 (rounded to 1)
To accommodate faster interfaces, adjust the reference bandwidth:
R1(config)# router ospf 10
R1(config-router)# auto-cost reference-bandwidth 1000
# Sets reference bandwidth to 1,000,000,000 (1 Gbps)
# Must be configured on all OSPF routers in the domain
Manually adjust interface cost to influence path selection:
R1(config)# interface gigabitethernet 0/0/0
R1(config-if)# ip ospf cost 50
# Verify OSPF cost
R1# show ip ospf interface gigabitethernet 0/0/0
# Look for: Cost: 50 State: DR
R1# show ip route ospf
# Sample output
O 10.2.2.0/24 [110/65] via 192.168.1.2, 00:05:23, GigabitEthernet0/0/0
# [110/65] = Administrative Distance / Metric (Cost)
OSPF Verification Commands
Essential commands to verify and troubleshoot OSPF operation
R1# show ip ospf neighbor
# Display OSPF interfaces and their parameters
R1# show ip ospf interface brief
# View OSPF routing table entries
R1# show ip route ospf
# Examine OSPF database
R1# show ip ospf database
# Display OSPF process information
R1# show ip ospf
# Debug OSPF events (use with caution)
R1# debug ip ospf events
R1# show ip ospf traffic
# Verify OSPF timers
R1# show ip ospf interface
# Check for OSPF authentication issues
R1# show ip ospf interface detail
# Clear OSPF process (forces re-establishment)
R1# clear ip ospf process
# Reset OSPF counters
R1# clear ip ospf counters
OSPF Protocol Summary
Visual representation of OSPF concepts and components
OSPF Features
- Classless (supports VLSM/CIDR)
- Fast convergence
- Scalable with areas
- Uses SPF algorithm
- Link-state protocol
OSPF Packet Types
- Hello
- DBD (Database Description)
- LSR (Link-State Request)
- LSU (Link-State Update)
- LSAck (Link-State Ack)
OSPF Operation
- Establish adjacencies
- Exchange LSAs
- Build topology database
- Run SPF algorithm
- Update routing table
OSPF Configuration
- Router ID selection
- Network statements
- DR/BDR election
- Network types
- Cost manipulation
OSPF Verification
- Neighbor table
- Topology database
- Routing table
- Interface statistics
- Debug commands