Skip to content
Visual explainer 6h to learn 5 steps

Build an isolated lab

Run Kali and vulnerable VMs on a host-only network that cannot reach real systems.

By Invicly Tech, , in Ethical Hacking & Penetration Testing. About 9 minutes to read.

Topic 4 of 32

In short

Practising safely means an isolated lab that cannot reach real systems. A hypervisor runs Kali alongside deliberately vulnerable VMs on a host-only network, and snapshots let you reset instantly after each exercise.

Explained simply

A lab is your private practice ground. It is made of virtual machines (VMs), which are whole computers running as programs inside your real computer. One VM is your attacker workstation, usually Kali Linux. The others are targets that were built to be broken.

The most important rule is isolation. The deliberately vulnerable targets must never be reachable from your home network or the internet. Otherwise a stranger could break into them, or your tools could hit a real device by mistake. A host-only network solves this: VMs can talk to each other and to your PC, but nowhere else.

VirtualBox is a free hypervisor (the program that runs VMs) for Windows, Linux and macOS on Intel. VMware Workstation Pro is now also free for personal use. Kali offers ready-made VM images, so you can import one instead of installing from scratch.

Snapshots are save points. Take one when a VM is clean and working. After an exercise, or when you break something, restore the snapshot and you are back in a minute. This makes it safe to experiment.

Press Play on a diagram to walk through it one step at a time.

LayersLab components
  1. 1
    Hypervisor

    VirtualBox or similar.

  2. 2
    Host-only network

    Isolated, no internet.

  3. 3
    Kali VM

    Your testing workstation.

  4. 4
    Target VMs

    Deliberately vulnerable machines.

MapA typical beginner lab
Your PC (VirtualBox)
  • NAT adapter
    • Kali only, for apt updates
    • Disconnect while testing
  • Host-only 192.168.56.0/24
    • Host at 192.168.56.1
    • Kali, for example .101
    • Targets, for example .102 and .103
  • Targets
    • Metasploitable 2
    • DVWA or Juice Shop VM
    • VulnHub machines
  • Snapshots
    • clean after install
    • before each exercise

In depth

VirtualBox network modes compared

Each VM network adapter has a mode, and the mode decides who it can reach. NAT gives the VM internet through your PC but other machines cannot reach it. Bridged puts the VM directly on your home network, like another laptop; never use it for vulnerable targets. Internal network connects only VMs that use the same network name, with no access to your PC. Host-only connects VMs and your PC on a private network, by default 192.168.56.0/24 with your PC at 192.168.56.1.

A common safe design: targets get only a host-only adapter. Kali gets a host-only adapter for the lab and, when you need updates, a second NAT adapter that you can disconnect while you test.

CompareWhich adapter mode for which VM
Host-only
  • VMs and your PC only
  • No internet, no home LAN
  • Use for all targets
  • Use for Kali's lab side
NAT
  • VM reaches the internet
  • Nobody can reach the VM
  • Kali updates only
  • Never on vulnerable targets
Bridged
  • VM joins your home LAN
  • Visible to every device
  • Not for this lab
  • Risky with vulnerable VMs

Sizing your host and your VMs

Plan for at least 16 GB of RAM on the host if you want Kali and two targets running together, and a CPU with hardware virtualization (Intel VT-x or AMD-V) turned on in the BIOS or UEFI. Give Kali 2 CPUs and about 4 GB of RAM; small Linux targets often need only 512 MB to 1 GB. Leave 60 GB or more of free disk space, because snapshots grow over time.

On Windows, Hyper-V or other features such as Virtual Machine Platform can make VirtualBox slower, because both want the CPU's virtualization features. On Apple Silicon Macs, use ARM images with UTM or VMware Fusion, because most old vulnerable VMs are x86 and will not run natively.

  • Host: 16 GB RAM or more, VT-x or AMD-V enabled
  • Kali: 2 vCPU, 4 GB RAM
  • Small targets: 512 MB to 1 GB RAM
  • 60 GB or more free disk for VMs and snapshots

Choosing deliberately vulnerable targets

Good beginner targets are Metasploitable 2 (an old Ubuntu server full of vulnerable services, default login msfadmin/msfadmin), DVWA and OWASP Juice Shop for web practice, and machines from VulnHub, a library of downloadable practice VMs. Download only from the official project pages and check the checksum if one is given.

These machines are dangerous by design. Metasploitable's own documentation warns never to expose it to an untrusted network. Turn off shared folders, shared clipboard and drag-and-drop on targets, so nothing on the target can reach your host's files. Treat any VM from the internet as untrusted.

Proving the lab is really isolated

Do not just trust the settings; test them. From each target, try to reach the internet and your home router. Both should fail. From Kali, a host discovery scan of the host-only range should only show your lab VMs and the host adapter at .1.

Also check your PC's side. The VirtualBox host-only adapter (vboxnet0 on Linux, "VirtualBox Host-Only Ethernet Adapter" on Windows) has an address on 192.168.56.0/24. Services you run on your PC that listen on all interfaces are reachable from the lab at 192.168.56.1, so treat that address as out of scope in your lab rules. Repeat the isolation check whenever you add a new VM.

