Open Shortest Path First (OSPF) Basics
OSPF is a Link-State protocol. An OSPF router does not rely on rumors. It demands to see the entire map of the network so it can calculate the absolute best path itself.
1. The Three Tables
Section titled “1. The Three Tables”When OSPF starts up on a router, it goes through a specific process to build three distinct tables:
The Neighbor Table (Adjacency Database): The router sends out “Hello” packets to find other OSPF routers directly connected to it. Once they agree to be friends, they become neighbors. (Command: show ip ospf neighbor)
The Topology Table (Link-State Database / LSDB): Every router floods the network with LSAs (Link-State Advertisements) containing information about their connected links. Every router collects these LSAs until they all have an identical, complete map of the entire network. (Command: show ip ospf database)
The Routing Table (Forwarding Database): The router takes that complete map and runs a mathematical formula over it to find the fastest routes. The winning routes are injected into the final routing table. (Command: show ip route)
2. OSPF packet types
Section titled “2. OSPF packet types”Hello: The router listen and send out hello packets to form adjacencies with other OSPF routers on the link
DBD Database Description: Adjacent routers will tell each other the networks they know about with the DBD packet
LSR Link State Request: If a router is missing information about any of the networks in the received DBD, it will send the neighbor an LSR
LSA Link State Advertisement: A routing update
LSU Link State Update: Contains a list of LSA’s which should be updated, used during flooding
LSAck: Receiving routers acknowledge LSAs
2. The Algorithm (Dijkstra’s SPF)
Section titled “2. The Algorithm (Dijkstra’s SPF)”The mathematical formula OSPF uses to process the map is called the Shortest Path First (SPF) algorithm, invented by Edsger Dijkstra. Imagine looking at a GPS map. The SPF algorithm calculates every possible combination of roads to get from your router to the destination, and it strictly selects the path with the lowest total “Cost”.
3. The Metric (Cost)
Section titled “3. The Metric (Cost)”OSPF measures the “distance” to a network using Cost, which is entirely based on bandwidth.
Faster links (like Gigabit) have a lower cost.
Slower links (like Serial) have a higher cost.
The Rule: OSPF will always choose the path with the lowest cumulative cost, even if that path requires hopping through more routers.
4. OSPF Default Cost Table
Section titled “4. OSPF Default Cost Table”OSPF calculates the cost of a link using the formula: Reference Bandwidth / Interface Bandwidth. By default, Cisco uses a reference bandwidth of 100 Mbps ($10^8$ bps).
Here are the default costs:
| Interface Type | Bandwidth | Default OSPF Cost |
|---|---|---|
| 10 Gigabit Ethernet | 10 Gbps | 1 (Minimum cost is 1) |
| Gigabit Ethernet | 1 Gbps | 1 (Minimum cost is 1) |
| Fast Ethernet | 100 Mbps | 1 |
| Ethernet | 10 Mbps | 10 |
| T1 Serial | 1.544 Mbps | 64 |
| Slow Serial | 128 kbps | 781 |
| ISDN / Slow Serial | 64 kbps | 1562 |
To change the default reference bandwidth we use the command:
R1(config-router)# auto-cost reference-bandwidth 1000005. Basic Configuration
Section titled “5. Basic Configuration”R2(config)# router ospf 1R2(config)# network 10.0.0.0 0.0.255.255 area 0O
R2(config)# int g0/0R2(config-int)# ip osfp 1 area 0To inject a default route:
R1(config)# ip route 0.0.0.0 0.0.0.0 192.168.2.1R1(config)# router ospf 1R1(config-router)# default-information originateSet and reset Hello and Dead intervals
ip ospf hello-interval intervalip ospf dead-interval interval
no ip ospf hello-intervalno ip ospf dead-intervalConfigure authentication
ip ospf authentication-key key123ip osfp authentication6. Verification
Section titled “6. Verification”R1# show run | section ospfR1# show ip protocolsR1# show ip ospf interface briefR1# show ip ospf neighborR1# show ip ospf databaseR1# show ip route7. OSPF Areas
Section titled “7. OSPF Areas”OSPF divides the network into areas to limit LSA flooding and keep each router’s LSDB smaller.
Why areas exist
Section titled “Why areas exist”| Problem without areas | What areas solve |
|---|---|
| Every router stores the full network map | Each router only floods LSAs inside its area |
| SPF runs on a huge topology | SPF runs on a smaller local topology |
| One link flap floods the whole AS | Instability stays mostly inside one area |
Area 0 — the backbone
Section titled “Area 0 — the backbone”Area 0 is mandatory. It is the central hub all other areas must connect to — directly or through another area that touches Area 0.
[Area 1] ──ABR──► [Area 0] ◄──ABR── [Area 2]Multi-area example — R1 in Area 1, backbone router in Area 0:
! R1 — internal router in Area 1R1(config)# router ospf 1R1(config-router)# network 10.1.0.0 0.0.0.255 area 1
! ABR — interface in Area 1 and interface in Area 0ABR(config)# router ospf 1ABR(config-router)# network 10.1.0.0 0.0.0.255 area 1ABR(config-router)# network 10.0.0.0 0.0.0.255 area 0Key router roles
Section titled “Key router roles”| Role | Abbrev. | Function |
|---|---|---|
| Internal router | — | All interfaces in the same area |
| Backbone router | — | At least one interface in Area 0 |
| Area Border Router | ABR | Connects Area 0 to another area; summarizes between areas |
| AS Boundary Router | ASBR | Injects external routes (static, EIGRP, etc.) into OSPF |
Route types
Section titled “Route types”| Type | Code | Meaning |
|---|---|---|
| Intra-area | O | Destination inside your area |
| Inter-area | O IA | Destination in another area (via ABR) |
| External | O E1 / O E2 | From outside OSPF (via ASBR) |
Check in the routing table:
R1# show ip route ospfStub areas
Section titled “Stub areas”Stub area — ABR blocks external LSAs (Type 5); internal routers get a default route instead. Reduces LSDB size at the edge. CCNA may mention stub/totally stubby; single-area labs usually skip this.
Quick checks
Section titled “Quick checks”R1# show ip ospfR1# show ip ospf interface brief ! Area ID per interfaceR1# show ip ospf border-routers ! ABR / ASBR infoArea ID mismatch on the same link → neighbors never reach FULL. Always verify both sides use the same area on a shared segment.
8. OSPF BR and BDR
Section titled “8. OSPF BR and BDR”The default priority is 1, the higher the better (0-255)
Setting OSPF Priority
R1(config)# int FastEthernet 0/0R1(config-if)# ip ospf priority 100```txt
This command isn't applied immediately. Restart OSPF on the interface for the command to take effect.
When a link state changes on a router connected to a multiacce segment, it sends a multicast LSU packet to 224.0.0.6The DR multicasts the update to 224.0.0.5
## 9. Router ID
The router ID can be established using the command:
```txtrouter-id 1.1.1.1If there is no manual router ID configured, the router uses the highest up/up loopback interface If no loopback interfaces exist, the router looks at its active physical interfaces and picks the one with the highest IP address.
This command isn’t applied immediately. Restart OSPF on the interface for the command to take effect.
ip ospf network non-broadcast
Section titled “ip ospf network non-broadcast”Applying this command to an interface changes how OSPF operates to accommodate networks that do not support broadcast or multicast traffic.
Core Concepts from the Options:
Section titled “Core Concepts from the Options:”- Neighbor Adjacencies (The Correct Answer):
Because multicasts are blocked, OSPF cannot dynamically discover its neighbors. You must manually establish adjacencies by using the
neighbor <ip-address>command in the OSPF router configuration. This forces OSPF to use 1-to-1 unicast messages. - Multicast Updates (Option B):
Non-broadcast networks do not send multicast updates (such as to
224.0.0.5). All OSPF communication is strictly unicast. - OSPF Timers (Option A): The 10-second Hello and 40-second Dead timers are for Broadcast and Point-to-Point networks. In a Non-Broadcast network, the timers are automatically increased to 30 seconds (Hello) and 120 seconds (Dead).
- DR and BDR Elections (Option D): Even though it cannot broadcast, the network is still considered “Multi-Access” (meaning multiple routers share the segment). Because of this, DR (Designated Router) and BDR (Backup Designated Router) elections are still performed.
OSPF timer:
- Broadcast, point ot point -> Hello timer 10 seconds, Dead timer 40 seconds.
- Non Broadcast, point to multipoint, point to multipoint not broadcast* -> Hello timer 30 seconds, Dead timer 120 seconds.
ip ospf network broadcast
ip osf network point-to-point- In not broadcast the neighbor command is required so that OSPF send unicast updates.