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.
| Term | Meaning in this lab |
|---|---|
| Router ID | Unique 32-bit identity written in dotted decimal. We configure it explicitly; it does not itself create a reachable address. |
| Area 0 | The backbone area. Every enabled interface here belongs to it. Multi-area design comes later. |
| Neighbor / adjacency | A discovered peer / a relationship that synchronizes databases. On our point-to-point links, neighbors should reach Full. |
| Process ID | Local 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.
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
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
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
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# 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 GigabitEthernet2R2 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# 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.3The 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# 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.
configure terminal
interface GigabitEthernet2
shutdown
endR1# show ip route 10.255.0.3
% Network not in tableR2 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.
configure terminal
interface GigabitEthernet2
no shutdown
endR2# 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, GigabitEthernet1Wait 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
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.