OSPFv2 Fundamentals
OSPF is the open-standard, link-state routing protocol that dominates enterprise IPv4 networks. Instead of swapping rumours, every router builds an identical map of the network and computes the shortest path itself. This lesson gives you the vocabulary — areas, router ID, cost, timers, LSAs — before the configuration in Lesson 20.
- Contrast link-state routing with distance-vector routing.
- Explain how OSPF uses LSAs, the link-state database, and Dijkstra’s SPF algorithm.
- Describe areas and the special role of area 0 (backbone).
- Determine a router’s router ID and calculate the OSPF cost metric.
- State the default hello and dead timers and the multicast addresses OSPF uses.
- Recall OSPF’s administrative distance of 110.
From distance-vector to link-state
RIP is a distance-vector protocol: it learns routes from its neighbours’ reports of distance and direction, sight unseen. It works, but every router sees only what its neighbours tell it, convergence is slow, and loops are only prevented by mechanisms such as split horizon. OSPF takes a different approach. As a link-state protocol it floods information about the state of each link to every router in an area, so each router builds a complete, identical topology map and computes the best paths itself.
| Aspect | Distance-vector (RIP) | Link-state (OSPF) |
|---|---|---|
| What is shared | Whole routing table entries (destinations and distances) | Local link states, flooded unchanged area-wide |
| Each router knows | Only its neighbours' view | An identical map of the whole area |
| Path computation | Bellman-Ford; incremental updates | Dijkstra SPF on the full database |
| Convergence | Slow, loop-prone | Fast, loop-free within an area |
| Metric | Hop count (max 15) | Cost based on bandwidth |
| Default AD | 120 | 110 |
The trade-off is resource use. OSPF stores a database and runs a graph algorithm, so it asks more of CPU and memory than RIP. In exchange it scales to large networks, converges quickly, and is supported by virtually every vendor, which is why it is the enterprise default.
How OSPF builds its map
Each router describes its own directly connected links in a link-state advertisement (LSA). LSAs are flooded to every other router in the same area and stored in the link-state database (LSDB). Because flooding is reliable and every router receives every LSA, all routers in an area end up with the same database — the same map. Each then runs Dijkstra’s shortest path first (SPF) algorithm over that map, rooted at itself, and installs the resulting best paths into the routing table.
Areas and the backbone
Flooding every LSA to every router does not scale — a network with thousands of routers would generate an enormous database and frequent SPF runs. OSPF contains the flooding with areas: a group of routers that share the same LSDB. LSAs are flooded only within their area, so a change in one area does not ripple through the others.
One area is special. Area 0, the backbone area, must be the transit core: every other area must connect to area 0, and inter-area traffic passes through it. In a small network you may have only area 0 — a single-area design, which is exactly what the CCNA labs use. In a larger network, areas 1, 2, 3, and so on attach to area 0 via area border routers (ABRs) that belong to both area 0 and their own area.
Router ID
Every OSPF router is identified by a 32-bit router ID, written in dotted-decimal form like an IPv4 address. It is unique within the OSPF domain and is used in LSAs to say “this came from me”. IOS selects it with a fixed order of preference:
- The value set explicitly with the
router-idcommand (highest priority). - Otherwise, the highest IP address among loopback interfaces.
- Otherwise, the highest IP address among active physical interfaces.
Because the router ID is chosen when OSPF starts, an administrator who relies on interface
addresses can be surprised when an interface goes down: the ID can change on a restart, disrupting
adjacencies. Best practice is to set a stable router-id or configure a loopback interface
and let its address become the ID.
! a loopback address often becomes the router ID by preference
R1(config)# interface Loopback0
R1(config-if)# ip address 1.1.1.1 255.255.255.255
! or set it explicitly in OSPF configuration
R1(config-router)# router-id 1.1.1.1
The cost metric
OSPF’s metric is cost, and cost is derived from interface bandwidth: faster links have lower cost (shorter paths), which matches intuition. The default formula uses a reference bandwidth of 100 Mbps:
cost = reference bandwidth / interface bandwidth = 100,000,000 / bandwidth (bps)
Cost is calculated on each interface and is the cumulative cost along the path, so a route’s
metric is the sum of the outgoing interfaces it crosses. The default reference of 100 Mbps creates a
problem on modern networks: any link at 100 Mbps or faster rounds to the minimum cost of 1, so a gigabit
link and a 10-gigabit link look identical. Administrators fix this by raising the reference bandwidth to
1 Gbps or higher with auto-cost reference-bandwidth on every router.
| Interface bandwidth | Default OSPF cost (ref 100 Mbps) |
|---|---|
| 10 Mbps | 10 |
| 100 Mbps | 1 |
| 1 Gbps (1000 Mbps) | 1 |
| 10 Gbps | 1 |
Neighbours, hellos, and timers
Before routers exchange LSAs they must become neighbours. OSPF sends periodic Hello packets to discover and maintain neighbours. On broadcast and point-to-point networks the defaults are:
- Hello interval: 10 seconds — how often a Hello is sent.
- Dead interval: 40 seconds — four times the Hello; if no Hello is heard within this time, the neighbour is declared down.
The Hello packet carries parameters that must match before an adjacency forms: the Hello and dead intervals, the area ID, authentication, and the stub-area flag. A common exam trap is a misconfigured timer or area number that silently prevents adjacency — the interfaces are up and pinging, but OSPF never converges. A mismatch is not automatically negotiated away as it is with some other parameters.
INIT or never progress and no routes are
exchanged. Check show ip ospf interface on both ends.
Multicast addresses and LSAs
OSPF does not use broadcast; it multicasts Hello and update packets to two well-known IPv4 addresses:
| Multicast address | Received by |
|---|---|
| 224.0.0.5 | All OSPF routers on the segment (AllSPFRouters). |
| 224.0.0.6 | Only the DR and BDR (AllDRouters). |
A normal router sends LSAs to 224.0.0.5 and neighbours update to 224.0.0.6. (For IPv6, OSPFv3 uses the
equivalents FF02::5 and FF02::6.) OSPFv2 runs directly over IP using protocol
number 89.
LSAs themselves come in several types. The ones worth knowing early are the Type 1 Router LSA (a router describing its own links) and the Type 2 Network LSA (produced on a broadcast segment by the designated router, Lesson 21). The full database these LSAs build is what SPF runs on.
The vocabulary you need
Every term below appears in the lesson text above. Select one to read its definition, then use the quiz at the end to check what stuck.
Review
Check what you have learned with these review questions.
Sources & references
- Cisco. CCNA (200-301) Exam Topics. cisco.com.
- IETF. Request for Comments (RFCs). rfc-editor.org.
- IANA. Internet Assigned Numbers Authority registries. iana.org.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.