Day 0: The training ground
Goal: Turn an empty Ubuntu VM into a small company network to break: two sites, a router, a web server, a database and a separate storage network, all as network namespaces on one VM · Duration: approx. 75 min · Prerequisite: a VM with Ubuntu 24.04, SSH access and
sudo
Briefing
- From the outside, network faults always look the same: “doesn’t work”, “hangs”, “timeout”. People who find them fast don’t guess, they measure layer by layer: link, address, route, neighbor, port, name, protocol. That is exactly what you practice in this course, every day on a different failure pattern.
- For that you need a network you can destroy without fear. Today you build it on a single VM: every “machine” is a network namespace with its own interfaces, addresses, routes and firewall rules. To the kernel it is a separate machine, but it costs only a few kilobytes.
- From Day 11 on, a Kubernetes cluster with Cilium joins in. Today only the training ground.
| Namespace | Role | Addresses |
|---|---|---|
client |
workstation at site A | 10.1.0.10/24 |
router |
connects A, B and the internet | 10.1.0.1, 10.2.0.1,
192.168.100.2/30 |
web |
web server at site B, second leg in the storage network | 10.2.0.10, 10.10.0.10 |
db |
database at site B, also in the storage network | 10.2.0.20, 10.10.0.20 |
The storage network 10.10.0.0/24 is deliberately not
routed, just like the replication network of a storage cluster (for DRBD
or Ceph, say) that only the storage nodes see among themselves.
How you work throughout the course
For every fault you go through four steps and jot them down briefly:
- Hypothesis: What could it be? (“The route is missing.”)
- Measurement: A command that confirms or refutes the
hypothesis (
ip route get …). - Cause: What exactly is wrong, with evidence from the output.
- Proof of the fix: The same command as in step 2 now shows the correct result.
Step 4 is the one people forget most often in day-to-day work. “It works now” is not proof; the output before and after is.
Drill 1: Access and starting point
If you don’t have an SSH key for the VM yet, create it on your own machine and copy the public part to the VM:
# on your machine
# Creates a new key pair for the lab
# -t ed25519 key type: Ed25519 (short, fast, today's standard)
# -C "netz-labor" comment in the public key so you recognize it later
# -f ~/.ssh/netz file name: private part ~/.ssh/netz, public ~/.ssh/netz.pub
ssh-keygen -t ed25519 -C "netz-labor" -f ~/.ssh/netzExpected (for a lab you can leave the passphrase prompt empty with Enter):
Generating public/private ed25519 key pair.
Your identification has been saved in /home/du/.ssh/netz
Your public key has been saved in /home/du/.ssh/netz.pub
The key fingerprint is:
# on your machine
# Copies the public key into ~/.ssh/authorized_keys on the VM (asks for the password once)
# -i ~/.ssh/netz.pub which public key is transferred
# ubuntu@<IP der VM> user and address of the VM
ssh-copy-id -i ~/.ssh/netz.pub ubuntu@<IP der VM>
# Logs in with the new key
# -i ~/.ssh/netz private key for this connection
ssh -i ~/.ssh/netz ubuntu@<IP der VM>If you created the VM with cloud-init or through your hypervisor’s
interface (Proxmox, multipass), the key is often already in place; then
you skip ssh-copy-id. In the lab the VM is called
netz and has the address 172.16.0.123. All
further commands run on it.
First look at what is there:
# on netz
# Name and version of the distribution
# -d description only
# -s short, without header
lsb_release -ds
# Number of CPUs
nproc
# Memory in readable units (-h), only header and first line (head -2)
free -h | head -2
# Package architecture: amd64 or arm64
dpkg --print-architecture
# Running kernel version (-r = release)
uname -rExpected (in the lab; your values differ):
Ubuntu 24.04.5 LTS
2
total used free shared buff/cache available
Mem: 3.8Gi 501Mi 2.2Gi 1.0Mi 1.4Gi 3.3Gi
amd64
6.8.0-149-generic
Then the network from the VM’s point of view:
# on netz
# All interfaces with addresses, one line per interface
# -br brief: table form instead of detailed output
# a short form of addr (addresses)
ip -br a
# The routing table (r = short form of route)
ip rExpected:
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0 UP 172.16.0.123/24 metric 100 fd0e:fdec:438a:328:be24:11ff:fe4d:d908/64 fe80::be24:11ff:fe4d:d908/64
default via 172.16.0.1 dev eth0 proto dhcp src 172.16.0.123 metric 100
1.1.1.1 via 172.16.0.1 dev eth0 proto dhcp src 172.16.0.123 metric 100
8.8.8.8 via 172.16.0.1 dev eth0 proto dhcp src 172.16.0.123 metric 100
172.16.0.0/24 dev eth0 proto kernel scope link src 172.16.0.123 metric 100
172.16.0.1 dev eth0 proto dhcp scope link src 172.16.0.123 metric 100
172.16.0.15 dev eth0 proto dhcp scope link src 172.16.0.123 metric 100
Read each column consciously once:
| Part | Meaning |
|---|---|
UP / UNKNOWN |
state of the interface; lo always reports
UNKNOWN, that is normal |
default via 172.16.0.1 |
everything without a more specific route goes to this router |
dev eth0 |
via which interface |
proto dhcp |
the route came from the DHCP server, not from you |
proto kernel scope link |
the local network; the kernel adds it as soon as the address is set |
src 172.16.0.123 |
source address the kernel picks for this route |
metric 100 |
cost of the route; with two identical destinations the smaller number wins |
Save your progress? Sign up for free
Drill 2: The tools
# on netz
# Update package lists
sudo apt-get update
# Install the tools for the whole course
# DEBIAN_FRONTEND=noninteractive no prompts (otherwise tshark asks about capture permissions)
# install -y install and answer all questions with yes
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y tcpdump tshark mtr-tiny netcat-openbsd \
dnsutils conntrack ethtool arping iperf3 socat nftables iputils-tracepath traceroute curl opensslWhat you need each for:
| Package | Commands | from Day | Version in the lab |
|---|---|---|---|
| iproute2 (preinstalled) | ip, ss, bridge |
0 | 6.1.0 |
| ethtool | ethtool |
1 | 6.7 |
| arping | arping |
3 | 2.24 |
| mtr-tiny, iputils-tracepath, traceroute | mtr, tracepath,
traceroute |
4 | 0.95, 20240117, 2.1.5 |
| netcat-openbsd, socat | nc, socat |
4 | 1.226, 1.8.0.0 |
| dnsutils | dig |
6 | 9.18.39 |
| curl | curl |
7 | 8.5.0 |
| openssl | openssl |
8 | 3.0.13 |
| nftables, conntrack | nft, conntrack |
9 | 1.0.9, 1.4.8 |
| tcpdump, tshark | tcpdump, tshark |
10 | 4.99.4, 4.2.2 |
| iperf3 | iperf3 |
15 | 3.16 |
Check that everything is there:
# on netz
# Prints the path for each command; if one is missing, it is listed
# command -v looks up a command in PATH without running it
for b in ip ss bridge ethtool arping mtr tracepath traceroute nc socat dig curl openssl nft conntrack tcpdump tshark iperf3; do
command -v $b >/dev/null || echo "fehlt: $b"
done; echo fertigExpected:
fertig
Save your progress? Sign up for free
Drill 3: Namespaces and bridges
First the four “machines”:
# on netz
# Creates four empty network namespaces (netns add <Name>)
sudo ip netns add client
sudo ip netns add router
sudo ip netns add web
sudo ip netns add db
# Lists all named namespaces
ip netns listExpected:
db
web
router
client
A fresh namespace has only a loopback interface, and it is down. Then the three “switches”: Linux bridges in the root namespace, that is, on the VM itself. A bridge forwards Ethernet frames between its ports like a switch.
# on netz
# Create a bridge
# link add br-a new interface named br-a
# type bridge kind of interface: software switch
sudo ip link add br-a type bridge
sudo ip link add br-b type bridge
sudo ip link add br-s type bridge
# Bring the bridges up (link set <Name> up)
sudo ip link set br-a up
sudo ip link set br-b up
sudo ip link set br-s up
# Show only interfaces of type bridge, in short form
ip -br link show type bridgeExpected:
br-a DOWN 96:03:5e:91:50:e9 <NO-CARRIER,BROADCAST,MULTICAST,UP>
br-b DOWN 72:4a:07:a2:69:71 <NO-CARRIER,BROADCAST,MULTICAST,UP>
br-s DOWN d6:bd:de:6e:d3:d4 <NO-CARRIER,BROADCAST,MULTICAST,UP>
Remember this picture, it comes back on Day 1: the flags say
UP (you brought them up), yet the column before says
DOWN, together with NO-CARRIER. A bridge
without a single attached, active port has no carrier, like a switch
with no cable plugged in.
Save your progress? Sign up for free
Drill 4: Pulling cables
A veth pair is a virtual cable with two ends: whatever goes into one comes out of the other. One end stays on the VM and plugs into a bridge, the other moves into a namespace.
# on netz
# Cable for client: one end a-client on the VM, the other is called eth0 in the namespace client
# link add a-client name of the end on the VM
# type veth virtual Ethernet cable pair
# peer name eth0 name of the other end
# netns client move the other end into the namespace client right away
sudo ip link add a-client type veth peer name eth0 netns client
# The remaining cables follow the same pattern
sudo ip link add a-router type veth peer name eth-a netns router
sudo ip link add b-router type veth peer name eth-b netns router
sudo ip link add b-web type veth peer name eth0 netns web
sudo ip link add b-db type veth peer name eth0 netns db
sudo ip link add s-web type veth peer name stor0 netns web
sudo ip link add s-db type veth peer name stor0 netns dbThe names on the VM follow a scheme: letter of the bridge, hyphen, namespace. That way you see right away in every output where a cable leads. Now plug the VM ends into the bridges:
# on netz
# Attach a port to a bridge and bring it up
# link set a-client change this interface
# master br-a attach it to the bridge br-a
# up bring it up
sudo ip link set a-client master br-a up
sudo ip link set a-router master br-a up
sudo ip link set b-router master br-b up
sudo ip link set b-web master br-b up
sudo ip link set b-db master br-b up
sudo ip link set s-web master br-s up
sudo ip link set s-db master br-s up
# All bridge ports with state (bridge link = ports of all bridges)
bridge linkExpected:
28: a-client@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 master br-a state disabled priority 32 cost 2
29: a-router@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 master br-a state disabled priority 32 cost 2
30: b-router@if3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 master br-b state disabled priority 32 cost 2
31: b-web@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 master br-b state disabled priority 32 cost 2
32: b-db@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 master br-b state disabled priority 32 cost 2
33: s-web@if3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 master br-s state disabled priority 32 cost 2
34: s-db@if3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 master br-s state disabled priority 32 cost 2
NO-CARRIER again, and the bridge sets the ports to
state disabled: the other end of each cable sits in the
namespace and is still down. A veth end only has a carrier once
both ends are up. @eth0 or
@if3 names the counterpart: either by name or, if the name
would be ambiguous in another namespace, by the number of the interface
there.
Save your progress? Sign up for free
Drill 5: Addresses
# on netz
# Bring up loopback in each namespace
# -n client run the command in the namespace client (short form of ip netns exec client ip …)
sudo ip -n client link set lo up
sudo ip -n router link set lo up
sudo ip -n web link set lo up
sudo ip -n db link set lo up
# Set the address and bring the interface up
# addr add 10.1.0.10/24 address with prefix length: 24 bits network, so 10.1.0.0 to 10.1.0.255
# dev eth0 on which interface
sudo ip -n client addr add 10.1.0.10/24 dev eth0
sudo ip -n client link set eth0 up
sudo ip -n router addr add 10.1.0.1/24 dev eth-a
sudo ip -n router addr add 10.2.0.1/24 dev eth-b
sudo ip -n router link set eth-a up
sudo ip -n router link set eth-b up
sudo ip -n web addr add 10.2.0.10/24 dev eth0
sudo ip -n web addr add 10.10.0.10/24 dev stor0
sudo ip -n web link set eth0 up
sudo ip -n web link set stor0 up
sudo ip -n db addr add 10.2.0.20/24 dev eth0
sudo ip -n db addr add 10.10.0.20/24 dev stor0
sudo ip -n db link set eth0 up
sudo ip -n db link set stor0 upEven reading in a namespace requires
sudo: without root privileges ip may not
switch into another namespace and reports
setting the network namespace "client" failed: Operation not permitted.
# on netz
# Addresses of all four namespaces in short form
sudo ip -n client -br addr
sudo ip -n router -br addr
sudo ip -n web -br addr
sudo ip -n db -br addrExpected (your fe80:: addresses are
different):
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0@if28 UP 10.1.0.10/24 fe80::f4bb:48ff:fed1:4bb9/64
lo UNKNOWN 127.0.0.1/8 ::1/128
eth-a@if29 UP 10.1.0.1/24 fe80::e82b:4dff:fecf:8859/64
eth-b@if30 UP 10.2.0.1/24 fe80::3800:5bff:fe1e:8679/64
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0@if31 UP 10.2.0.10/24 fe80::4886:c1ff:fede:4534/64
stor0@if33 UP 10.10.0.10/24 fe80::e0ae:31ff:fed9:99b1/64
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0@if32 UP 10.2.0.20/24 fe80::344b:cbff:fe79:ef3a/64
stor0@if34 UP 10.10.0.20/24 fe80::444e:6eff:fe8b:6afb/64
bridge link now shows LOWER_UP and
state forwarding for all ports. The first test:
client reaches its router in the same network.
# on netz
# Two pings from client to the router
# ip netns exec client run any command in the namespace client
# -c2 send two packets, then stop
# -W1 wait at most 1 second for each reply
# | tail -2 only the last two lines (summary)
sudo ip netns exec client ping -c2 -W1 10.1.0.1 | tail -2Expected:
2 packets transmitted, 2 received, 0% packet loss, time 1020ms
rtt min/avg/max/mdev = 0.145/0.185/0.226/0.040 ms
And the web server at the other site?
# on netz
# Asks the kernel in the namespace client which path a packet to 10.2.0.10 would take
# route get 10.2.0.10 routing decision for exactly this destination address
sudo ip -n client route get 10.2.0.10Expected:
RTNETLINK answers: Network is unreachable
This is the first real fault of the course, and the message is
unambiguous: in the namespace client there is only the
route into its own network 10.1.0.0/24, no default route.
The packet would not even leave the machine. ip route get
is the most important tool on Day 2.
Save your progress? Sign up for free
Drill 6: Routes and forwarding
# on netz
# Set the default route: everything foreign goes to the router in the local network
# route add default route for all destinations without a more specific route
# via 10.1.0.1 next hop (gateway)
sudo ip -n client route add default via 10.1.0.1
sudo ip -n web route add default via 10.2.0.1
sudo ip -n db route add default via 10.2.0.1
# New attempt via the router
sudo ip netns exec client ping -c2 -W1 10.2.0.10 | tail -2Expected:
2 packets transmitted, 0 received, 100% packet loss, time 1046ms
The route is there, yet nothing comes back. Hypothesis: the router doesn’t forward. Linux drops packets that are not addressed to one of its own addresses as long as forwarding is off, and this setting applies per namespace.
# on netz
# Turn on forwarding in the namespace router
# sysctl -w set a kernel parameter at runtime
# net.ipv4.ip_forward=1 forward IPv4 packets between interfaces
sudo ip netns exec router sysctl -w net.ipv4.ip_forward=1
# Proof of the fix: the same ping as above
sudo ip netns exec client ping -c2 -W1 10.2.0.10 | tail -2
# For comparison: the setting in the VM's root namespace is unaffected
sysctl net.ipv4.ip_forwardExpected:
net.ipv4.ip_forward = 1
2 packets transmitted, 2 received, 0% packet loss, time 1030ms
rtt min/avg/max/mdev = 0.127/0.206/0.286/0.079 ms
net.ipv4.ip_forward = 0
Save your progress? Sign up for free
Drill 7: The way out
For DNS, curl and TLS from Day 6 on, the namespaces need
the internet. Another cable connects the router to the VM, and the VM
translates the addresses to its own via NAT.
# on netz
# Cable between VM (up0) and router (wan0)
sudo ip link add up0 type veth peer name wan0 netns router
# Transfer network with two addresses: /30 = 4 addresses, 2 of them usable
sudo ip addr add 192.168.100.1/30 dev up0
sudo ip link set up0 up
sudo ip -n router addr add 192.168.100.2/30 dev wan0
sudo ip -n router link set wan0 up
# The router's default route points to the VM
sudo ip -n router route add default via 192.168.100.1
# The VM now has to forward itself (packets from wan0 to eth0)
sudo sysctl -w net.ipv4.ip_forward=1Then NAT twice: the router hides the site networks behind
192.168.100.2, the VM hides 192.168.100.2
behind its own address. nftables rules are organized in tables and
chains; Day 9 reads them in detail, today only the bare minimum.
# on netz
# In the router: create table nat for IPv4
# add table ip nat new table named nat for the address family ip (IPv4)
sudo ip netns exec router nft add table ip nat
# Chain postrouting, hooked in where packets leave the machine
# type nat chain for address translation
# hook postrouting after the routing decision, just before sending
# priority srcnat standard priority for source NAT
sudo ip netns exec router nft add chain ip nat postrouting '{ type nat hook postrouting priority srcnat; }'
# Everything that goes out via wan0 gets the address of wan0 as source
# oifname wan0 condition: the output interface is called wan0
# masquerade replace the source address with the address of the output interface
sudo ip netns exec router nft add rule ip nat postrouting oifname wan0 masquerade
# The same on the VM in a separate table ndbg, so it stands out from other rules
sudo nft add table ip ndbg
sudo nft add chain ip ndbg postrouting '{ type nat hook postrouting priority srcnat; }'
# ip saddr 192.168.100.0/30 only packets from the transfer network
# oifname eth0 that go out into the home network
sudo nft add rule ip ndbg postrouting ip saddr 192.168.100.0/30 oifname eth0 masquerade
# Check: the rule on the VM
# list table ip ndbg print exactly this table
sudo nft list table ip ndbgExpected:
table ip ndbg {
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
ip saddr 192.168.100.0/30 oifname "eth0" masquerade
}
}
That leaves DNS. A namespace shares the file system with the VM,
including /etc/resolv.conf, and on Ubuntu that file says
127.0.0.53, the local systemd resolver. But it listens only
in the root namespace. ip netns exec has a mechanism for
this: if a file exists under /etc/netns/<Namespace>/,
it is laid over the file of the same name in /etc/ for
commands in that namespace.
# on netz
# Separate resolv.conf for client, web and db
# mkdir -p create the directory, no error if it already exists
# tee <Datei> writes the input to the file (with sudo, because /etc belongs to root)
# >/dev/null discard tee's screen output
sudo mkdir -p /etc/netns/client /etc/netns/web /etc/netns/db
echo "nameserver 1.1.1.1" | sudo tee /etc/netns/client/resolv.conf >/dev/null
echo "nameserver 1.1.1.1" | sudo tee /etc/netns/web/resolv.conf >/dev/null
echo "nameserver 1.1.1.1" | sudo tee /etc/netns/db/resolv.conf >/dev/null
# The proof: an HTTPS request from the client
# -s silent: no progress bar
# -o /dev/null discard the page content
# -w '%{http_code} …\n' after the request, print only status code and destination address
sudo ip netns exec client curl -s -o /dev/null -w '%{http_code} %{remote_ip}\n' https://example.comExpected (the address may change):
200 104.20.23.154
Save your progress? Sign up for free
Drill 8: A service for testing
From now on a small web server runs on web. So that it
keeps running when you log out, you start it as a transient systemd
unit:
# on netz
# Directory with a test page
mkdir -p ~/www
echo "hallo von web" > ~/www/index.html
# Start a Python web server in the namespace web as a systemd unit
# systemd-run starts a command as a transient unit
# --unit=web-http name of the unit (for status/stop)
# --property=WorkingDirectory=/home/ubuntu/www working directory = files being served
# ip netns exec web run in the namespace web
# python3 -m http.server 80 simple web server on port 80
# --bind 10.2.0.10 listen only on this address
sudo systemd-run --unit=web-http --property=WorkingDirectory=/home/ubuntu/www \
ip netns exec web python3 -m http.server 80 --bind 10.2.0.10If your user is not called ubuntu, adjust the path. Then
the request from the other site:
# on netz
# Fetch the page from the client (-s silent)
sudo ip netns exec client curl -s http://10.2.0.10/
# Who listens in the namespace web?
# ss show sockets
# -l only listening sockets
# -t only TCP
# -n addresses and ports as numbers, don't resolve names
# -p show the process as well
sudo ip netns exec web ss -ltnpExpected:
hallo von web
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 5 10.2.0.10:80 0.0.0.0:* users:(("python3",pid=45984,fd=3))
Save your progress? Sign up for free
Exercise: The storage network
- Check whether
webreaches the database via the storage network, and which path the kernel picks for it. - Does
clientreach the address10.10.0.20as well? If not: at which point does the packet get lost? Prove it withip route getin two namespaces.
Solution
# on netz
# 1: one ping (-c1), reply timeout 1 s (-W1), summary only (-q)
sudo ip netns exec web ping -c1 -W1 -q 10.10.0.20 | tail -2
# Path: directly via stor0, without a router
sudo ip netns exec web ip route get 10.10.0.20Expected:
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.158/0.158/0.158/0.000 ms
10.10.0.20 dev stor0 src 10.10.0.10 uid 0
cache
# on netz
# 2: from the client
sudo ip netns exec client ping -c1 -W1 -q 10.10.0.20 | tail -2
# Step 1 of the path: client sends it to its router
sudo ip netns exec client ip route get 10.10.0.20
# Step 2: the router doesn't know 10.10.0.0/24 and sends it to the internet
sudo ip netns exec router ip route get 10.10.0.20Expected:
1 packets transmitted, 0 received, 100% packet loss, time 0ms
10.10.0.20 via 10.1.0.1 dev eth0 src 10.1.0.10 uid 0
cache
10.10.0.20 via 192.168.100.1 dev wan0 src 192.168.100.2 uid 0
cache
The router has no route into the storage network, so its default
route toward the VM and the internet kicks in, where
10.10.0.20 belongs to nobody. That is exactly how it should
be: the storage network is not reachable from the outside.
uid 0 only means the query ran as root; cache
shows that the kernel cached the decision.
Save your progress? Sign up for free
Challenge
A colleague asks: “Nobody listens on port 80 on the VM, but
curl http://10.2.0.10 works. Where does the web server
run?” Prove with commands in the root namespace which
namespace the process of the unit web-http lives in.
Solution
# on netz
# Nothing listens on port 80 on the VM itself
# grep ':80 ' only lines with port 80
# || otherwise print a note
sudo ss -ltnp | grep ':80 ' || echo "Root-Namespace: niemand auf Port 80"
# Process ID of the unit's main process
# show -p MainPID only this property
# --value only the value, without “MainPID=”
systemctl show -p MainPID --value web-http
# Which named namespace does this PID live in?
# netns identify <PID> compares the process's network namespace with all named ones
sudo ip netns identify $(systemctl show -p MainPID --value web-http)Expected:
Root-Namespace: niemand auf Port 80
45984
web
The same trick helps later with containers: every container and every pod has its own network namespace, and “the port is open, but not on the host” is one of the most common confusions.
Save your progress? Sign up for free
After a reboot
Namespaces, bridges, addresses, NAT rules and the unit
web-http live only in memory. After a reboot of the VM the
training ground is gone; only /etc/netns/ and
~/www remain. Then you run the commands from Drills 3 to 8
again; Appendix A collects them in the right
order. That is intentional: every rebuild is a repetition of Day 0.
Checkpoint
# on netz
# four namespaces
ip netns list | wc -l
# three bridges with carrier
ip -br link show type bridge | grep -c ' UP '
# router forwards
sudo ip netns exec router sysctl -n net.ipv4.ip_forward
# client reaches web at the other site
sudo ip netns exec client curl -s http://10.2.0.10/
# client reaches the internet with name resolution
sudo ip netns exec client curl -s -o /dev/null -w '%{http_code}\n' https://example.com
# storage network stays internal
sudo ip netns exec client ping -c1 -W1 -q 10.10.0.20 >/dev/null || echo "10.10.0.20 von client aus nicht erreichbar"wc -l counts lines, grep -c counts matching
lines, sysctl -n prints only the value without the
name.
Expected:
4
3
1
hallo von web
200
10.10.0.20 von client aus nicht erreichbar
Interview note
“How do you proceed when a service is unreachable?” A good answer
names an order and a command for each stage: link
(ip -br link), address (ip -br addr), route
(ip route get), neighbor (ip neigh), port
(ss -ltn, nc -zv), name (dig),
protocol (curl -v), and at the end the proof of the fix
with the same command. If you can explain why ip_forward
applies per namespace, you have understood that containers and pods are
built on exactly this mechanism.
Enterprise note
Many teams don’t build a test environment for network faults and learn on the production network. A training ground made of namespaces like this one fits on any laptop with a Linux VM and can be rebuilt in a minute. It is also suitable for rehearsing firewall or routing changes before the change window, with the same addresses as in production, but without risk.