FlowIsolation check for a new target VM
  1. 1
    Adapter settings

    Host-only only, no NAT or bridged

  2. 2
    Ping the internet

    ping -c 2 8.8.8.8 must fail

  3. 3
    Ping home router

    For example 192.168.1.1, must fail

  4. 4
    Scan from Kali

    nmap -sn shows only lab hosts

  5. 5
    Take a snapshot

    Name it clean-isolated

Learn it in 5 short steps

About 1h 10m each. Track them with a timer in your plan.

  1. 1
    Install a hypervisor like VirtualBox~1h 10m
  2. 2
    Install Kali Linux as a VM~1h 10m
  3. 3
    Create a host-only lab network~1h 10m
  4. 4
    Add deliberately vulnerable practice VMs~1h 10m
  5. 5
    Take snapshots before every exercise~1h 10m

Key points

  • Use a host-only network so the lab cannot reach real systems.
  • Kali provides a ready set of testing tools.
  • Use intentionally vulnerable VMs built for practice.
  • Snapshot before each exercise to reset cleanly.

Key terms

Tap a card to flip it. 0/4 known

Examples

Create the lab network and attach VMs from the command line

VBoxManage is VirtualBox's command-line tool. Step 1: create a host-only interface and give it an address (on Linux and Windows hosts). Step 2: attach the target's first adapter to it and remove any NAT. Step 3: give Kali a host-only adapter plus a NAT adapter for updates. Step 4: take a clean snapshot of each VM while it is powered off.

bash
VBoxManage hostonlyif create          # prints the name, e.g. vboxnet0
VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.56.1 --netmask 255.255.255.0

# Target: host-only only
VBoxManage modifyvm "Metasploitable2" --nic1 hostonly --hostonlyadapter1 vboxnet0
VBoxManage modifyvm "Metasploitable2" --nic2 none

# Kali: lab side plus NAT for updates
VBoxManage modifyvm "Kali" --nic1 hostonly --hostonlyadapter1 vboxnet0
VBoxManage modifyvm "Kali" --nic2 nat

VBoxManage snapshot "Metasploitable2" take "clean" --description "fresh import"

Reset a target after a messy exercise

You changed configs on a target while practising and now it behaves oddly. Step 1: power it off; VirtualBox restores snapshots only on a VM that is not running. Step 2: list the snapshots to find the right name. Step 3: restore the clean one and start it headless (without a window). The VM is back exactly as it was, ready for the next exercise.

bash
VBoxManage controlvm "Metasploitable2" poweroff
VBoxManage snapshot "Metasploitable2" list
VBoxManage snapshot "Metasploitable2" restore "clean"
VBoxManage startvm "Metasploitable2" --type headless

Quick reference

  • Targets: host-only adapter only; never bridged, never NAT
  • VirtualBox host-only default: 192.168.56.0/24, host at .1
  • Kali VM images use the login kali / kali; change it after import
  • sudo apt update && sudo apt full-upgrade -y keeps Kali current
  • Disable shared folders, clipboard and drag-and-drop on targets
  • VBoxManage snapshot VM take NAME and VBoxManage snapshot VM restore NAME
  • Test isolation from each target: ping 8.8.8.8 must fail

Common mistakes

  • Bridging the lab to your real network by accident.
  • Forgetting to snapshot before a destructive exercise.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1Which network mode lets lab VMs talk to each other and to your PC, but not to the internet?

Question 2

2Why should a vulnerable target never use a bridged adapter?

Question 3

3Your target VM can ping 8.8.8.8. What does that tell you?

Question 4

4What must you do before restoring a VirtualBox snapshot of a running VM?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Import the official Kali VirtualBox image, log in, change the default password and update the system.

  2. Exercise 2medium

    Add Metasploitable 2 on the host-only network and find its IP from Kali without logging into it.

  3. Exercise 3hard

    Write an isolation test you can run inside any Linux target VM that prints PASS only if it cannot reach the internet or your home router.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Can I install Kali directly on my laptop instead of a VM?
You can, but a VM is safer and easier for a lab: you can snapshot it, run targets next to it and keep your normal OS untouched. Many testers use a VM or WSL for daily work.
Do I need a powerful PC for a hacking lab?
Not very. 16 GB of RAM and a CPU with virtualization support run Kali plus two small targets well. With 8 GB, run one target at a time.
Is it safe to download vulnerable VMs?
Download only from official sources like the Metasploitable, OWASP or VulnHub pages, and keep them on a host-only network. Treat them as untrusted machines that should never touch your real network.
Does VirtualBox work on Apple Silicon Macs?
VirtualBox now has an Apple Silicon version for ARM guests, but x86 practice VMs like Metasploitable 2 still will not run on it natively. Many Mac users run ARM Kali in UTM or VMware Fusion and use hosted platforms for x86 targets.

Go deeper

ShareXLinkedInWhatsApp