Cyber Services / All lessons / CCNA — Networking / Day 8 — Dynamic Routing & OSPF

Day 8 — Dynamic Routing & OSPF

Module 8 of 12 · 6 min read · Free to read

MODULES ↓ Command blocks have a COPY button

OSPF Concepts & Configuration

Understanding and implementing Open Shortest Path First routing protocol

OSPF Features
OSPF Packets
OSPF Operation
OSPF Configuration

OSPF Introduction

Open Shortest Path First - A Link-State Routing Protocol

What is OSPF?
  • Link-state routing protocol
  • Faster convergence than RIP
  • Scales to larger network implementations
  • Uses concept of areas for scalability
  • Uses Dijkstra's SPF algorithm
OSPF Components
  • 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

Link-State Operation
1

Establish Neighbor Adjacencies

Discover and form relationships with neighboring OSPF routers

2

Exchange Link-State Advertisements

Share information about connected links and their states

3

Build Link-State Database

Create a complete topology map of the network

4

Execute SPF Algorithm

Calculate shortest paths to all destinations

5

Choose Best Route

Populate routing table with optimal paths

Single-Area vs Multiarea OSPF

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

OSPF Packet Types
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
Hello Packet Details
  • 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)
# Verify OSPF interfaces and timers
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

OSPF Operational States
1

Down State

No Hello packets received from neighbor

2

Init State

Hello packet received but bidirectional communication not established

3

Two-Way State

Bidirectional communication established with neighbor

4

ExStart State

Master/slave relationship established for DBD exchange

5

Exchange State

Routers exchange DBD packets

6

Loading State

Routers exchange LSR and LSU packets

7

Full State

Adjacency established, databases synchronized

Designated Router (DR) Concept

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.
# Verify OSPF neighbors and their roles
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

Basic OSPF Configuration
# Enable OSPF with process ID
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
Default Route Originate

Purpose

Propagates a default route (0.0.0.0/0) into the OSPF domain. Useful for edge routers connecting to the Internet.

Command

# Advertise default route if present in routing table
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 always is used.
  • Other routers will see this as O*E2 route.
Point-to-Point Networks
  • 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.
# Change network type to point-to-point
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
NBMA Networks
  • 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.
# Manually define neighbor in NBMA
R1(config-router)# neighbor 192.168.1.2

# Or change network type
R1(config-if)# ip ospf network point-to-multipoint
Multiaccess (Broadcast)
  • 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).
# Set OSPF priority to influence DR election
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 Cost Calculation

OSPF uses cost as its metric, with lower values indicating better paths:

# OSPF Cost Formula
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:

# Adjust reference bandwidth for Gigabit networks
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
Manipulating OSPF Cost

Manually adjust interface cost to influence path selection:

# Manually set OSPF cost on an interface
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
# Verify OSPF routes and their costs
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

Verification Commands
# Show OSPF neighbors and their states
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
Troubleshooting Commands
# Check OSPF packet statistics
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
Modules (12) ← CCNA — Networking