How OSPF works

Why a routing protocol?

Static routes are fine for a few routers. But every new network means typing a route on every router, and (as you saw in the last module) a static route doesn't notice a failure further away. A routing protocol lets routers tell each other what they know, so they find the routes themselves and change them when the network changes.

OSPF (Open Shortest Path First) is the routing protocol most companies use inside their networks, and the one the CCNA covers.

How OSPF works, in five steps

  1. Each router has a router ID: a name written like an IPv4 address, such as 1.1.1.1.
  2. It sends hello messages out of its OSPF interfaces every 10 seconds. Routers that hear each other with matching settings become neighbours.
  3. Neighbours swap descriptions of their links: LSAs (link-state advertisements). Every router in the area ends up with the same map, the link-state database (LSDB).
  4. Each router runs the SPF algorithm (Dijkstra) on the map to find the lowest-cost path to every network.
  5. The best paths go into the routing table as O routes (AD 110).

The three routers below already run OSPF. R1 has two neighbours and has learned the other routers' LANs and loopbacks:

In NetLab

▶ R1
R1>enable
R1#show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:37    10.0.12.2       GigabitEthernet0/1
3.3.3.3           1   FULL/DR         00:00:37    10.0.13.2       GigabitEthernet0/2
R1#show ip route ospf | begin Gateway
Gateway of last resort is not set

      2.0.0.0/32 is subnetted, 1 subnets
O        2.2.2.2 [110/2] via 10.0.12.2, 00:00:03, GigabitEthernet0/1
      3.0.0.0/32 is subnetted, 1 subnets
O        3.3.3.3 [110/2] via 10.0.13.2, 00:00:03, GigabitEthernet0/2
      10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
O        10.0.23.0/30 [110/2] via 10.0.12.2, 00:00:03, GigabitEthernet0/1
                      [110/2] via 10.0.13.2, 00:00:03, GigabitEthernet0/2
O     192.168.2.0/24 [110/2] via 10.0.12.2, 00:00:03, GigabitEthernet0/1
O     192.168.3.0/24 [110/2] via 10.0.13.2, 00:00:03, GigabitEthernet0/2
▶ PC1
NetLab Windows-style command prompt. Type help to see the commands.
C:\Users\student>ping 192.168.3.10

Pinging 192.168.3.10 with 32 bytes of data:
Request timed out.
Request timed out.
Reply from 192.168.3.10: bytes=32 time<1ms TTL=126
Reply from 192.168.3.10: bytes=32 time<1ms TTL=126

Ping statistics for 192.168.3.10:
    Packets: Sent = 4, Received = 2, Lost = 2 (50% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Areas

Big OSPF networks are split into areas to keep the maps small. Area 0 is the backbone, and every other area must touch it. The CCNA only needs one area, so in this course everything is in area 0.

Remember: OSPF: neighbours with hellos, the same map (LSDB) in every router, SPF picks the lowest cost. Routes show as O with AD 110.

HOME LABS COMMUNITY DASHBOARD