Course contents

Module 1: Understanding OSPFLesson 1.1 (1 of 4 in this module)1 of 29 in the OSPF course

OSPF overview

How do three routers learn each other's LANs without a static route for every destination? Let's separate finding neighbours, sharing the topology and choosing a path.

Intermediate · 9 min read

Technical definition

OSPF (Open Shortest Path First) is an open-standard, link-state interior gateway protocol. Routers discover neighbours with Hello packets, synchronise link-state information within an area and calculate paths using the shortest path first (SPF) algorithm.

Which routes should OSPF learn for us?

In this three-router chain, OSPF can learn the remote LANs instead of relying on an inter-site static route for each destination. R1 keeps its static default towards the ISP. The examples use OSPFv2 for IPv4 on Cisco IOS / IOS XE. The internal router links and LANs join area 0; R1's ISP-facing Gi0/2 does not run OSPF.

This overview uses a three-router chain: R1 reaches R3 through R2, with no direct R1–R3 backup link. Assume that static routes to the remote internal LANs have been removed, or are not preferred over OSPF, before expecting the route codes below. Keep R1's static default to the ISP. A preferred static route can hide an otherwise eligible OSPF route in the routing table.

Learn more: What Is OSPF?

First understand neighbours, adjacencies and shared-LAN roles

An OSPF neighbour is another router discovered through Hello packets. A Full adjacency is a closer relationship: the routers have completed the required database synchronisation for their shared area. The link-state database (LSDB) is OSPF's map of the topology; a neighbour list and that database are different things.

On a shared broadcast LAN, OSPF elects two roles to organise these relationships and the distribution of updates:

DR: designated router
The elected router that coordinates OSPF adjacencies and flooding (sharing updated link-state information) on this segment. It also originates the segment's type 2 network LSA when it has the required Full adjacency. Being DR does not make it everyone's default gateway.
BDR: backup designated router
The elected backup. It already has Full adjacencies and maintains its database, so it can take the DR role after the existing DR is declared down. Failure detection and recovery still take time.
DROther
A router that is neither DR nor BDR on this segment. It forms Full adjacencies with the DR and BDR, while normally remaining 2-Way with other DROthers. It still learns routes and forwards user traffic.

These roles belong to the shared segment, not the entire OSPF area. Point-to-point OSPF links do not elect them. On a broadcast link, the role after the slash in FULL/DR or FULL/BDR describes the neighbour, not the local router.

Learn more: DR, BDR and DROther explained, with a worked election

Meet, share, calculate

Neighbour discovery, database synchronisation and path calculation are separate jobs. A neighbour is not necessarily a Full adjacency. On a broadcast LAN, two routers that are both DROthers normally stay 2-Way and synchronise through the DR/BDR.

How two routers become neighbours

A link-state advertisement (LSA) is a record describing part of the topology or reachability. A Database Description (DBD) packet summarises records so adjacent routers can discover what they lack. A Link State Request (LSR) asks for a needed record; a Link State Update (LSU) carries one or more LSAs. A Link State Acknowledgment (LSAck) confirms receipt of advertised records. These are protocol messages, not the learner's web traffic.

Read the following exchange from top to bottom. Bidirectional Hellos establish that each router can hear the other. When the routers need an adjacency, they compare database summaries and obtain missing records. Reaching Full means that the required database synchronisation has completed; one acknowledgment alone does not make a neighbour Full.

From bidirectional Hellos to a synchronised adjacency
From bidirectional Hellos to a synchronised adjacencyR1 Gi0/1 is 10.0.12.1/30, router ID 1.1.1.1. R2 Gi0/0 is 10.0.12.2/30, router ID 2.2.2.2. In area 0, bidirectional Hellos establish 2-Way. If an adjacency is required, database descriptions, requests, updates and acknowledgements synchronise the relevant databases before Full.R1R2RID 1.1.1.1RID 2.2.2.2Gi0/110.0.12.1/30Gi0/010.0.12.2/30Hellos · bidirectional → 2-WayDBD · exchange LSA summariesLSR · request missing recordsLSU · send requested LSAsLSAck · confirm receiptFull: required database synchronisation is complete
A simplified OSPFv2 exchange; repeated packets and intermediate states are omitted. This pair forms an adjacency. On a broadcast LAN, two DROthers normally remain 2-Way. Requested LSA updates can be unicast; flooding delivery depends on network type and role. Acknowledging one packet alone does not establish Full.

On a default Cisco broadcast Ethernet interface, OSPFv2 Hellos go to 224.0.0.5 every 10 seconds, with a 40-second dead interval. Network type and configuration can change those values. Check area, timers, subnet and authentication settings when neighbours do not form; use show ip ospf interface to inspect the actual values.

Cost: how OSPF picks a path

