Skip to main content
RunBook Academy

← All labs in Docker & Containers

Lab · intermediate · ~35 min

Lab 4: Container networking — see veth, bridge, iptables

B · Nested virtualisationC · Simulation

Objectives

  • See the veth pair between container and host
  • See iptables DNAT rules for published ports
  • Trace a packet from container to outside

Prerequisites

  • Lab 1 completed

Objective

Trace a packet from inside a container through the host network stack. See the veth pair, the bridge, the iptables DNAT rules, and the host’s outbound interface.

Requirements

  • A Linux host.
  • Docker installed.
  • curl available.

Tasks

Task 1: Start a container

docker run --rm -d --name nettest -p 8080:80 nginx:1.27

Task 2: Find the veth pair

PID=$(docker inspect nettest --format '{{.State.Pid}}')

docker exec nettest ip link

HOST_VETH=$(ip link | grep "if${PID: -3}:" | head -1 | awk -F: '{print $2}' | xargs)
echo "Host-side veth: $HOST_VETH"
ip link show $HOST_VETH

Task 3: See the bridge

ip link show docker0
brctl show docker0

Task 4: See the iptables DNAT rule

iptables -t nat -L DOCKER -n -v | grep :8080

Task 5: Trace with tcpdump

In one terminal:

sudo tcpdump -i docker0 -n port 80 -c 5

In another terminal:

curl http://localhost:8080

Task 6: Clean up

docker stop nettest

Verification status

Last reviewed
2026-08-09
Executed end to end
not yet run on hardware

The commands and configuration here have been reviewed against the verified software versions, but nobody has run this lab start to finish on a system meeting its prerequisites. Treat the Expected Outcome as the intended result rather than an observed one, and keep the Cleanup section to hand.