---
title: "OSPF for CCNA: Single Area OSPFv2 | CyberWithMadhav"
description: "Free CCNA lesson on single area OSPFv2: link state basics, neighbour states, router ID, DR and BDR election, cost and reference bandwidth, with a lab."
url: https://www.cyberwithmadhav.com/learn-ccna-ospf.html
source_format: markdown rendering of the HTML page
---

[Learn](https://www.cyberwithmadhav.com/learn.html) / [Stage 3: Networking and CCNA](https://www.cyberwithmadhav.com/learn.html#stage-3) / Lesson 3.8

$ lesson 3.8 --track ccna --domain routing

# Single Area OSPFv2: Neighbours, DR/BDR, Cost and Troubleshooting

Static routes do not notice when a link dies. OSPF does. Learn how routers discover each other, agree on one map of the network, elect a DR on shared LANs, choose paths by cost, and how a single mismatched timer can quietly break it all.

- Stage **3** Networking and CCNA
- Level **Intermediate to advanced**
- **70** min
- **6** sections, quiz, lab

Start the lesson Jump to the lab

## In this lesson

1. Link state routing in plain words
2. Becoming neighbours: states, timers and the must-match list
3. DR and BDR on shared LANs, and why point to point skips it
4. Configuring single area OSPF
5. Cost: how OSPF picks the best path
6. Practise on R1
7. Flashcards
8. Quick quiz
9. Hands-on lab
10. Key takeaways

## By the end of this lesson you can

- Explain how OSPF neighbours form and build a shared LSDB
- Configure single area OSPFv2 with a fixed router ID and passive interfaces
- Predict DR and BDR election results and use point to point links
- Read OSPF costs and equal cost paths in the routing table
- Troubleshoot neighbours that will not reach FULL

3.8.01

## Link state routing in plain words

Static routes from lesson 3.7 work until a link fails and nobody updates them. A **dynamic routing protocol** lets routers tell each other what they can reach and recalculate when something changes. **OSPF** (Open Shortest Path First) is the open standard one you will meet everywhere, and OSPFv2 carries IPv4.

1. Each router finds **neighbours** by sending hello packets out of its OSPF interfaces (to multicast 224.0.0.5).
2. Neighbours exchange **LSAs** (link state advertisements): descriptions of each router's links, subnets and costs.
3. Every router in an **area** ends up with an identical **link state database** (LSDB), a map of the area.
4. Each router runs the **SPF** (Dijkstra) algorithm on that map, with itself as the root, and installs the lowest cost paths in its routing table as `O` routes with administrative distance 110.

Think of it like this

Distance vector protocols work like asking for directions: each neighbour only tells you how far a place is. OSPF gives every router the same complete city map, and each one plans its own shortest route on it.

This lesson covers **single area** OSPF: everything is in area 0, the backbone. Multi area design exists for large networks and is beyond CCNA depth.

3.8.02

## Becoming neighbours: states, timers and the must-match list

Two routers move through these states. Full means their databases are synchronised. On a shared LAN, two routers that are neither DR nor BDR stop at 2-Way with each other, and that is normal.

Hellos go out every **10 seconds** on Ethernet, and a neighbour is declared dead after **40 seconds** of silence (the dead interval). Two routers only become neighbours when these match:

| Must match | What happens if it does not |
| --- | --- |
| Area ID | No adjacency. The hello is ignored. |
| Subnet and mask on the link | No adjacency on broadcast links. |
| Hello and dead intervals | No adjacency. Changing one side drops an existing neighbour when the dead timer runs out. |
| Authentication settings | No adjacency. |
| Stub area flag | No adjacency (not used in this lesson). |
| MTU | Neighbours get stuck in ExStart or Exchange. |

What does *not* need to match: the **process ID** in `router ospf 1`. It is local to the router. Router IDs must be unique.

**Router ID** (a 32 bit name written like an IPv4 address) is chosen in this order: the `router-id` command; else the highest IP on a loopback interface that is up; else the highest IP on an active physical interface. A router ID only changes when the process restarts, so after changing it you run `clear ip ospf process`.

3.8.03

## DR and BDR on shared LANs, and why point to point skips it

If ten routers share one Ethernet segment and every pair formed a full adjacency, that would be 45 adjacencies flooding the same updates. OSPF instead elects a **designated router (DR)** and a **backup (BDR)**. Everyone forms a Full adjacency with the DR and BDR; the others (**DROTHERs**) stay at 2-Way with each other.

- Highest **OSPF interface priority** wins (default 1, range 0 to 255). Priority 0 means "never be DR or BDR".
- On a tie, the highest **router ID** wins.
- The election is **not preemptive**. A router that joins later with a higher priority does not take over. The DR changes only if it fails (then the BDR is promoted) or the OSPF processes are restarted.

A link with only two routers (a /30 between R1 and R3, say) gains nothing from an election. `ip ospf network point-to-point` on both ends removes the DR/BDR step and the wait that comes with it, so the adjacency forms faster. Both ends must use the same network type.

| Command | Where | Effect |
| --- | --- | --- |
| `ip ospf priority 200` | Interface | Makes this router the likely DR on that segment (at the next election). |
| `ip ospf priority 0` | Interface | Never DR or BDR on that segment. |
| `ip ospf network point-to-point` | Interface, both ends | No DR/BDR election; neighbour shows FULL/ -. |

3.8.04

## Configuring single area OSPF

```
R1(config)#interface Loopback0
R1(config-if)#ip address 1.1.1.1 255.255.255.255
R1(config-if)#exit
R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 172.16.100.0 0.0.0.255 area 0
R1(config-router)#network 10.0.13.0 0.0.0.3 area 0
R1(config-router)#network 192.168.1.0 0.0.0.255 area 0
R1(config-router)#network 1.1.1.1 0.0.0.0 area 0
R1(config-router)#passive-interface GigabitEthernet0/0/1
R1(config-router)#auto-cost reference-bandwidth 10000
! alternative to network statements, per interface:
R1(config)#interface GigabitEthernet0/0/1
R1(config-if)#ip ospf 1 area 0
```

- A `network` statement does not advertise a prefix by itself. It says "run OSPF on every interface whose IP falls in this range", and those interfaces' subnets get advertised. It uses a **wildcard** mask: 0.0.0.255 for a /24, 0.0.0.3 for a /30, 0.0.0.0 for exactly one address.
- `passive-interface` stops hellos on a LAN port but still advertises its subnet. Every user facing interface should be passive. `passive-interface default` followed by `no passive-interface` on router links is the safer habit.
- `default-information originate` shares this router's default route with the rest of the area. Others see it as `O*E2 0.0.0.0/0`.

3.8.05

## Cost: how OSPF picks the best path

OSPF's metric is **cost**, added up along the path. Interface cost = reference bandwidth / interface bandwidth, with a minimum of 1. The default reference is 100 Mb/s, which means FastEthernet, Gigabit and 10 Gigabit links all cost 1 and OSPF cannot tell them apart.

| Link | Cost, reference 100 (default) | Cost, reference 10000 |
| --- | --- | --- |
| 100 Mb/s | 1 | 100 |
| 1 Gb/s | 1 | 10 |
| 10 Gb/s | 1 | 1 |

Fix it with `auto-cost reference-bandwidth 10000` (in Mb/s) on **every** router, or set a link's cost directly with `ip ospf cost N`. In the routing table, `[110/20]` means AD 110 and total cost 20. If two paths have the same cost, OSPF installs both (up to 4 by default on IOS) and shares the load.
How attackers abuse this

A laptop on a user VLAN running routing software can speak OSPF. If that VLAN's router interface is not passive, the laptop can form an adjacency and advertise fake routes (even a better default route), pulling traffic through itself for interception or into a black hole.
Defender move

Passive interfaces everywhere users live; OSPF authentication between routers (MD5 or HMAC-SHA where your platform supports it); ACLs that drop OSPF (IP protocol 89) arriving from user ports; and watching the `%OSPF-5-ADJCHG` log messages, because an unexpected new neighbour is an incident.

3.8.06

## Practise on R1

R1's interfaces are already addressed. R2 and R3 are modelled by this console: R2 has already been given OSPF priority 200 on the shared LAN by a colleague, and R3's end of the point to point link is configured to match whatever you do. All three routers use the same reference bandwidth. Treat outputs as a close guide, not a real protocol run.

console: R1 (R1 OSPF console)

#### Missions  0/16

Simplified IOS simulator in your browser. It teaches the commands; Packet Tracer and real gear have many more.

## Flashcards: do you remember?

Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.

## Quick quiz

Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.

### Q1 Two routers on the same link show no OSPF neighbour. Which mismatch causes this?

### Q2 A router with priority 255 joins a LAN that already has a DR with priority 1. What happens?

### Q3 Two DROTHERs on a shared LAN show 2WAY/DROTHER with each other. This is:

### Q4 With the default reference bandwidth, what is the cost of a 10 Gb/s link?

### Q5 Which wildcard matches the 10.0.13.0/30 subnet in a network statement?

### Q6 Why make LAN interfaces passive?

**0 / 6**

## Hands-on lab

Cisco Packet Tracer lab  55 minutes  simulated network

### Packet Tracer lab 3.8: OSPF with DR election and a point to point link

**You need:** Cisco Packet Tracer (free with a Cisco Networking Academy account; version 9.0.1 was the current download on the NetAcad Resource Hub when this lesson was written). Devices: 3 x ISR4331, 4 x 2960 (SW0 for the shared LAN plus one per LAN), 3 x PC-PT.

**Simulator lab, zero risk.** This lab runs inside Cisco Packet Tracer, so it touches no real network. Packet Tracer is free with a Cisco Networking Academy account (netacad.com). It simulates a subset of Cisco IOS, so where support for a feature is uncertain we say so instead of promising it works.

#### Topology and addressing

R1, R2 and R3 Gi0/0/0 on SW0 (172.16.100.0/24). Each Gi0/0/1 to its own LAN switch. R1 Gi0/0/2 to R3 Gi0/0/2 (10.0.13.0/30).

| Device | Interface | IPv4 address / prefix | Default gateway or note |
| --- | --- | --- | --- |
| R1 | Gi0/0/0 / Gi0/0/1 / Gi0/0/2 | 172.16.100.1/24 / 192.168.1.1/24 / 10.0.13.1/30 | Lo0 1.1.1.1/32 |
| R2 | Gi0/0/0 / Gi0/0/1 | 172.16.100.2/24 / 192.168.2.1/24 | Lo0 2.2.2.2/32 |
| R3 | Gi0/0/0 / Gi0/0/1 / Gi0/0/2 | 172.16.100.3/24 / 192.168.3.1/24 / 10.0.13.2/30 | Lo0 3.3.3.3/32 |
| PC1 / PC2 / PC3 | Fa0 | 192.168.1.10 / 192.168.2.10 / 192.168.3.10 (/24) | gateway .1 in each LAN |

1. Address everything, including loopbacksUse the table. Bring every router interface up with `no shutdown` and ping across each link before touching OSPF.  Done
2. OSPF on R1 (adapt the networks for R2 and R3)`R1(config)#  router ospf 1   R1(config-router)#  router-id 1.1.1.1   R1(config-router)#  network 172.16.100.0 0.0.0.255 area 0   R1(config-router)#  network 10.0.13.0 0.0.0.3 area 0   R1(config-router)#  network 192.168.1.0 0.0.0.255 area 0   R1(config-router)#  network 1.1.1.1 0.0.0.0 area 0   R1(config-router)#  passive-interface GigabitEthernet0/0/1   R1(config-router)#  auto-cost reference-bandwidth 10000   R1(config)#  interface GigabitEthernet0/0/2   R1(config-if)#  ip ospf network point-to-point`Use the same reference bandwidth on all three routers and set point to point on R3's Gi0/0/2 too.  Done
3. Make R2 the DR`R2(config)#  interface GigabitEthernet0/0/0   R2(config-if)#  ip ospf priority 200   R1#  clear ip ospf process   Reset ALL OSPF processes? [no]: yes`Run `clear ip ospf process` on all three routers, because the election is not preemptive.  Done
4. Share a default route from R1`R1(config)#  interface Loopback1   R1(config-if)#  ip address 203.0.113.1 255.255.255.255   R1(config-if)#  exit   R1(config)#  ip route 0.0.0.0 0.0.0.0 Loopback1   R1(config)#  router ospf 1   R1(config-router)#  default-information originate`  Done
5. Break and fix`R3(config)#  interface GigabitEthernet0/0/0   R3(config-if)#  ip ospf hello-interval 5   ! wait for the dead timer, watch the ADJCHG messages, then:   R3(config-if)#  no ip ospf hello-interval`  Done
6. Verify`R1#  show ip ospf neighbor   R1#  show ip ospf interface brief   R1#  show ip protocols   R2#  show ip route ospf   R1#  show ip ospf database`  Done

**You are done when:** On R1, show ip ospf neighbor lists R2 as FULL/DR and R3 as FULL/BDR on Gi0/0/0, and R3 again as FULL/ - on Gi0/0/2. R2 and R3 show O routes to the other LANs and an O*E2 default route. PC1 pings PC2 and PC3.

#### Packet Tracer limits and notes

- You will not see 2WAY/DROTHER with only three routers. Add a fourth router to SW0 if you want to see two DROTHERs at 2-Way with each other.
- `show ip ospf interface brief` is reported by a third party site as added in Packet Tracer 8.2. UNVERIFIED against Cisco release notes; use `show ip ospf interface` if it is missing.
- `ip ospf network point-to-point` on Packet Tracer Ethernet interfaces is UNVERIFIED. If it is rejected, leave that link as broadcast: the two routers will elect a DR and BDR, and everything else still works.
- The interface form `ip ospf 1 area 0` is UNVERIFIED on every Packet Tracer image. The network statements above are the reliable way.
- OSPF authentication in Packet Tracer is UNVERIFIED and outside this lesson's depth.
- Packet Tracer simulates a subset of IOS. If a command here is rejected in your version, note it, skip that step and carry on; the concept still applies to real Cisco gear.

[Download the lab checklist (.txt)](https://www.cyberwithmadhav.com/assets/learn/learn-ccna-ospf-lab-checklist.txt)  Print it or keep it open beside Packet Tracer.

## Key takeaways

- OSPF routers share one map per area and each runs SPF on it.
- Area, subnet, timers and authentication must match; the process ID does not.
- DR and BDR: highest priority then router ID, and the election is not preemptive.
- Raise the reference bandwidth on every router so fast links get different costs.
- Make user facing interfaces passive, and treat an unexpected new neighbour as an incident.

Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.

[Previous 3.7 The Routing Table and Static Routing (IPv4 and IPv6)](https://www.cyberwithmadhav.com/learn-ccna-static-routing.html)[Next 3.9 Access Control Lists: Standard, Extended, Named and VTY Protection](https://www.cyberwithmadhav.com/learn-ccna-access-control-lists.html)
