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

Free lesson

OSPF Basics

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

Virtual machine lab7 min read5 commands

What you will do

A network is made of routers that pass packets along and hosts that send and receive them. Here h1 and h2 are hosts and r1, r2 and r3 are routers in a row. The routers learn the way by talking to each other with OSPF, a protocol routers use to share their tables, once somebody turns it on. You will look around the second 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, r2 and r3 are the routers; each has the OSPF program, ospfd, running. 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

Here r1 pings r2. Neighbours on one cable can always talk, with no routing needed.

Command
sudo ip netns exec r1 ping -c 2 -W 1 10.0.12.2

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 whether OSPF is on

The program is running, but nobody has told it which networks to share. show ip ospf neighbor lists the routers it has become neighbours with. The answer says OSPF is not enabled yet.

Command
sudo vtysh -N r1 -c "show ip ospf neighbor"

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

5. Read the router's settings

show running-config prints everything the router has been told: so far, only FRR's version, its defaults and a hostname line, and no router ospf section. Turning on OSPF means adding one here.

Command
sudo vtysh -N r1 -c "show running-config"

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 three routers inside it. The lab's check waits for the neighbours to be Full and 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: OSPF lab: bring up dynamic routing on three routers in your browser

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