TT Lab
Get started
Learn Learning paths Courses

Network Fundamentals — Hands-on in a Linux VM

Read Interfaces and Addresses, Cut Subnets

Continue in TT Lab

This lab runs on a VM

It is a single Ubuntu 24.04 VM. You are root and have kernel privileges, so you can create interfaces and attach addresses. It takes 1–2 minutes to start (because it installs packages).

Goal

Read which interface your computer uses, what address it has, and where it sends traffic out; calculate subnets; and create an interface yourself and attach an address to it.

Why it matters

"Is it on the same subnet?" is the first question that splits paths in networking. If yes, the host calls the peer directly with ARP; if no, it hands the packet to the gateway. So get one mask wrong and the computer at the next desk ends up on the other side of the planet, and put the gateway address in a different range and you get "Network is unreachable". This calculation is the foundation of firewall rules, Kubernetes Pod ranges, and VPC design, so getting it into your hands here makes every later lab easier.

Steps

  1. Save the output of ip -br link to /root/ip/links.txt. lo and the interface the default route goes out through (on this VM, enp1s0) must show as UP.
  2. Save the IPv4 address of the default-route interface, with its prefix, on one line in /root/ip/addr.txt (for example, in the form 10.0.2.2/24).
  3. Calculate 172.16.37.200/20 and save it in /root/ip/calc.txt as five lines: network=·broadcast=·first=·last=·hosts=.
  4. Split 10.42.0.0/24 into four /26 blocks and write them in /root/ip/split.txt, one per line, in the form 네트워크/26 첫호스트 마지막호스트 (that is, network/26, first host, last host).
  5. Create a dummy interface lab0, attach 192.0.2.10/28 to it, and bring it UP.
  6. Add a second address 192.0.2.20/28 to lab0 and save the output of ip -br -4 addr show lab0 to /root/ip/lab0.txt.
  7. Decide whether each of five pairs is on the same subnet and write the results in /root/ip/pairs.txt in the form 주소/프리픽스 상대주소 same|different (address/prefix, peer address, then same or different). The pairs are 10.0.0.5/24 10.0.0.200, 10.0.1.5/24 10.0.0.200, 192.168.1.77/25 192.168.1.130, 172.16.5.9/12 172.31.0.1, and 172.16.5.9/16 172.31.0.1.
  8. In /root/ip/report.md, write three lines, uplink=·address=·gateway=, together with an explanation of why the gateway must be on the same subnet.

Notes

Interface list

Save the output of ip -br link to /root/ip/links.txt. lo and the interface the default route goes out through must show as UP.

Run mkdir -p /root/ip first. -br means brief: one line per interface with name, state, and MAC. The default-route interface is after dev in ip route show default.

My address and prefix

Save the IPv4 address of the default-route interface, with its prefix, on one line in /root/ip/addr.txt.

The third column of ip -br -4 addr show <인터페이스> is 주소/프리픽스 (address/prefix; replace the placeholder with the interface name). If you prefer JSON, pull out .addr_info[].local and .prefixlen with ip -j addr show <인터페이스> | jq.

Subnet calculation

Calculate 172.16.37.200/20 and save it in /root/ip/calc.txt as five lines: network=·broadcast=·first=·last=·hosts=.

ipcalc 172.16.37.200/20 calculates everything. With /20, the network covers the first 4 bits of the third octet, so 37 falls in the 32–47 block. hosts is the total minus the network and broadcast addresses.

Splitting a subnet

Split 10.42.0.0/24 into four /26 blocks and write them in /root/ip/split.txt, one per line, in the form 네트워크/26 첫호스트 마지막호스트 (network/26, first host, last host).

Borrowing 2 bits going from /24 to /26 gives four blocks of 64. The block boundaries are 0, 64, 128, and 192. The first host of each block is network+1, and the last is broadcast-1.

Creating an interface and attaching an address

Create a dummy interface lab0, attach 192.0.2.10/28 to it, and bring it UP.

ip link add lab0 type dummy → ip addr add 192.0.2.10/28 dev lab0 → ip link set lab0 up. A dummy has no cable, so even if the state shows UNKNOWN, it is on if the flags include UP.

Two addresses on one interface

Add a second address 192.0.2.20/28 to lab0 and save the output of ip -br -4 addr show lab0 to /root/ip/lab0.txt.

Just run ip addr add once more. You can attach as many addresses as you like to one interface. Both addresses must appear in the saved file.

Same subnet or not

Decide whether each of five pairs is on the same subnet and write the results in /root/ip/pairs.txt in the form 주소/프리픽스 상대주소 same|different (address/prefix, peer address, then same or different). The pairs are 10.0.0.5/24 10.0.0.200, 10.0.1.5/24 10.0.0.200, 192.168.1.77/25 192.168.1.130, 172.16.5.9/12 172.31.0.1, and 172.16.5.9/16 172.31.0.1.

The test is "Is the peer address inside my network?" With /25 the split falls at 128, and /12 treats 172.16 through 172.31 as one block. Cross-check with the Python expression ipaddress.ip_address(b) in ipaddress.ip_network(a, strict=False).

What you learned

In /root/ip/report.md, write three lines, uplink=·address=·gateway=, together with an explanation of why the gateway must be on the same subnet.

uplink is the name of the default-route interface, address is the value from step 2, and gateway is the address after via in ip route show default. Your explanation must include the point that ARP reaches only the same link.