PacketLab
OSPF · Fundamentals and adjacency

Introduction to OSPF

Build a three-router area, exchange topology information and verify how remote prefixes become reachable.

How OSPF works

OSPF is an interior gateway protocol: it calculates routes inside a routing domain. OSPFv2 carries IPv4 reachability. Routers discover neighbors with Hello packets, establish the required adjacencies and exchange link-state advertisements (LSAs).

LSAs describe topology and reachability. They form the link-state database (LSDB). Routers in the same area converge on the same area topology, then each runs shortest path first (SPF) from its own position. The resulting next hops can therefore differ. OSPF prefers lower accumulated cost; eligible routes compete for installation in the IP routing table.

TermMeaning in this lab
Router IDUnique 32-bit identity written in dotted decimal. We configure it explicitly; it does not itself create a reachable address.
Area 0The backbone area. Every enabled interface here belongs to it. Multi-area design comes later.
Neighbor / adjacencyA discovered peer / a relationship that synchronizes databases. On our point-to-point links, neighbors should reach Full.
Process IDLocal instance number. Using 1 everywhere is convenient, but matching it is not a neighbor requirement.

Area, timers, authentication and area capabilities must be compatible. Addressing and network type must suit the link; MTU issues can prevent database exchange. Broadcast networks also use a DR and BDR, so not every neighbor pair becomes Full. Our point-to-point network type avoids that election.

The lab

Start with three routers with no competing routing protocol or static route for these prefixes. Use routed GigabitEthernet interfaces, connected as shown. Interface names may need adjustment for your image.

Single-area chainIllustrative topology
Area 0 · OSPFv2192.0.2.0/30192.0.2.4/30Gi1 · .1Gi1 · .2Gi2 · .5Gi1 · .6R1Lo0: 10.255.0.1/32R2Lo0: 10.255.0.2/32R3Lo0: 10.255.0.3/32Transit cost 10 in each direction · loopback cost 1
Solid lines are physical Ethernet links configured as OSPF point-to-point. All enabled interfaces, including loopbacks, are in area 0. Router symbol: GNS3, GPL-2.0. Original topology layout.

R1 and R3 are not directly adjacent. R2 forwards traffic between them. Each router has Loopback0 at 10.255.0.1/32, 10.255.0.2/32 or 10.255.0.3/32 respectively. We set transit costs to 10 and loopback costs to 1 for predictable calculations.

Configure

Create the process and router ID before enabling interfaces. Apply these commands on a fresh lab. The interface command enables OSPF and associates that interface with area 0; no redistribution is needed. Passive loopbacks retain their advertised prefixes without sending Hellos.

R1

R1 · configuration
configure terminal
router ospf 1
 router-id 10.255.0.1
 passive-interface Loopback0
 exit
interface Loopback0
 ip address 10.255.0.1 255.255.255.255
 ip ospf 1 area 0
 ip ospf cost 1
 exit
interface GigabitEthernet1
 ip address 192.0.2.1 255.255.255.252
 ip ospf network point-to-point
 ip ospf cost 10
 ip ospf 1 area 0
 no shutdown
 exit
end

R2

R2 · configuration
configure terminal
router ospf 1
 router-id 10.255.0.2
 passive-interface Loopback0
 exit
interface Loopback0
 ip address 10.255.0.2 255.255.255.255
 ip ospf 1 area 0
 ip ospf cost 1
 exit
interface GigabitEthernet1
 ip address 192.0.2.2 255.255.255.252
 ip ospf network point-to-point
 ip ospf cost 10
 ip ospf 1 area 0
 no shutdown
 exit
interface GigabitEthernet2
 ip address 192.0.2.5 255.255.255.252
 ip ospf network point-to-point
 ip ospf cost 10
 ip ospf 1 area 0
 no shutdown
 exit
end

R3

R3 · configuration
configure terminal
router ospf 1
 router-id 10.255.0.3
 passive-interface Loopback0
 exit
interface Loopback0
 ip address 10.255.0.3 255.255.255.255
 ip ospf 1 area 0
 ip ospf cost 1
 exit
interface GigabitEthernet1
 ip address 192.0.2.6 255.255.255.252
 ip ospf network point-to-point
 ip ospf cost 10
 ip ospf 1 area 0
 no shutdown
 exit
end

There is no authentication in this isolated first lab. Do not treat this as a production security configuration. Authentication and timer tuning have their own lessons.

Verify

