>_ IzzyLab

Hands-on task

This task is step 6 of the course “Containers from the inside: namespaces and cgroups”

An isolated network to test a client

medium~15 min

You need to check how the payment client behaves on a network where the only other thing is one server. Build an isolated network bench for it — the same way Docker builds a container's network:

  • a network namespace probe;
  • a veth pair: the veth-host end stays on the server with the address 10.200.0.1/24, the veth-probe end moves into probe with the address 10.200.0.2/24;
  • both ends and lo inside probe are up.

A test API is already running on the server on port 9090 — from probe it must open at http://10.200.0.1:9090/health.json. Leave Docker's networks alone.

What you'll practise:
  • network namespace
  • ip netns
  • veth
  • ip

Topic breakdown

A network namespace is a separate network stack: its own interfaces, addresses, routes, iptables rules and ports. A new namespace has only a lo that is down, so nothing outside can reach it until you lay a "wire". That wire is a veth pair — two virtual interfaces connected to each other: a packet sent into one end comes out of the other. One end stays on the host, the other moves into the namespace, and both get addresses from the same subnet. Docker does the same for every container: the eth0 end in the container, its veth… peer on the host, plugged into the docker0 bridge. ip netns add creates a named namespace (a file in /run/netns), and ip netns exec runs any host command in it.

What's checked

  1. The network namespace probe exists
  2. veth-host on the server: 10.200.0.1/24, up, its peer in probe
  3. In probe: veth-probe with 10.200.0.2/24 and lo are up
  4. 10.200.0.1 answers ping from probe
  5. The test API opens from probe

What it looks like