Skip to content
Tutorials Center
My learning

Topics

Lesson 4 of 38 ยท Getting Started

Building a Safe Practice Lab

Set up an isolated penetration testing lab with virtual machines, host-only networks, deliberately vulnerable targets and snapshots so you can practice legally and safely.

You learn penetration testing by doing it, and you can only do it legally against systems you own. A home lab solves this: a few virtual machines on your own computer, connected by a private network that cannot reach the internet or your family's devices. In this lesson you plan a lab, understand why isolation matters, and use stand-ins to check that your design is safe. The commands for real virtualization software are read-only here, because the site cannot start virtual machines.

What a lab needs

A minimal lab has three parts.

  1. An attacker machine. A Linux distribution that bundles security tools, such as Kali Linux or Parrot OS, or an ordinary Linux install where you add tools yourself.
  2. One or more targets. Machines that are meant to be attacked. They are deliberately vulnerable or simply old, unpatched systems that you built.
  3. A private network. A virtual switch connecting them, isolated from everything else.

Lab building blocks

Host computer 16 GB RAM is comfortable.
Hypervisor VirtualBox, VMware or KVM.
Attacker VM Kali, Parrot or plain Linux.
Target VMs Vulnerable by design.

Everything stays on one private virtual network.

1 / 2

Hardware and software

You do not need a data center. A laptop with 16 GB of RAM, a modern multi-core CPU and 100 GB of free disk runs an attacker VM and two or three small targets. With 8 GB you can run one target at a time. Virtualization must be enabled in the firmware settings of the computer.

Common hypervisors are VirtualBox (free), VMware Workstation or Fusion, and KVM on Linux. Cloud labs exist too, but check the provider's policy before you attack anything, even your own virtual machines, because traffic can cross shared infrastructure.

Network design: isolation first

The most important decision is the network type. Hypervisors usually offer these modes:

Mode Can VMs reach the internet? Can VMs reach each other? Use for
NAT Yes No (each is separate) Updating a single VM
Bridged Yes, with a real address on your LAN Yes Avoid for vulnerable targets
Host-only No Yes, and with the host Attack practice
Internal network No Yes, but not the host Strongest isolation

Put vulnerable targets only on host-only or internal networks. A deliberately vulnerable machine on a bridged adapter is exposed to everyone on your home network and possibly to the internet if your router forwards ports. Many real compromises of lab machines happen this way.

A sensible layout gives the attacker VM two adapters: a NAT adapter for updating tools, which you disable while attacking, and a host-only adapter that connects it to the targets.

flowchart LR
    subgraph HOST["Your computer"]
        A["Attacker VM"]
        T1["Target VM 1"]
        T2["Target VM 2"]
        S(("Host-only switch<br/>10.10.10.0/24"))
        A --- S
        T1 --- S
        T2 --- S
    end
    A -. "NAT adapter, off during practice" .-> NET["Internet"]

The targets have no route to the internet. The attacker's NAT adapter is only for updates.

Targets to practice on

Use systems that exist to be attacked, or that you built yourself:

  • Intentionally vulnerable web applications you run locally, such as OWASP Juice Shop, DVWA or WebGoat.
  • Vulnerable virtual machines published for training, such as Metasploitable.
  • Capture-the-flag (CTF) platforms and hosted labs that give you permission by design. Read each platform's rules.
  • Your own builds: install an old Windows or Linux version, add services, then attack and harden them.

Always download images from the official project page and verify the checksum, because a "vulnerable VM" from an unknown source could itself be malicious.

Snapshots: your undo button

Before each exercise, take a snapshot of every target. After you break the machine you restore it in seconds. Snapshot the attacker VM after installing your tools so a bad update never ruins your setup. Name snapshots clearly, for example clean-install and tools-installed.

Read-only: example hypervisor commands

These commands use VirtualBox's VBoxManage tool. They are shown for reference only.

Terminal
# create a host-only network and attach a VM to it (example)
VBoxManage hostonlyif create
VBoxManage modifyvm "target1" --nic1 hostonly --hostonlyadapter1 vboxnet0
VBoxManage snapshot "target1" take "clean-install"
TEXT
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interface 'vboxnet0' was successfully created
Snapshot taken. UUID: 3f2a0c1e-0000-0000-0000-000000000000

The output above is an example of the format, not a recording of a real run.

Stand-in: validate your lab plan

Write your design as data, and let a script verify the safety rules. The first example flags any target VM that has a bridged or NAT adapter.

Python Check the lab for unsafe adapters

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The second example estimates whether your computer can run the planned machines at the same time, using invented RAM figures per VM.

Python Will my lab fit in memory?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Habits that keep a lab safe

  • Disable the attacker's internet adapter while you practice.
  • Never expose a lab target with port forwarding.
  • Keep notes on each exercise: start state, steps, result. See Note-Taking and Evidence.
  • Update the attacker VM regularly; do not update deliberately vulnerable targets (that would fix what you want to practice).
  • Never bring tools or techniques learned in the lab to systems you do not own.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which network mode is the safest home for a deliberately vulnerable VM?

    Host-only and internal networks keep the vulnerable machine away from the internet and the rest of your LAN.
  2. 2. Why take snapshots before each exercise?

    Exploiting a machine often changes or breaks it. A snapshot lets you restart from a clean state.
  3. 3. Where should you download a vulnerable training VM?

    An unofficial image may contain real malware. Verify source and checksum.
  4. 4. What is the purpose of the NAT adapter on the attacker VM in the example layout?

    It gives temporary internet access for updates and is disabled while you practice.

Summary

  • A lab is an attacker VM, vulnerable targets and a private virtual network on hardware you own.
  • Use host-only or internal networks for targets; avoid bridged mode for anything vulnerable.
  • Practice on intentionally vulnerable applications, training VMs and CTF platforms with explicit permission.
  • Snapshots let you reset targets; verify downloads with official sources and checksums.
  • The hypervisor commands here are read-only examples, while the Python checks are runnable stand-ins.

Next: Attacker Mindset and Core Terminology