๐ŸŽฏ Lab Objectives

  • Understand OSPF operation: LSAs, SPF algorithm, link-state database
  • Configure OSPF on multiple routers and verify neighbour adjacency
  • Set router IDs manually using loopback interfaces
  • Understand and influence DR/BDR election on multi-access networks
  • Adjust OSPF cost to control path selection
  • Configure multi-area OSPF with ABRs

OSPF Overview

OSPF (Open Shortest Path First) is a link-state routing protocol standardised as RFC 2328. Each router builds a complete map of the network topology by exchanging LSAs (Link State Advertisements), then runs Dijkstra's SPF algorithm to find the shortest path to every destination.

FeatureValue
Protocol typeLink-state (Interior Gateway Protocol)
AlgorithmDijkstra SPF
MetricCost (100Mbps reference BW / interface BW)
Administrative Distance110
TransportIP Protocol 89 (not TCP/UDP)
Multicast addresses224.0.0.5 (all OSPF), 224.0.0.6 (DR/BDR)
Hello interval10s (broadcast), 30s (non-broadcast)
Dead interval4x Hello (40s / 120s)

Step 1 โ€” Lab Topology

        .1          .2
R1 ----[eth0/1]---[eth0/1]---- R2
10.0.12.0/30              10.0.23.0/30
                       .1          .2
              R2 ----[eth0/2]---[eth0/2]---- R3

Loopbacks:
R1: 1.1.1.1/32
R2: 2.2.2.2/32
R3: 3.3.3.3/32

LANs:
R1: 192.168.1.0/24
R3: 192.168.3.0/24

Step 2 โ€” Interface Configuration

! R1
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
interface GigabitEthernet0/1
 ip address 10.0.12.1 255.255.255.252
 no shutdown
interface GigabitEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 no shutdown

! R2
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
interface GigabitEthernet0/1
 ip address 10.0.12.2 255.255.255.252
 no shutdown
interface GigabitEthernet0/2
 ip address 10.0.23.1 255.255.255.252
 no shutdown

! R3
interface Loopback0
 ip address 3.3.3.3 255.255.255.255
interface GigabitEthernet0/2
 ip address 10.0.23.2 255.255.255.252
 no shutdown
interface GigabitEthernet0/0
 ip address 192.168.3.1 255.255.255.0
 no shutdown

Step 3 โ€” Enable OSPF

! R1 โ€” Single area OSPF
router ospf 1
 router-id 1.1.1.1
 network 10.0.12.0 0.0.0.3 area 0
 network 192.168.1.0 0.0.0.255 area 0
 network 1.1.1.1 0.0.0.0 area 0

! R2
router ospf 1
 router-id 2.2.2.2
 network 10.0.12.0 0.0.0.3 area 0
 network 10.0.23.0 0.0.0.3 area 0
 network 2.2.2.2 0.0.0.0 area 0

! R3
router ospf 1
 router-id 3.3.3.3
 network 10.0.23.0 0.0.0.3 area 0
 network 192.168.3.0 0.0.0.255 area 0
 network 3.3.3.3 0.0.0.0 area 0

Step 4 โ€” Router ID

# Router ID selection priority:
# 1. Manually configured router-id (recommended)
# 2. Highest loopback interface IP
# 3. Highest active physical interface IP

# Always set manually โ€” prevents unexpected changes
router ospf 1
 router-id 1.1.1.1

# After changing router-id, clear OSPF process
clear ip ospf process   # (confirm yes)

Step 5 โ€” Verify Neighbours

# Show OSPF neighbours
show ip ospf neighbor

# Expected output on R2:
Neighbor ID  Pri  State    Dead Time  Address     Interface
1.1.1.1       1  FULL/DR  00:00:38  10.0.12.1   Gi0/1
3.3.3.3       1  FULL/DR  00:00:36  10.0.23.2   Gi0/2

# Neighbour states โ€” must reach FULL for adjacency
# DOWN โ†’ INIT โ†’ 2-WAY โ†’ EXSTART โ†’ EXCHANGE โ†’ LOADING โ†’ FULL

# Show routing table (O = OSPF routes)
show ip route ospf

# Show OSPF database
show ip ospf database

Step 6 โ€” DR/BDR Election

# DR/BDR elected on multi-access networks (Ethernet)
# Election based on: highest priority โ†’ highest router-id
# Priority 0 = never become DR/BDR

# Set OSPF priority on interface (higher = more likely DR)
interface GigabitEthernet0/1
 ip ospf priority 255   # guaranteed DR

interface GigabitEthernet0/2
 ip ospf priority 0     # never DR

# Verify DR/BDR
show ip ospf interface GigabitEthernet0/1

Step 7 โ€” OSPF Cost

# Default cost = 100,000,000 / interface bandwidth (bps)
# FastEthernet (100M) = cost 1
# GigabitEthernet (1G) = cost 1 (same as FE โ€” problem!)
# Serial T1 (1.544M) = cost 64

# Fix: change reference bandwidth to 1Gbps
router ospf 1
 auto-cost reference-bandwidth 1000

# Or set cost manually on interface
interface GigabitEthernet0/1
 ip ospf cost 10

# Lower cost = preferred path
show ip ospf interface brief

Step 8 โ€” Multi-Area OSPF

# R2 becomes ABR (Area Border Router) connecting area 0 and area 1
router ospf 1
 router-id 2.2.2.2
 network 10.0.12.0 0.0.0.3 area 0      # backbone
 network 10.0.23.0 0.0.0.3 area 1      # area 1

# R1 in area 0, R3 in area 1
# R3 config:
router ospf 1
 router-id 3.3.3.3
 network 10.0.23.0 0.0.0.3 area 1
 network 192.168.3.0 0.0.0.255 area 1

Step 9 โ€” Passive Interfaces

# Stop sending OSPF Hellos on LAN interfaces (no routers connected)
# Still advertises the network โ€” just doesn't send Hellos
router ospf 1
 passive-interface GigabitEthernet0/0   # LAN interface

# Or set all interfaces passive then enable only on WAN links
router ospf 1
 passive-interface default
 no passive-interface GigabitEthernet0/1   # enable OSPF here

Step 10 โ€” Troubleshooting

# OSPF neighbours won't form? Check:
# 1. Same area number on both sides?
# 2. Same Hello/Dead timers? (must match)
# 3. Same subnet? (must be same network)
# 4. Authentication mismatch?
# 5. MTU mismatch? (causes EXSTART/EXCHANGE loop)

# Check timers
show ip ospf interface GigabitEthernet0/1

# Check MTU
show interface GigabitEthernet0/1 | include MTU

# Debug OSPF (use carefully โ€” can be verbose)
debug ip ospf events
debug ip ospf adj
undebug all   # stop debugging

# Ping across OSPF network
ping 192.168.3.1 source 192.168.1.1

๐Ÿ“‹ OSPF Command Reference

CommandPurpose
show ip ospf neighborView neighbour adjacencies and state
show ip ospf databaseView link-state database
show ip ospf interfaceOSPF settings per interface
show ip ospf interface briefSummary of all OSPF interfaces
show ip route ospfRoutes learned via OSPF
clear ip ospf processReset OSPF (forces re-election)
debug ip ospf eventsLive OSPF event debugging
โœ…
Lab Complete! You can now configure and troubleshoot OSPF. Practice with Cisco Packet Tracer or GNS3 for hands-on router simulation.
Next: VLANs Lab โ†’ โ† All Labs