Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Static Routing Basics

The whole lesson is here to read. Create a free account to run it in a live lab.

Virtual machine lab7 min read6 commands

What you will do

A network is made of routers that pass packets along and hosts that send and receive them. Here h1 is a host, r1 and r2 are routers, and h2 is another host. A router only knows the networks it is directly connected to. You will look around the first networking lab, send a packet that cannot get through, and find out why. You will not fix it: that is the lab's own task.

Before you start

Note

Press Start the lab on the bar at the top of this lesson. This lab is a whole Ubuntu machine of your own, with a small network built inside it, so it takes a little longer to come up than a container. Each Run button below types its command into the machine's terminal, one after another. If one says the machine is still starting, wait a few seconds and press it again. To watch them, or to type your own, press Open terminal on the bar.

1. Meet the machines

Everything here is built inside your one Ubuntu machine: each router and each host is a separate network namespace, with its own addresses. netlab status lists them. r1 and r2 are the routers, h1, h2 and mgmt the hosts. The names starting to- are the network cables, and the numbers are the addresses.

Command
netlab status

Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.

2. Talk to the router next door

sudo ip netns exec h1 runs the command that follows inside h1's own network. This pings r1's address on the cable to r2. It answers: h1 can reach its own router, and the router knows about both its cables.

Command
sudo ip netns exec h1 ping -c 2 -W 1 10.0.12.1

Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.

3. Try to cross the network

Now ask for the far host, 10.0.3.2. ping sends a small packet and waits for an answer. Nothing gets through, and the router that is next to h1 says why: Destination Net Unreachable, "I do not know a way to that network".

Command
sudo ip netns exec h1 ping -c 2 -W 1 10.0.3.2

Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.

4. Ask the router what it knows

A route is a line in a router's table: "to reach this network, go this way". This shows r1's table. It has two lines, one for each cable it is joined to, and none for the network where h2 lives, 10.0.3.0/24. That is why the packet stopped.

Command
sudo ip netns exec r1 ip route

Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.

5. Watch where the packet stops

traceroute shows every router a packet passes. The first line is r1, and the !N after it means "network unreachable": the packet went no further.

Command
sudo ip netns exec h1 traceroute -n -m 4 -w 1 10.0.3.2

Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.

6. Ask the router's own console

The routers here run FRRouting, free routing software, and vtysh is its console, the one students meet on real equipment. show ip route is the same table, with a legend: C means connected.

Command
sudo vtysh -N r1 -c "show ip route"

Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.

Now do the lab

Tip

You have found where the packet stops and why. Making it work is the task of this lab: open README.md in your home folder with cat README.md in the terminal. It says what to do and gives none of the answers.

For teachers

Tip

This lesson is a small example of a lesson worked in a lab: the steps and the Run buttons are the lesson, and the lab is each student's own copy. This lesson is worked in a VM lab: each student has an Ubuntu machine of their own with the network inside it, and a Run types into its terminal and shows what it printed. The lab itself has a check that marks the finished network. Copy it into your own module and change it, or build one from scratch with the Lab menu in the lesson builder.

About this lab and its source: Static routing lab: build routes on a small network in your browser

Teaching a class? Set these lessons for your students with marking and a lab for every student.