OSPF's metric is called cost. Each interface normally derives cost from reference bandwidth ÷ configured interface bandwidth, with a minimum of 1. A manual ip ospf cost overrides this calculation. For alternative intra-area routes to the same prefix, compare the sum of outgoing interface costs, including the destination LAN interface.

InterfaceDefault costWith reference 10000 Mbps
10 Mbps Ethernet101000
100 Mbps FastEthernet1100
1 Gbps GigabitEthernet110
10 Gbps11

With the default, OSPF can't tell 100 Mbps from 10 Gbps. That's why this lab uses auto-cost reference-bandwidth 10000consistently on R1, R2 and R3. The reference is in Mbps; it changes the cost calculation, not the link speed.

Show the outgoing-cost diagram
To reach LAN 3, count three outgoing interface costs
To reach LAN 3, count three outgoing interface costsR1 forwards to R2 over 10.0.12.0/30, then R2 to R3 over 10.0.23.0/30 and R3 to LAN 3, 192.168.3.0/24. With reference bandwidth 10000 Mbps and interface bandwidth 1000 Mbps, each outgoing interface costs 10. Total cost at R1 is 30; next hop is 10.0.12.2, not R3's router ID.R1R2R3Gi0/1 · cost 1010.0.12.1/30Gi0/010.0.12.2/30Gi0/1 · cost 1010.0.23.1/30Gi0/010.0.23.2/30Gi0/1 · 192.168.3.1/24 · cost 10LAN 3 · 192.168.3.0/24Destination subnetSW3R1 metric = 10 + 10 + 10 = 30O 192.168.3.0/24 [110/30] via 10.0.12.2 · Gi0/1
The same single-area lab, with reference bandwidth 10000 Mbps on all three routers and no manual cost override. Cost uses configured interface bandwidth, not measured throughput. The destination LAN interface contributes cost; a Layer 2 switch does not add an OSPF routed-interface cost.

Why big networks split into areas

An area bounds the detailed link-state topology a router maintains. An area border router (ABR) connects areas and keeps a database for each area it joins. Remote reachability can cross the backbone without copying every remote area's internal topology. The configuration in this lesson remains single-area; the sketch below shows how that design can grow.

Show the optional multi-area example
Areas limit the detailed topology each router must track
Areas limit the detailed topology each router must trackA separate multi-area illustration: an internal router in area 1 reaches backbone area 0 through ABR-A. ABR-B connects area 0 to area 2. An ABR has interfaces in multiple areas and maintains a database for each attached area. Remote areas are represented by inter-area reachability, not a full copy of their internal topology.Area 1Area 0 · backboneArea 2R-AABR-AABR-BR-BArea 1 topologyConnect the areasArea 2 topologyDetailed LSDB per area · inter-area reachability through ABRs
A logical area sketch, separate from the single-area configuration below. ABRs have interfaces in multiple areas; an entire ABR is not assigned to just one area. Non-backbone areas need logical connectivity to area 0. Addressing and physical port details are omitted in this scope view.

Turning OSPF on for R1

Before typing, configure and enable the addressed interfaces: R1 Gi0/0 is 192.168.1.1/24, Gi0/1 is 10.0.12.1/30 towards R2 at 10.0.12.2, and Gi0/2 is 203.0.113.2/30 towards the ISP at 203.0.113.1. R2 joins R3 over 10.0.23.0/30. PCs use their local router's LAN IP as their default gateway; return routes must exist too.

Start this block at R1's global configuration prompt, R1(config)#. From R1#, enter configure terminal first. For the full internal address plan and router configurations, follow the linked configuration lesson. That separate lesson uses point-to-point router links; this overview keeps broadcast Ethernet to illustrate the DR/BDR neighbour labels shown below.

Learn more: Complete three-router configuration lesson

Based on Cisco IOS / IOS XE documentation, not run on a lab device. R2 and R3 are set up the same way with their own router IDs and networks.

ip route 0.0.0.0 0.0.0.0 203.0.113.1 router ospf 1 router-id 1.1.1.1 auto-cost reference-bandwidth 10000 network 192.168.1.0 0.0.0.255 area 0 network 10.0.12.0 0.0.0.3 area 0 passive-interface GigabitEthernet0/0 default-information originate

On R1. The network command uses a wildcard mask (the inverse of the subnet mask) to choose which interfaces run OSPF.

  • router ospf 1: the 1 is a local process number. It doesn't need to match between routers.
  • router-id: the router's OSPF name. It must be unique.
  • passive-interface: advertise the LAN, but don't send hellos to the PCs on it.
  • default-information originate: originate a default when R1 has an installed default route. The static route above requires a usable ISP next hop; this example does not use the unconditional originate option.

Keep user-facing LANs passive when they do not need OSPF neighbours. An active LAN interface could admit an unwanted neighbour if its OSPF settings and authentication requirements are satisfied.

