# Days 26, 27, 28: OSPF

# CCNA Study Guide: OSPFv2 (Exam Topic 3.4)

## 1.0 OSPFv2 Fundamentals: The Link-State Advantage

Open Shortest Path First (OSPF) is a Link-State Interior Gateway Protocol (IGP). Unlike distance-vector protocols that rely on "routing by rumor," OSPF routers build a complete, synchronized map of the network topology.

### The Metaphor: The GPS vs. The Signpost

- Distance Vector (RIP): Like a signpost. It tells you "Network X is 4 miles that way," but you don't know what the road looks like or if there is a bridge out further ahead.
- Link-State (OSPF): Like a GPS map. Every router has a complete map of every "road" (link) and "intersection" (router) in the area. Each router can independently calculate the best path using the map.

### Core Characteristics

<div align="left" dir="ltr" id="bkmrk-attribute-descriptio"><table><colgroup><col width="175"></col><col width="398"></col></colgroup><tbody><tr><td>Attribute

</td><td>Description

</td></tr><tr><td>Protocol Type

</td><td>Link-State IGP

</td></tr><tr><td>Algorithm

</td><td>Dijkstra’s Shortest Path First (SPF)

</td></tr><tr><td>Admin Distance (AD)

</td><td>110

</td></tr><tr><td>Multicast Addresses

</td><td>224.0.0.5 (All OSPF Routers), 224.0.0.6 (DR/BDR)

</td></tr></tbody></table>

</div>## 2.0 The Path to Adjacency: OSPF Core Operations

OSPF routers must go through a structured process to become fully adjacent and synchronize their Link State Database (LSDB).

### The 3-Step Process

1. Become Neighbors: Routers discover each other via Hello packets.
2. Exchange LSAs: Routers share Link State Advertisements (LSAs) to synchronize their databases.
3. Calculate Routes: Once the LSDB is identical, each router runs the SPF algorithm to find the best paths.

### OSPFv2 Neighbor States

<div align="left" dir="ltr" id="bkmrk-state-description-do"><table><colgroup><col width="95"></col><col width="510"></col></colgroup><tbody><tr><td>State

</td><td>Description

</td></tr><tr><td>Down

</td><td>No Hellos received.

</td></tr><tr><td>Init

</td><td>Hello received, but your own Router ID is not in the neighbor's list.

</td></tr><tr><td>2-Way

</td><td>Bidirectional communication confirmed (DR/BDR election happens here).

</td></tr><tr><td>ExStart

</td><td>Determining Master/Slave relationship for data exchange.

</td></tr><tr><td>Exchange

</td><td>Exchanging Database Descriptors (DBDs) (summaries of the LSDB).

</td></tr><tr><td>Loading

</td><td>Requesting specific missing info via LSRs and LSUs.

</td></tr><tr><td>Full

</td><td>LSDBs are fully synchronized. Normal operation.

</td></tr></tbody></table>

</div>## 3.0 Essential OSPF Components

### 3.1 Router ID (RID) Selection

The RID is a unique 32-bit identifier for the router. It is selected in this order:

1. Manual Configuration: router-id 1.1.1.1 (Best Practice).
2. Highest Loopback IP: Highest IP on any active loopback interface.
3. Highest Physical IP: Highest IP on any active physical interface.

### 3.2 The OSPF Metric: Cost

OSPF calculates cost based on interface bandwidth. A lower cumulative cost is preferred.

$$Cost = \\frac{Reference\\ Bandwidth}{Interface\\ Bandwidth}$$

Important: The default reference bandwidth is 100 Mbps. On modern networks (Gigabit or 10G), you must manually increase this to ensure OSPF can distinguish between different high-speed links.

- Command: auto-cost reference-bandwidth 1000 (for 1 Gbps links).

### 3.3 LSA Types (CCNA Focus)

- Type 1 (Router LSA): Sent by every router; describes its own links/interfaces.
- Type 2 (Network LSA): Generated by the Designated Router (DR); describes the routers on a multi-access segment.
- Type 5 (External LSA): Describes routes redistributed from outside the OSPF domain (e.g., a Static Route).

## 4.0 Network Types and the DR/BDR Election

On multi-access networks (like Ethernet), OSPF elects a Designated Router (DR) and a Backup Designated Router (BDR) to manage LSA flooding and reduce the number of adjacencies.

<div align="left" dir="ltr" id="bkmrk-feature-broadcast-%28e"><table><colgroup><col width="159"></col><col width="174"></col><col width="184"></col></colgroup><tbody><tr><td>Feature

</td><td>Broadcast (Ethernet)

</td><td>Point-to-Point (Serial)

</td></tr><tr><td>DR/BDR Election

</td><td>Yes

</td><td>No

</td></tr><tr><td>Hello / Dead Timer

</td><td>10s / 40s

</td><td>10s / 40s

</td></tr></tbody></table>

</div>### DR/BDR Election Hierarchy

1. Highest Interface Priority: Default is 1. A priority of 0 makes a router ineligible.
2. Highest Router ID: The tie-breaker if priorities are equal.

Note: The election is non-preemptive. If a new router with a higher priority joins the network, it will not become the DR until the current DR/BDR process is reset or the current DR fails.

## 5.0 OSPFv2 Configuration

### 5.1 Basic Implementation

\# Method 1: Traditional Network Command

Router(config)# router ospf 1

Router(config-router)# router-id 1.1.1.1

Router(config-router)# network 10.1.1.0 0.0.0.255 area 0

\# Method 2: Interface-level Command (Preferred)

Router(config)# interface g0/0

Router(config-if)# ip ospf 1 area 0

### 5.2 Common Optimizations

- Passive Interface: Prevents Hellos from being sent to user segments (Security/Efficiency).
- passive-interface g0/1

- Default Route Propagation:
- default-information originate (Injects the 0.0.0.0/0 route into OSPF).


## 6.0 Troubleshooting OSPF Adjacency Issues

If two routers fail to reach the FULL state, check for mismatches in these parameters:

1. Area ID: Must match.
2. Subnet &amp; Mask: Must be on the same primary subnet.
3. Hello/Dead Timers: Must match (Default 10/40).
4. Authentication: Passwords and types must match.
5. MTU Size: If they mismatch, routers get stuck in ExStart/Exchange.
6. Unique Router IDs: Duplicate RIDs prevent adjacency.

## TL;DR Summary

- Link-State: OSPF uses a map (LSDB), not rumors.
- Election: Lowest Bridge ID wins (Priority, then RID).
- Cost Formula: Reference Bandwidth / Interface Bandwidth.
- Convergence: Moves through 7 states; FULL is the goal.
- Multi-access: Uses DR/BDR to reduce LSA flooding on Ethernet.
- Troubleshooting: Check Area, Timers, Subnet, and MTU if adjacencies fail.