Skip to content
Portfolio

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.

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)

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

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”.

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.

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 TypeBandwidthDefault OSPF Cost
10 Gigabit Ethernet10 Gbps1 (Minimum cost is 1)
Gigabit Ethernet1 Gbps1 (Minimum cost is 1)
Fast Ethernet100 Mbps1
Ethernet10 Mbps10
T1 Serial1.544 Mbps64
Slow Serial128 kbps781
ISDN / Slow Serial64 kbps1562

To change the default reference bandwidth we use the command:

R1(config-router)# auto-cost reference-bandwidth 100000
R2(config)# router ospf 1
R2(config)# network 10.0.0.0 0.0.255.255 area 0

O

R2(config)# int g0/0
R2(config-int)# ip osfp 1 area 0

To inject a default route:

R1(config)# ip route 0.0.0.0 0.0.0.0 192.168.2.1
R1(config)# router ospf 1
R1(config-router)# default-information originate

Set and reset Hello and Dead intervals

ip ospf hello-interval interval
ip ospf dead-interval interval
no ip ospf hello-interval
no ip ospf dead-interval

Configure authentication

ip ospf authentication-key key123
ip osfp authentication
R1# show run | section ospf
R1# show ip protocols
R1# show ip ospf interface brief
R1# show ip ospf neighbor
R1# show ip ospf database
R1# show ip route

OSPF divides the network into areas to limit LSA flooding and keep each router’s LSDB smaller.

Problem without areasWhat areas solve
Every router stores the full network mapEach router only floods LSAs inside its area
SPF runs on a huge topologySPF runs on a smaller local topology
One link flap floods the whole ASInstability stays mostly inside one area

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 1
R1(config)# router ospf 1
R1(config-router)# network 10.1.0.0 0.0.0.255 area 1
! ABR — interface in Area 1 and interface in Area 0
ABR(config)# router ospf 1
ABR(config-router)# network 10.1.0.0 0.0.0.255 area 1
ABR(config-router)# network 10.0.0.0 0.0.0.255 area 0
RoleAbbrev.Function
Internal routerAll interfaces in the same area
Backbone routerAt least one interface in Area 0
Area Border RouterABRConnects Area 0 to another area; summarizes between areas
AS Boundary RouterASBRInjects external routes (static, EIGRP, etc.) into OSPF
TypeCodeMeaning
Intra-areaODestination inside your area
Inter-areaO IADestination in another area (via ABR)
ExternalO E1 / O E2From outside OSPF (via ASBR)

Check in the routing table:

R1# show ip route ospf

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.

R1# show ip ospf
R1# show ip ospf interface brief ! Area ID per interface
R1# show ip ospf border-routers ! ABR / ASBR info

Area ID mismatch on the same link → neighbors never reach FULL. Always verify both sides use the same area on a shared segment.

The default priority is 1, the higher the better (0-255)

Setting OSPF Priority

R1(config)# int FastEthernet 0/0
R1(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.6
The DR multicasts the update to 224.0.0.5
## 9. Router ID
The router ID can be established using the command:
```txt
router-id 1.1.1.1

If 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.

Applying this command to an interface changes how OSPF operates to accommodate networks that do not support broadcast or multicast traffic.

  • 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.