All outputs below are illustrative excerpts, constructed from this configuration rather than recorded router results. Exact formatting and counters vary.

1. Check interfaces and neighbors

R2 · illustrative output
R2# show ip ospf interface brief
Interface    PID   Area  IP Address/Mask  Cost  State Nbrs F/C
Lo0          1     0     10.255.0.2/32    1     LOOP  0/0
Gi1          1     0     192.0.2.2/30     10    P2P   1/1
Gi2          1     0     192.0.2.5/30     10    P2P   1/1

R2# show ip ospf neighbor
Neighbor ID     Pri  State    Dead Time  Address      Interface
10.255.0.1        0  FULL/-   00:00:36   192.0.2.1   GigabitEthernet1
10.255.0.3        0  FULL/-   00:00:34   192.0.2.6   GigabitEthernet2

R2 has one Full adjacency per transit interface. The dash denotes no DR/BDR role on these point-to-point links. R1 and R3 each have one neighbor: R2.

2. Inspect the shared topology

R1 · illustrative database excerpt
R1# show ip ospf database router
            OSPF Router with ID (10.255.0.1) (Process ID 1)
                Router Link States (Area 0)
Link ID         ADV Router
10.255.0.1      10.255.0.1
10.255.0.2      10.255.0.2
10.255.0.3      10.255.0.3

The excerpt omits age, sequence, checksum and link-count columns. Each router originates a router-LSA in area 0. R1 has R3’s LSA even though R3 is not a direct neighbor. An LSDB entry is topology information, not proof of an installed route.

3. Check routes and forwarding

R1 · illustrative output
R1# show ip route ospf
O    10.255.0.2/32 [110/11] via 192.0.2.2, GigabitEthernet1
O    10.255.0.3/32 [110/21] via 192.0.2.2, GigabitEthernet1
O    192.0.2.4/30  [110/20] via 192.0.2.2, GigabitEthernet1

R1# ping 10.255.0.3 source Loopback0
!!!!!
Success rate is 100 percent (5/5)

O identifies intra-area OSPF routes. In [110/21], 110 is administrative distance on this command platform and 21 is cost: R1’s outgoing transit cost 10 + R2’s outgoing transit cost 10 + R3’s loopback cost 1. R1’s own loopback is connected and does not appear in this OSPF-only view. The sourced ping also requires a return route to R1’s loopback.

Break and restore

On R2, shut the interface toward R3.

R2 · configuration
configure terminal
interface GigabitEthernet2
 shutdown
end
R1 · illustrative output after convergence
R1# show ip route 10.255.0.3
% Network not in table

R2 detects its local interface failure and updates the topology. After flooding and recalculation, R1 removes the only path to R3. R1’s adjacency to R2 stays Full; the chain offers no alternate path. A silent failure can instead require the dead timer to expire.

R2 · restore configuration
configure terminal
interface GigabitEthernet2
 no shutdown
end
R2 and R1 · illustrative recovery excerpts
R2# show ip ospf neighbor
Neighbor ID     Pri  State    Dead Time  Address      Interface
10.255.0.1        0  FULL/-   00:00:37   192.0.2.1   GigabitEthernet1
10.255.0.3        0  FULL/-   00:00:36   192.0.2.6   GigabitEthernet2

R1# show ip route ospf | include 10.255.0.3
O    10.255.0.3/32 [110/21] via 192.0.2.2, GigabitEthernet1

Wait for the adjacency and route to recover, then repeat the sourced ping. If they do not, inspect interface status, addressing, area and network type before changing unrelated settings.

Technical references

OSPFv2 specification, RFC 2328 · OSPF configuration guide

Key Takeaways

  • OSPF floods link-state information within an area; each router calculates paths from its own position.
  • A neighbor is discovered through Hellos; a Full adjacency has synchronized the relevant databases.
  • Router IDs identify routers. Process IDs are locally significant and need not match.
  • Enable OSPF on an interface to include its prefix; passive interfaces advertise reachability without forming neighbors.
  • Use neighbor, database and routing checks together; a Full adjacency alone does not prove end-to-end forwarding.

Introduction to OSPF Quiz

Six questions · four options each · select one answer per question. Submit all answers to see your score and explanations.

1. What does SPF use to calculate paths?
2. Which routers become direct OSPF neighbors in this chain?
3. What does Full mean on these point-to-point links?
4. What does passive-interface Loopback0 do here?
5. Must the OSPF process ID match between routers?
6. After the only R2–R3 link fails and OSPF converges, what happens at R1?