Open Shortest Path First

June 17, 2025 - Reading time: 3 minutes

OSPF (Open Shortest Path First) is a dynamic, link-state interior gateway protocol used within an autonomous system to exchange routing information between routers. It uses cost as its metric, calculated based on interface bandwidth, and ensures loop-free, efficient routing through the Dijkstra Shortest Path First (SPF) algorithm. OSPF organizes routers into areas to optimize scalability and convergence. Routers exchange topology information via LSAs (Link-State Advertisements), allowing each router to build a synchronized link-state database and independently compute the shortest path tree.

Each router is identified by a unique Router ID (RID), which must remain consistent in the OSPF domain. OSPF establishes neighbor relationships through Hello packets and forms adjacencies to exchange routing data. For any two routers to become neighbors, key parameters like area ID, hello/dead intervals, subnet, and authentication (if used) must match. All routers in a single area maintain identical link-state databases, ensuring consistent path selection.

Step-by-Step Lab:

Basic OSPF Single-Area Configuration


Lab Topology

R1 ── Fa0/0 ── R2 ── Fa0/1 ── R3
Router Interface IP Address OSPF Router ID
R1 Fa0/0 192.168.12.1/24 1.1.1.1
R2 Fa0/0 192.168.12.2/24 2.2.2.2
R2 Fa0/1 192.168.23.2/24 2.2.2.2
R3 Fa0/0 192.168.23.3/24 3.3.3.3

All routers will be in OSPF Area 0.


Configuration

R1 Configuration

R1(config)# interface fastethernet0/0
R1(config-if)# ip address 192.168.12.1 255.255.255.0
R1(config-if)# no shutdown

R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
R1(config-router)# network 192.168.12.0 0.0.0.255 area 0

R2 Configuration

R2(config)# interface fastethernet0/0
R2(config-if)# ip address 192.168.12.2 255.255.255.0
R2(config-if)# no shutdown

R2(config)# interface fastethernet0/1
R2(config-if)# ip address 192.168.23.2 255.255.255.0
R2(config-if)# no shutdown

R2(config)# router ospf 1
R2(config-router)# router-id 2.2.2.2
R2(config-router)# network 192.168.12.0 0.0.0.255 area 0
R2(config-router)# network 192.168.23.0 0.0.0.255 area 0

R3 Configuration

R3(config)# interface fastethernet0/0
R3(config-if)# ip address 192.168.23.3 255.255.255.0
R3(config-if)# no shutdown

R3(config)# router ospf 1
R3(config-router)# router-id 3.3.3.3
R3(config-router)# network 192.168.23.0 0.0.0.255 area 0


Verification Commands 

show ip ospf neighbor — Confirm Neighborship

On R1:

R1# show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:32    192.168.12.2    FastEthernet0/0
  • Neighbor ID: The router ID of the adjacent router (R2)

  • State: Must reach FULL for full adjacency

  • Interface: Shows the local interface forming the adjacency


show ip route — Confirm OSPF Routes Installed

On R1:

R1# show ip route

Gateway of last resort is not set

     192.168.0.0/24 is subnetted, 2 subnets
O       192.168.23.0 [110/20] via 192.168.12.2, 00:00:10, FastEthernet0/0
C       192.168.12.0 is directly connected, FastEthernet0/0
  • O indicates an OSPF-learned route

  • Administrative distance = 110, cost = 20


show ip ospf — Confirm OSPF Process and Router ID

On R2:

R2# show ip ospf

Routing Process "ospf 1" with ID 2.2.2.2
Start time: 00:01:15.000, Time elapsed: 00:04:38.000
Supports only single TOS(TOS0) routes
...
  • Confirms the Router ID and that OSPF process is running


show ip ospf interface brief — Interface Participation Summary

On R2:

R2# show ip ospf interface brief

Interface    PID   Area  IP Address      State     Cost  Neighbors
Fa0/0        1     0     192.168.12.2    DR        10    1
Fa0/1        1     0     192.168.23.2    DROTHER   10    1

  • State: Shows role on each segment (DR, BDR, DROTHER)

  • Cost: OSPF cost of the interface

  • Neighbors: Number of OSPF neighbors on that interface


Common Mistakes

Mistake Symptom Fix
Not setting router-id Random IDs from interfaces; confusion in show ip ospf neighbor Set it manually with router-id
Interfaces shutdown OSPF adjacency never forms Use no shutdown on interfaces
Incorrect wildcard mask OSPF doesn’t recognize interface Double-check network command masks
Mismatched area IDs Neighbors stuck in INIT or EXSTART Ensure all connected interfaces are in same OSPF area
Missing network statement Route or interface not advertised Include all intended subnets in network commands

User Challenge

The lab is available for download from this link. Try recreating the sample lab above using the provided IP addressing scheme.

Try the following tasks to prepare for the next lesson:

  1. Configure a loopback interface on each router:

    • R1: Loopback0 → 10.1.1.1/32

    • R2: Loopback0 → 10.2.2.2/32

    • R3: Loopback0 → 10.3.3.3/32

    • Advertise them in OSPF.

  2. Verify that all loopback networks are visible on R1 using show ip route.

  3. Download the OSPF1 troubleshooting scenarios and apply what you've learned.
    (requires version 2.10)

Open Shortest Path First | PocketCLI

Download


>