Frontend Labs
⋯

Chapter 49 — OSPF: finding your way inside one network

In one sentence

Every OSPF router floods a description of its own links to every other router, they all build the identical map, and each calculates its own shortest paths from it.

How it works, step by step

   1. HELLO      Routers multicast Hello packets to find neighbours.
                 Both sides must agree on: hello timer, dead timer, area ID,
                 authentication, and subnet mask -- or no relationship forms.

   2. ADJACENCY  Neighbours synchronise their databases and become "FULL".

   3. FLOODING   Each router sends an LSA ("Link State Advertisement")
                 describing ITS OWN links and their costs.
                 These get flooded to everyone.

   4. DATABASE   Every router now holds an IDENTICAL copy of the map
                 (the "link-state database").

   5. SPF        Each router runs Dijkstra's shortest-path algorithm
                 on that map, from itself.

   6. INSTALL    The results go into the routing table.

   Any change -> flood the update -> everyone recalculates.

OSPF runs directly on IP as protocol 89 — not TCP, not UDP.

Cost: how OSPF picks a path

   cost = reference bandwidth / link bandwidth
   (lower cost = preferred)

And here is the single most important practical fact about OSPF:

The default reference bandwidth is 100 Mbit/s. So every link at or above 100 Mbit/s gets cost 1.

   100 Mbit link   -> cost 1
   1 Gbit link     -> cost 1     <-- identical!
   10 Gbit link    -> cost 1     <-- identical!
   100 Gbit link   -> cost 1     <-- identical!

Out of the box, OSPF cannot tell a gigabit link from a 100-gigabit link and will choose by hop count instead. The fix is one command (auto-cost reference-bandwidth 100000) — but it must be set identically on every router, or you get inconsistent routing.

Check this on every OSPF network you inherit. It is a very common real-world misconfiguration.

Areas: how OSPF scales

Flooding every link change to every router doesn't scale past a few hundred routers. OSPF divides the network into areas:

              +-------------- AREA 0 (the backbone) --------------+
              |                                                   |
        [ABR] |                                                   | [ABR]
              |                                                   |
          AREA 1                                              AREA 2

   * SPF runs only WITHIN an area -- a change in Area 1 doesn't make
     Area 2 recalculate.
   * ALL areas must connect to Area 0. Traffic between areas goes through it.
   * An ABR (Area Border Router) sits in two areas and summarises between them.

You can also make an area stub (block external routes, inject a default route instead) to keep its routing tables tiny.

Neighbour states, and what "stuck" means

You'll see these in show ip ospf neighbor. The healthy end state is FULL.

Stuck at Almost always means
Init Hellos are only going one way — an ACL or a one-way link
2-Way Normal on a shared LAN between two non-designated routers
ExStart MTU mismatch between the two routers (Chapter 15 again!)
Flapping Timer mismatch, or a genuinely unstable link

ExStart = check your MTUs is a genuinely useful piece of knowledge.

Practice (30 min)

If you installed FRRouting on two machines:

sudo vtysh
  configure terminal
   router ospf
    ospf router-id 1.1.1.1
    auto-cost reference-bandwidth 100000
    network 10.0.0.0/24 area 0
   exit
  end

  show ip ospf neighbor        # want to see state FULL
  show ip ospf interface eth0  # cost, timers, area, network type
  show ip ospf database        # the map every router shares
  show ip route ospf           # what OSPF installed

Then break it deliberately (the best way to learn):

  1. Change the hello timer on one side only → the adjacency drops. Watch show ip ospf neighbor.
  2. Set different MTUs on each side → watch it stick at ExStart.
  3. Unplug one of two paths → watch OSPF reconverge and the route change.

Check yourself

  1. What does each OSPF router flood, and what does every router end up with?
  2. Why does the default reference bandwidth cause problems?
  3. What must all areas connect to?
  4. An adjacency is stuck at ExStart. What do you check?

Further reading

  • Video: "OSPF Explained" series — Practical Networking. Thorough and clear.
  • Book: Routing TCP/IP, Volume 1 — Jeff Doyle. The classic reference.
  • Book: any CCNA study guide — OSPF is a large part of the syllabus and the material is drill-oriented.
  • Lab: FRRouting, or Cisco Packet Tracer / GNS3 for a full virtual network.

Generated from real-life-guide-v1.md · 8 Oct 2026 16:36