Show which R1 interfaces participate
Network statements select interfaces; passive controls Hellos
Network statements select interfaces; passive controls HellosOn R1, network 192.168.1.0 0.0.0.255 area 0 selects Gi0/0 at 192.168.1.1/24, made passive. Network 10.0.12.0 0.0.0.3 area 0 selects active Gi0/1 at 10.0.12.1/30. Gi0/2 at 203.0.113.2/30 is not selected; it reaches the ISP. Wildcards do not change interface subnet masks.network 192.168.1.0 0.0.0.255 area 0network 10.0.12.0 0.0.0.3 area 0R1Gi0/0 · 192.168.1.1/24LAN: advertise prefix, no HellosSelected + passiveGi0/1 · 10.0.12.1/30Transit: Hellos and neighboursSelected + activeGi0/2 · 203.0.113.2/30ISP: no OSPF participationNot selected
This diagram maps configuration to interfaces, rather than packet movement. An operational passive LAN is advertised through OSPF neighbours on active interfaces. The ISP interface is excluded; a separate static default may still use it.

Neighbours FULL, routes marked O

These outputs are based on Cisco documentation, not run on a lab device.

Example output · based on Cisco documentation; exact format varies by platform and software version
R2#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/BDR        00:00:33    10.0.12.1       GigabitEthernet0/0
3.3.3.3           1   FULL/DR         00:00:38    10.0.23.2       GigabitEthernet0/1
Neighbor ID is the remote OSPF identity; Address is the remote interface IP. The DR/BDR labels apply per broadcast segment. Election considers interface priority, then router ID as a tie-breaker; an existing healthy DR is not displaced merely by a better candidate. This output shows roles, not the election history.
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip route ospf
Gateway of last resort is 203.0.113.1 to network 0.0.0.0

O     10.0.23.0/30 [110/20] via 10.0.12.2, 00:03:10, GigabitEthernet0/1
O     192.168.2.0/24 [110/20] via 10.0.12.2, 00:03:10, GigabitEthernet0/1
O     192.168.3.0/24 [110/30] via 10.0.12.2, 00:03:10, GigabitEthernet0/1
Illustrative excerpt: O marks intra-area OSPF routes, 110 is the default administrative distance and 30 is the cost to LAN 3. This assumes 1 Gbps configured interface bandwidth and reference 10000 Mbps on all three routers, without manual cost overrides.

Type commands in the practice lab

The practice lab starts with the chain already configured. First inspect show ip ospf neighbor and show ip route ospf; R1 should learn 192.168.3.0/24 via 10.0.12.2 at cost 30. In its guided failure exercise, making the transit interface passive removes its OSPF neighbours without shutting the cable. Restore it with no passive-interface Gi0/1 in router configuration mode and verify that the neighbour and route return, or use Reset lab to restore the prepared baseline.

An installed route and a successful application test are different checks. This browser lab supports only the documented command subset. Its expected output is an educational model, not a measurement from your own router or a guarantee of Internet access.

Simulated R1 terminal. Type supported IOS commands and inspect the result. R2 and R3 are preconfigured. Outputs are simplified teaching examples, not responses from real equipment. Changes last until reset or page reload.

R1 is ready. Try show ip ospf neighbor, or ? for help.

One command at a time. Enter runs it; ↑ and ↓ recall recent commands. Use ? for help in the current mode.

R1 reference: 10000 Mbps · transit: active · LAN: passive

Ready. Type a command and press Enter.

Try a guided troubleshooting exercise
  1. Inspect routes with show ip route ospf.
  2. Enter enable, configure terminal, then router ospf 1.
  3. Type passive-interface Gi0/1, then do show ip ospf neighbor.
  4. Compare do ping 10.0.12.2 with do ping 192.168.3.10. The link is up, but the OSPF neighbour and remote routes are gone.
  5. Check do show ip route 192.168.3.10: the default still matches, but this lab ISP cannot reach LAN 3.
  6. Restore no passive-interface Gi0/1. Try auto-cost reference-bandwidth 100 and inspect routes again. Only R1 changes, so the remote route becomes cost 21. Reset to restore the consistent 10000 Mbps reference on all routers.

Test yourself on the OSPF overview

Predict · scenario 1

R1 and R2 are cabled, but R1 is in area 0 and R2's interface is in area 1. What happens?

Predict · scenario 2

Two paths: three 1 Gbps links, or one 100 Mbps link, all at default reference bandwidth. Which does OSPF choose?

Predict · scenario 3

Two OSPF neighbours are both DROthers on the same broadcast LAN. They remain 2-Way with each other. Is that necessarily a fault?

References: RFC 2328 routing-protocol packets, Cisco neighbour states, OSPF costs and behaviour, and IOS XE configuration guide.