What OSPF is
OSPF (Open Shortest Path First, RFC 2328) is a link-state protocol. Instead of passing routes like RIP, each router describes its own links in LSAs (Link State Advertisements). All routers in the area keep the same database (LSDB) and each one calculates the shortest-path tree with Dijkstra's algorithm. It runs directly over IP (protocol 89), its metric is cost and its administrative distance on Cisco is 110.
An interface's cost is the reference bandwidth (100 Mb/s by default) divided by the interface bandwidth. That's why FastEthernet, GigabitEthernet and 10 GigabitEthernet all have cost 1 unless the reference is raised with auto-cost reference-bandwidth.
A neighbor's states
| State | What it means | In this lab |
|---|---|---|
| Down | No Hello has been received | Before step 1 |
| Init | A Hello arrived, but the neighbor doesn't list me yet | R1 sees R2 (step 1) |
| 2-Way | Both see each other; DR and BDR are elected here | Step 2 |
| ExStart | Who's the master is decided | Step 3 |
| Exchange | LSA headers are sent (DBD) | Step 4 |
| Loading | Missing LSAs are requested and received | Step 5 |
| Full | Both databases are identical | From step 5 |
How it works: from the first Hello to the O route
Seven steps: R2's Hello, 2-Way with the DR and BDR election, ExStart, Exchange, Loading up to FULL, the new LSAs and the Network-LSA, and the acks with the SPF calculation.
Hello: R1 discovers R2 (INIT)
R2 turns on OSPF and sends a Hello to 224.0.0.5, the group of all OSPF routers. It carries its Router ID, the area, the mask, the timers (Hello 10 s, Dead 40 s) and the priority. DR, BDR and neighbors are empty: it doesn't know anything yet. R1 receives the Hello, checks that area, mask and timers match and puts R2 in the INIT state: "I hear you, but you haven't seen me yet".
2-Way and the DR/BDR election
R1 answers with a Hello that lists 2.2.2.2 as a neighbor and declares itself the segment's DR. R2 sees itself in the list: 2-WAY state. Since R1 already claims DR and there's no BDR, R2 doesn't wait the 40 s election period and becomes BDR. Even though R2's Router ID is higher, the DR isn't replaced while it's up: there's no preemption. R2 sends its Hello listing R1, with DR 10.0.12.1 and BDR 10.0.12.2, and R1 also moves to 2-WAY.
ExStart: who's the master
Since R2 is the BDR, it must form a full adjacency with the DR. Both move to EXSTART and send an empty Database Description with the I (init), M (more) and MS (master) bits, each with its own sequence number. Comparing Router IDs, 2.2.2.2 is higher: R2 will be the master and set the sequence; R1 will be the slave. These DBDs go straight to the neighbor (unicast), not to the multicast group.
Exchange: the database summary
R1, as the slave, answers with the master's sequence and the header of its Router-LSA (1.1.1.1). The master increases the sequence by one and sends the header of its Router-LSA (2.2.2.2). R1 repeats that sequence to confirm. Only 20-byte headers travel: type, Link State ID, advertising router, sequence number and checksum. With them, each router knows which LSAs it's missing or has outdated.
Loading: asking for what's missing (FULL)
Each router asks with an LS Request for the LSA it didn't have, and the other sends it in full in an LS Update, straight to the neighbor. The LSA carries all its links: each one describes the WAN link as stub (they had no FULL neighbor yet) and its LAN. With both databases identical, the adjacency reaches FULL and Cisco logs it with %OSPF-5-ADJCHG.
FULL: new LSAs and the DR's Network-LSA
Now there's a FULL neighbor on the segment, so both change their Router-LSA: the WAN link is no longer stub and becomes transit, pointing to the DR (10.0.12.1). Each new LSA increases its sequence number. Also, R1, as the DR, creates the segment's Network-LSA (type 2) with its mask and the two attached routers. They flood them to 224.0.0.5, because both are DR or BDR.
Acks and SPF: the route to Montreal
Each router acknowledges the LSAs it received with an LS Acknowledgment, grouped in a single packet. With the database complete, each one runs SPF (Dijkstra) with itself as the root. R1 reaches 192.168.30.0/24 through R2: cost 1 for the WAN link plus 1 for the Montreal LAN, and installs it as "O … [110/2]". R2 does the same toward Vancouver.
The five message types
| Type | Message | What it's for |
|---|---|---|
| 1 | Hello | Discover neighbors, elect the DR/BDR and keep the adjacency alive |
| 2 | Database Description (DBD) | Summarize the database with LSA headers |
| 3 | Link State Request (LSR) | Ask for specific LSAs |
| 4 | Link State Update (LSU) | Send full LSAs |
| 5 | Link State Acknowledgment (LSAck) | Confirm they arrived |
DR and BDR on an Ethernet segment
On a multi-access network (broadcast type, Ethernet's), routers elect a DR and a BDR so that not everyone forms adjacencies with everyone. The highest priority wins (1 by default; 0 means never DR) and, on a tie, the highest Router ID. The election has no preemption: if a better router arrives, the current DR stays. The other routers (DROTHER) go FULL only with the DR and BDR, and stay in 2-WAY among themselves.
On a link with only two routers, like the one in this lab, the DR adds nothing. That's why WAN links are usually configured with ip ospf network point-to-point: no election, no Network-LSA and a faster adjacency.
How the Router ID is chosen
- The value set with router-id under router ospf.
- If there's none, the highest IP of an active loopback interface.
- If there's no loopback, the highest IP of an active physical interface.
- A Router ID change only applies after clear ip ospf process or a reload.
OSPF on Cisco IOS XE
| Command | What it does |
|---|---|
router ospf 1 | Starts process 1 (the number is local and doesn't have to match). |
network 10.0.12.0 0.0.0.3 area 0 | Turns on OSPF on the interfaces in that network, with a wildcard mask. |
ip ospf 1 area 0 | Per-interface alternative to the network command. |
passive-interface GigabitEthernet0/0/1 | Advertises the LAN without sending Hellos on it. |
ip ospf priority 0 | Per interface: the router will never be DR or BDR. |
show ip ospf neighbor | Neighbors, state (FULL/DR, FULL/BDR, 2WAY/DROTHER) and Dead time. |
show ip ospf interface brief | Interfaces, cost, state (DR, BDR, DROTHER, P2P) and neighbors. |
show ip ospf database | The LSDB: Router-LSAs, Network-LSAs and their sequence numbers. |
show ip route ospf | The O routes with [110/cost]. |
What happens when it fails
- The routers don't see each other: check they're in the same area and subnet, with the same Hello and Dead, and that the interface isn't passive.
- They get stuck in EXSTART or EXCHANGE: it's almost always a different MTU at each end.
- Two routers with the same Router ID: Cisco logs a duplicate Router ID warning and the adjacency doesn't work.
- A DROTHER stays in 2-WAY with another DROTHER: that's normal, not a failure.
- Routes with unexpected cost: the reference bandwidth isn't the same on every router.
Frequently asked questions
Why does R1 stay DR if R2 has a higher Router ID?
Because the election has no preemption: the DR only changes if it goes down. R1 was already DR when R2 arrived, so R2 becomes BDR.
What decides who's the master in ExStart?
The higher Router ID. It has nothing to do with the DR: here R1 is the DR, but R2 is the master of the exchange.
Why are there two versions of the same Router-LSA?
Because the WAN link changed: before the adjacency it was stub; with a FULL neighbor it becomes transit. Every change creates an LSA with a higher sequence number.
What's the LLS block at the end of the Hello?
Link-Local Signaling (RFC 5613): extra data Cisco adds to Hellos and DBDs, flagged with the L bit. Here it advertises that the router can resynchronize the database without dropping the adjacency.
What does CCNA v2.0 ask about OSPF?
Topic 3.3 asks you to configure single-area OSPFv2 (and OSPFv3 for IPv6): neighbor adjacencies without authentication, point-to-point networks, broadcast networks with DR/BDR selection, and Router ID. This lab walks through the adjacency on a broadcast network; the page explains point-to-point.
Key takeaways
- OSPF is link state: it shares LSAs, not routes, and every router runs SPF.
- Hello to 224.0.0.5 every 10 s; neighbors must match on area, subnet, timers and authentication.
- States: Down, Init, 2-Way, ExStart, Exchange, Loading and Full.
- DR and BDR: priority wins, then Router ID, with no preemption; the ExStart master is the higher Router ID.
- A Router-LSA (type 1) per router, the DR's Network-LSA (type 2); the resulting route is O [110/cost].
NEXT STEP
From this lesson to the Canadá Logística network
In the CCNA 2.0 Course you configure OSPF at Canadá Logística's three sites, tune priorities, Router IDs and network types, and read neighbors and databases the way the exam asks, in Packet Tracer or CML. We'll let you know when it opens.
Upcoming labs
Sources
- RFC 2328 · OSPF Version 2
- RFC 5613 · OSPF Link-Local Signaling
- Cisco · Understand OSPF Neighbor States (doc. 13685)
- Cisco · Troubleshoot OSPF Neighbor Problems (doc. 13699)
- Cisco · 200-301 CCNA v2.0 Exam Topics (3.3)
Lesson prepared with AI assistance and checked against the sources cited. The bytes of every packet are generated according to the standard and verified with an independent tool.