Lab04: The Network Layer Part 1 -- Routing, IP Addressing, and Subnetting¶
Learning Goals¶
Goals for this week's lab
- Understand IP addresses and their organisation into subnets
- Create and configure Local Area Networks (LANs)
- Use basic Linux commands for managing
- IP addresses (IPv4 and IPv6)
- IP subnets and masks
- Recognize the role of routing in networking
- Use
ip routefor managing routes
IP Addressing and Subnetting¶
Launching GNS3 and Creating a Basic Network¶
To get started, create a new project with a basic network that consists of two interconnected ubuntu-host hosts like you did in lab02. You can revisit the instructions from lab02 for more details if necessary.
Create a minimal topology that consists of two directly connected hosts by dragging instances of the ubuntu-host onto the main panel, and then interconnecting their eth0 interfaces by consecutively clicking on the Add a link button and the two hosts. The result should look as follows.

Start all devices using the green button at the top.
Networking with Two Computers - IP Address Configuration¶
On ubuntu-host-1¶
- Using the command
ip addr show dev eth0, find out your current IP address, if any, oneth0. - Type
ip addr helpto see all the available options. - Let's now remove any unwanted addresses or routes on
eth0with the commandip addr flush dev eth0. - Visit Private network on Wikipedia to learn about the private IPv4 address ranges defined by the IETF and choose an address from any of the three ranges for your first host.
- Add an IP address and the respective mask to the interface
eth0using the commandip addr add <your_chosen_ip_here>/<chosen_mask> dev eth0. - Use the command
ip a s eth0(same as in step 1 but shorter) to verify your IP address. It should be the one you have just set. - Use the command
ip link set up dev eth0to "turn on" the interface, in case it is down.
On ubuntu-host-2¶
Repeat the configuration steps from ubuntu-host-1, setting its IP address to an appropriate value.
Tip
Remember that one IP address can only be used by a single interface in the same network. It should be unique.
Verifying Your Configuration¶
After configuring the two hosts, continue with the following steps.
- On one of the hosts, use the command
ip routeto see the routing table. For now, just report the entry you see. We will dive deeper into the exact meaning of it at a later stage of this lab. - Verify that both nodes have connectivity with the
pingcommand. First, by ping-ing ubuntu-host-2's IP address from ubuntu-host-1 and afterwards ubuntu-host-1's IP address from ubuntu-host-2. - Start a packet capture between the two hosts, run
pingagain, and observe what kind of packets / messages are exchanged. Do some research to figure out the broad use of the involved protocols (few sentences in your report are sufficient). You can also include a screenshot of your Wireshark window in the report if it helps with your explanations.
Experimenting with Masks¶
The goal of this task is to get more comfortable with subnets and masks and see how they work in practice. If you have questions about why something happens, or does not happen, feel free to ask!
On ubuntu-host-1¶
- Change the IP address of
eth0to10.10.10.30using the mask255.255.255.192. - Verify that you still have connectivity and discuss why or why not.
Tip
You may lose connectivity at this point depending on the IP addresses you have previously chosen.
On ubuntu-host-2¶
Make the following changes.
- Change the IP address of
eth0to10.10.10.5using the mask255.255.255.192. - Check for changes in connectivity between the two hosts. Can one still ping the other?
- Using the same IP address, change the mask to
/30. - Check for changes in connectivity between the two hosts.
- Using the same IP address, what is the smallest subnet size, and corresponding mask, that you can use to maintain connectivity between the two hosts? Why?
Tip
It may be helpful to convert the addresses of both hosts to binary first. Also, feel free to consult online tools such as the IP calculator.
Tip
Don't forget to make the changes on both hosts when experimenting with different subnet sizes.
REPORT
You don't have to include all the commands you needed to type. It is enough to discuss/explain the changes in connectivity and the choices you made.
IP Addressing: Optional IPv6 Exercise¶
Using the same topology, use IPv6 addresses and experiment with
- the
pingcommand - different subnets
Tip
Note that some commands require additional arguments to handle IPv6 (check their documentation).
Routing¶
Import and Topology¶
For this part of the lab, we're going to revisit the project from lab02 that comes with several pre-configured components.
If you still have the project from lab02, you can use that one. To make sure that changes are applied within GNS3, close any running instances of GNS3 and launch it again, then pick the project from the Projects library tab as outlined in the following graphic.

If you no longer have it, download the same project below and import it into GNS3 via File → Import portable project.
- Download: GNS3 project - lab04
You will be presented with a network topology that consists of three routers (R1-R3), a switch, and three hosts, corresponding to a client, a DNS server, and a (web) server. A schematic overview of the network topology is provided in the graphic below. The graphic shows network interface names alongside their configured IP addresses and their interconnections. It uses the same colors to highlight interfaces that are on the same subnet.

Identifying Packets' Paths and Confirming Routes¶
The hosts and routers are already set up in a way that allows communication
between the client (10.240.1.3) and the server (10.168.1.2).
First, confirm that this is actually the case,
for instance by ping-ing from one to the other.
Although this confirms connectivity,
you do not yet know which path packets take through the network
to reach their respective destination.
-
Recall (or look up online) which command line tool we used to figure out the path packets take to a given destination. Use it to determine the sequence of IP addresses / interfaces / devices that packets from the client take on their way to the server.
The way packets are treated by computers and routers along the way is determined by the devices' routing tables. You can inspect routing table entries by issuing the
ip routecommand. For instance, the routing table of the client looks as follows:root@client:/# ip route 10.168.1.0/24 via 10.240.1.1 dev eth0 10.240.1.0/24 dev eth0 proto kernel scope link src 10.240.1.3The first item of any routing table entry is the destination network (
10.168.1.0/24and10.240.1.0/24in this example). If the device wants to send a packet towards the specified network, it will consult the matching routing table entry to find the appropriate interface to send it out of and the next-hop device (typically a router) along the way.In case of the first rule, packets destined for the
10.168.1.0/24network will be sent out theeth0interface towards theeth0interface of router R1, which is on the same network as the client and has the IP address10.240.1.1.The second rule states that if the client wants to send data to any device in the
10.240.1.0/24network, it shall use theeth0interface and use10.240.1.3as its source IP address. -
Using the
ip routecommand on the routers you identified along the path from client to server, confirm that the route configuration does indeed match the observed behavior. In particular, explain which routing table entries are triggered when a packet from the client to the server or a packet from the server to the client traverses the respective router.
Adjusting Routes¶
In addition to retrieving routing table information,
the ip route command can be used to modify routing behavior.
Using the same syntax as the outputs we discussed in step 1,
we can use ip route add and ip route del to add or delete entries.
For instance, you can delete the route from the client to the server with
ip route del 10.168.1.0/24 via 10.240.1.1 dev eth0.
- What happens if you try to ping or otherwise reach the server after deleting the route? Add the route again and confirm that connectivity is restored.
- Using your knowledge of routing and the
ip routecommand, adjust the routing table entries on routers R1, R2, and R3 so that packets between the client and the server take the path client-R1-R2-server. Document and discuss the purpose of all commands and where you used them, and finally confirm your configuration by once again checking the output of the tool for checking the end-to-end path on the client.
Tip
For this step, you will only need rules of the shape
<destination_network/mask> via <next_hop_ip> dev <interface>.
Tip
If your configuration happens to break along the way, you can just restart the device in question or the entire network to revert it back to its initial configuration. If restarting the device(s) from within GNS3 does not resolve the issue, you can also exit and restart GNS3.