Skip to content
Pwnversity
FUND-VIRTbasic · 11 min · upd. 2026-11

Virtualisation, Containers and Their Networks

Attacking other people’s systems without permission is a crime, so everything is learned in your own labs: isolated virtual machines and containers you can break and restore. On top of that, half of modern infrastructure is VMs and containers, so understanding how they connect to the network also means understanding your targets. Most “my reverse shell never arrives” lab problems are really a badly chosen network mode.

A hypervisor shares the hardware among several virtual machines, each with its own operating system and kernel.

Type Where it runs Examples Use
Type 1 (bare-metal) Directly on the hardware ESXi, Proxmox, Hyper-V Servers and data centres
Type 2 (hosted) On top of your OS VirtualBox, VMware Workstation/Fusion, UTM Your laptop

A snapshot freezes a VM’s full state (disk and, optionally, memory) so you can return to it whenever you want. It’s what turns a lab into a place to learn by trial and error: take a snapshot before anything destructive and, if you break the machine, restore it in seconds.

Virtual machine Container
What it is An emulated computer A normal process whose view and resources are limited by the system
Kernel Its own The host’s
Size and boot Gigabytes, minutes Megabytes, seconds
Isolation High Lower: a kernel bug affects them all

Because the container shares the kernel, it isn’t a strong security boundary: container escapes exist, and being in the docker group is equivalent to root on the host. See Docker.

The table describes VirtualBox. The names repeat across hypervisors, but the behaviour doesn’t always: in VMware Workstation/Fusion, for example, VMs on NAT share a virtual network and the host reaches them without port forwarding. Always check how yours does it.

Mode VM reaches the Internet Host reaches the VM VMs see each other Your real network sees the VM
NAT Yes No (only with port forwarding) No No
NAT Network Yes No (only with port forwarding) Yes No
Bridged Yes Yes Yes Yes: it’s just another machine
Host-only No Yes (and the VM can also reach the host’s services) Yes No
Internal No No Yes No

VirtualBox’s NAT mode is the one that confuses people most. Each VM lives alone on a private 10.0.2.0/24 network: the VM is 10.0.2.15 and its gateway 10.0.2.2. It can get out, but the host has no route to that network and can’t reach it, not even with ping. Port forwarding fixes this for TCP and UDP, but not for ICMP.

flowchart LR
    subgraph Host["Your laptop"]
        K["Kali 10.0.2.15"] --> N["VirtualBox NAT (10.0.2.2)"]
        H["Host-only 192.168.56.0/24"]
        K2["Kali 192.168.56.10"] --- H
        V["Victim 192.168.56.20"] --- H
    end
    N --> I["Internet"]

A common lab setup: Kali with two adapters, one on NAT (for updates) and another on host-only or internal (to talk to the victims), and the victims only on the isolated network.

  • Docker creates a virtual bridge, docker0 (usually 172.17.0.1), that acts as switch and gateway. Each container gets an IP from 172.17.0.0/16 and reaches the Internet through NAT on the host: the same structure as a VM’s NAT mode.
  • From outside you can’t reach a container unless you publish a port: -p 8080:80 means “host port 8080 goes to container port 80”. The left side is always your machine.
  • -p 8080:80 listens on all of the host’s interfaces; -p 127.0.0.1:8080:80 only locally.
  • On the default network containers see each other by IP but not by name. On a network you create (docker network create), Docker gives them internal DNS and they find each other by name.
Ventana de terminal
# Inside the VM: which network am I on and how do I get out?
ip -br -4 a
# eth0 UP 10.0.2.15/24 → VirtualBox NAT
# eth1 UP 192.168.56.10/24 → host-only
ip r
# default via 10.0.2.2 dev eth0
Ventana de terminal
# Local vulnerable lab, reachable only from your machine
docker run -d --name juice -p 127.0.0.1:3000:3000 bkimminich/juice-shop
docker ps # PORTS: 127.0.0.1:3000->3000/tcp
# Several containers that find each other by name
docker network create lab
docker run -d --name db --network lab -e MARIADB_ROOT_PASSWORD=lab mariadb:11
docker run -d --name web --network lab -p 127.0.0.1:8080:80 nginx:1.27
docker exec web getent hosts db # resolves thanks to the "lab" network's DNS
# Its internal IP and what changed inside compared with the image
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web
docker diff web
# Clean up
docker rm -f juice web db && docker network rm lab
  • Build your lab step by step: lab.
  • Spot that your shell is inside a container, and escape: Docker.
  • When a machine has several interfaces, each network is a possible hop: pivoting.
Concept What to remember
Type 1 · type 2 On the hardware · on your OS.
Snapshot Before anything destructive.
VM · container Own kernel · shared kernel (weaker isolation).
NAT (VirtualBox) Gets out, but nothing gets in. VM .15, gateway .2. Other hypervisors differ.
Bridged Just another machine on your real network. Never for victims.
Host-only · internal VMs + host (exposes the host) · VMs only (the option for malware).
docker0 172.17.0.1, network 172.17.0.0/16, NAT outwards.
-p 8080:80 Left is your machine, right is the container. All interfaces.
-p 127.0.0.1:... Local only. The right choice for vulnerable labs.
Docker and ufw Published ports bypass ufw.
docker group Equivalent to root on the host.
  1. Your Kali on VirtualBox NAT doesn’t receive the reverse shell from a victim in another VM, also on NAT. Why?

    Answer

    In NAT mode each VM sits alone on its own private network and nobody can open connections to it. The two VMs can’t see each other. Put them on a shared network (NAT Network, host-only or internal).

  2. Why can’t you ping a VM on NAT even though you’ve set up port forwarding?

    Answer

    Because port forwarding carries TCP and UDP connections to a specific port, and ping is ICMP, which has no ports.

  3. Which network mode would you use for a VM with malware, and why?

    Answer

    An internal network, with no way out and no port forwarding: the VM only sees other VMs on that network. Host-only isn’t enough, because from there the sample can reach your host’s services, and a snapshot only reverts the VM, not what it touched outside. And take a snapshot before you start.

  4. Why is a container megabytes in size and quick to start, and what’s the security consequence?

    Answer

    Because it doesn’t boot its own OS: it’s a process using the host’s kernel. The consequence is weaker isolation than a VM: a kernel bug or a misconfiguration (mounting the Docker socket, --privileged) allows escaping to the host.

  5. You run docker run -p 8080:80 vulnerables/web-dvwa and your ufw blocks 8080. Is it protected?

    Answer

    No. Docker inserts its iptables rules before ufw’s, so the port is reachable from the network. Publish it on 127.0.0.1:8080:80.

  6. Two containers on the default network can’t find each other by name. How do you fix it?

    Answer

    Create your own network (docker network create lab) and attach both to it: on user-defined networks, Docker provides internal DNS with the container names.