Labs / Routing / Routing protocols

Lab 1 of 2 · Routing protocols

RIP routing: routers that learn by rumor

Let routers teach each other routes, then watch a stale rumor loop.

Start this lab 7 steps

The idea

Nobody at this ski resort has typed a route in twenty years, because the routers tell each other what they can reach. Bring the new summit router into the conversation, find out why it picks the slowest link on the mountain, then lose the bad news on its way down and watch a rumor about a dead network run in circles.

One command, a route on each side
One command, a route on each side
One router, two different lists
One router, two different lists
After the first offset
After the first offset
Where the silent seconds go
Where the silent seconds go
Metric 16, passed straight down
Metric 16, passed straight down
Where the bad news stopped
Where the bad news stopped
Four routers, no network
Four routers, no network

Steps

  1. Join the conversation

    A ski resort runs four routers in a ring around the mountain. Fiber climbs from valleyRouter through forestRouter and ridgeRouter to summitRouter, and an old radio link, radioLink, jumps straight from the valley to the summit. The ticket server sits in the valley, and the scanner summitGate at the top of the lift asks it about every pass.

    In the static-routes lab you typed each route by hand and repaired each failure yourself. Four routers in a ring would need a line on every router for every network, each pointing the right way, and one failure could mean changing most of them. A routing protocol does that work for you: it's software on each router that talks to the routers beside it and fills in the table from what it hears.

    RIP, the Routing Information Protocol, is the oldest of these still running, and its messages are short enough to read by eye. Three of these routers already speak it. summitRouter came out of its box this morning and doesn't, so the scanner can't reach anything past that router.

    Ping the ticket server from summitGate, read the summit's table, then turn RIP on for the router's cards and look again.

    summitGate:~# ping -c 1 -W 2 10.0.1.10
    summitRouter:~# vtysh -c "show ip route"
    summitRouter:~# vtysh -c "configure terminal" -c "router rip" -c "network 10.0.0.0/8"
    summitRouter:~# vtysh -c "show ip route"
    summitGate:~# ping -c 1 -W 2 10.0.1.10
  2. Listen to the gossip

    Those routes came from somewhere, and RIP's messages are ordinary packets that anyone on the wire is free to read. forestRouter has a neighbor on each side, which makes it a good place to listen. The lab records on both its cards for a few seconds while you ask it for its settings.

    The design is old. It grew out of Xerox's networks in the late 1970s, and Berkeley's Unix shipped a program called routed that spoke it, which put it on university machines across the early internet. It was written down as a standard only in 1988, as RFC 1058, long after it was everywhere.

    Version 2 came in the 1990s and added the /24 you'll see on each line. Version 1 sent addresses with no mask, and that stopped working once networks came in every size. The version is a setting on each router, and a router set to one version refuses the other.

    Every RIP router does one small job. On a steady beat it sends a list of the networks it knows and how far away each one is, and when a list arrives it adds one to each distance and keeps any route that beats what it has. News from the neighbor it already uses always counts, even when the number gets worse.

    Distance here is a count of hops. A network on a router's own card counts as 1, and each router further on adds 1.

    So a router ends up with a direction and a distance for each network, and what it sends its neighbors is a list, or vector, of distances, which is why this family is called distance vector.

    Look at what's missing. No router ever learns the shape of the network, in the same way that a road sign saying "Lyon 40 km" tells you nothing about the roads. Each router knows only what its neighbors claim, and it believes them.

    forestRouter:~# vtysh -c "show ip rip status"
    summitRouter:~# vtysh -c "show ip rip"
  3. Pay for the slow radio

    The radio is one hop from the valley to the summit, and the fiber is three, so RIP sends every pass check over the radio. It's a 2 megabit link with 40 ms of delay each way, kept from the days before the fiber was laid. RIP's metric has no room for speed, so it will prefer a slow link with fewer hops every time.

    Ping the ticket server and trace the path to see what the scanners live with. Then make the radio look worse: an offset list puts a penalty on routes heard through a card.

    The numbers need care. Over the fiber the summit hears the ticket office at metric 4, which is the 3 the ridge offers plus one hop.

    Over the radio the valley offers 1, since the ticket office sits on its own card. A normal hop would add one to that, and in FRR an offset takes the place of that one, so an offset of 4 turns the 1 into 5, and 5 loses to 4. An offset of 3 would make a tie at 4, and on a tie FRR's RIP stays with the route it already has.

    Add the offset on summitRouter and ping, then add it on valleyRouter and ping again.

    summitGate:~# ping -c 3 -W 2 10.0.1.10
    summitGate:~# traceroute -n -w 1 10.0.1.10
    summitRouter:~# vtysh -c "configure terminal" -c "access-list all-routes permit any" -c "router rip" -c "offset-list all-routes in 4 radioLink"
    summitGate:~# ping -c 3 -W 2 10.0.1.10
    valleyRouter:~# vtysh -c "configure terminal" -c "access-list all-routes permit any" -c "router rip" -c "offset-list all-routes in 4 radioLink"
    summitGate:~# ping -c 3 -W 2 10.0.1.10
    summitGate:~# traceroute -n -w 1 10.0.1.10
  4. Cut a link quietly

    In the static-routes lab you broke a provider's network while the cards stayed up, and the route went on sending packets into nothing. RIP runs a different test: a neighbor has to keep renewing each route, and silence kills it.

    The lab is about to lose every packet on forestRidge and leave the cards up, so no router gets told anything. While it does, a loss meter on summitGate sends a ping every 0.2 seconds for 35 seconds, then reports the longest gap. The fiber comes back at the end of this step.

    summitGate:~# ping -i 0.2 -c 175 -W 1 10.0.1.10
    summitRouter:~# vtysh -c "show ip rip"
    forestRouter:~# ip -br link show forestRidge
  5. Send the bad news

    Silence is how RIP finds a link that dies quietly. A failure the router can see for itself needs no waiting, because a card that goes down is a fact.

    Take the card summitGates down on summitRouter, as if someone had pulled the cable to the gates' network, while the lab records what crosses forestRouter. This cuts off the scanners until you bring the card back at the end of this step.

    summitRouter:~# ip link set summitGates down
    ticketServer:~# ping -c 2 -W 2 10.0.2.10
    summitRouter:~# ip link set summitGates up
    ticketServer:~# ping -c 2 -W 2 10.0.2.10
  6. Lose the bad news

    That worked because every message arrived. RIP's messages travel over UDP, so nobody acknowledges them, and a router that sends bad news has no idea whether it landed.

    The lab is about to make the fiber between ridgeRouter and forestRouter lose every RIP message going downhill. It has also given forestRouter a 50-minute timeout in place of 15 seconds, so that its own countdown can't end the fault while you look at it. A real link wouldn't need this long: lose one message, and if the valley's regular list reaches the summit before the ridge repeats the news, the same thing happens.

    Take summitGates down again, and follow the news. It reaches the ridge, and the ridge's message to the forest is lost. It also crosses the radio to the valley, and the valley ignores it, because the valley's route goes through the forest and bad news only counts from the neighbor in use.

    So forestRouter and valleyRouter still believe the scanners are up there, and valleyRouter goes on saying so in its regular list, over the radio, to the very router that lost them.

    summitRouter:~# ip link set summitGates down
    ticketServer:~# ping -c 2 -W 2 10.0.2.10
    forestRouter:~# vtysh -c "show ip route 10.0.2.0/24"
    ridgeRouter:~# vtysh -c "show ip route 10.0.2.0/24"
    summitRouter:~# vtysh -c "show ip route 10.0.2.0/24"
    valleyRouter:~# vtysh -c "show ip route 10.0.2.0/24"
  7. Count up to infinity

    Four routers are holding a false route, and nothing is coming to save them: the forest's countdown is 50 minutes long, and the messages that could correct it are being lost.

    Repair the link by deleting the rule on ridgeRouter that's losing those messages. The lab records RIP's packets on summitRouter for 12 seconds after you do. The scanners' network stays down until the end of this step.

    ridgeRouter:~# iptables -D OUTPUT -o forestRidge -p udp --dport 520 -j DROP
    ticketServer:~# ping -c 2 -W 2 10.0.2.10
    summitRouter:~# ip link set summitGates up
    ticketServer:~# ping -c 2 -W 2 10.0.2.10

Run these steps on real machines

Keep reading

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab