Frontend Labs
⋯

Part 12 — How routers learn routes

Chapter 13 showed you the routing table. This part is about how it gets filled in without a human typing every line.

Chapter 48 — Two ways to share directions

In one sentence

Routers either tell each other how far away things are (distance-vector) or what they're connected to (link-state), and everything else follows from that choice.

The problem

A router knows the networks it's directly plugged into. Everything else has to be learned. Typing static routes works for three routers and is impossible for three hundred — and static routes don't react when a link fails.

The two approaches

   DISTANCE-VECTOR                    LINK-STATE
   "routing by rumour"                "everyone gets the same map"

   Each router tells its NEIGHBOURS   Each router describes ITS OWN LINKS
   how far away everything is.        to EVERY other router.

   A: "I can reach X, it costs 3"     A: "I'm connected to B (cost 1)
   B: "OK, so for me it costs 4"          and C (cost 5)"
   B tells C: "X costs 4"             Everyone builds an IDENTICAL map,
                                      then each calculates its own shortest
                                      paths from that map.

   + simple, low memory               + fast, reliable convergence
   + fine for small networks          + you can see the whole topology
   - slow to react to failures        - more CPU and memory
   - can form temporary LOOPS         - needs structure to scale

   RIP, EIGRP                         OSPF, IS-IS

Why "routing by rumour" is a real problem

   A --- B --- C --- X

   C loses its link to X.
   But B is still telling everyone "I can reach X, cost 2"
       (B learned that FROM C, but doesn't remember that).
   C hears B and thinks: "great, I'll go via B, cost 3."
   B hears C's new cost and updates to 4. Then 5. Then 6.

   Meanwhile packets for X bounce between B and C until the
   count reaches "infinity" (16 hops in RIP) and both give up.

This is count-to-infinity. Distance-vector protocols patch it with rules like split horizon ("never tell a neighbour about a route you learned from them") and hold-down timers. Link-state protocols simply don't have the problem, because nobody relies on a neighbour's summary.

Which protocol goes where

   INSIDE one organisation  (an "IGP")     BETWEEN organisations  (an "EGP")
   goal: find the FASTEST path             goal: enforce BUSINESS POLICY

   OSPF   -- most common in enterprises    BGP -- the only one
   IS-IS  -- common in large ISPs
   EIGRP  -- Cisco networks
   RIP    -- teaching and tiny networks

That distinction matters more than it sounds: an IGP optimises for speed; BGP optimises for money. That's Chapter 50.

When routes conflict

If a router learns the same destination from two protocols, it needs a tiebreak. Most vendors use administrative distance — a trust ranking, lower = more trusted:

   Connected      0     <- always wins; it's directly attached
   Static         1     <- a human said so
   eBGP          20
   OSPF         110
   RIP          120
   iBGP         200

Remember from Chapter 13: longest-prefix match is checked first. A more specific route always wins, regardless of which protocol found it. Administrative distance only decides between routes of the same prefix length.

Practice (15 min)

# what protocol installed each of your routes?
ip route show                 # Linux -- look for "proto kernel/static/dhcp/ospf/bgp"
ip route show proto static
netstat -rn                    # macOS

# install a static route and watch it appear (then remove it)
sudo ip route add 192.0.2.0/24 via 192.168.1.1
ip route show 192.0.2.0/24
sudo ip route del 192.0.2.0/24

Optional, and very worthwhile: install FRRouting (sudo apt install frr) on two VMs or containers. It gives you real OSPF and BGP for free, and you can run every example in the next three chapters.

Check yourself

  1. What's the core difference between distance-vector and link-state?
  2. Explain count-to-infinity in your own words.
  3. What's the difference between an IGP and an EGP, in terms of goals?
  4. Which is checked first: longest-prefix match, or administrative distance?

Further reading

  • Video: "Routing Protocols Explained" and the OSPF/BGP series — Practical Networking. Ed's routing playlist is the best free introduction.
  • Book: Computer Networking: A Top-Down Approach, Chapter 5.
  • Book: Network Warrior (Donahue) — practical routing chapters written by someone who has debugged this at 3am.

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