| Tested on | Windows 11; Ubuntu 24.04 (VirtualBox 7.x host screenshots) |
|---|---|
| Package | Oracle VirtualBox 7.xMetasploitable 2DVWA 1.0.7 VulnHub ISO |
| Applies to | Windows Linux macOS |
| Privilege | Host administrator rights to install VirtualBox; sudo on Kali for package installs |
| Scope | Lab component overview, install order, host-only topology, adapter layout, and snapshots. Links to dedicated Kali and DVWA install guides. Does not cover exploitation walkthroughs on the targets. |
A penetration testing lab gives you legal, isolated targets for ethical hacking practice. This guide builds a three-VM layout on Oracle VirtualBox: Kali Linux as the attacker, Metasploitable 2 for network targets, and DVWA for web application testing.
Lab VMs and packages
This lab is a small, repeatable stack — not every tool you will ever use in a career, but enough surface area to practice recon, network exploitation, web attacks, and Metasploit workflows without touching a production network. Below is what we install, what role each piece plays, and where it fits in the ethical hacking course.
| Component | What it is | Why we use it in this lab |
|---|---|---|
| Oracle VirtualBox | Free desktop hypervisor on your Windows, Linux, or macOS host | Runs multiple VMs on one physical machine, supports snapshots for reset between exercises, and ships host-only networking for isolation without extra hardware |
| VirtualBox Extension Pack | Optional add-on matched to your VirtualBox version | Enables USB 2/3 passthrough and fuller host-only adapter support on some hosts |
| Host-only virtual network | Private VirtualBox subnet shared only by your lab VMs | Keeps exploit traffic, malware samples, and ARP/DNS lab tricks off your home LAN and the Internet |
| Kali NAT adapter (second NIC) | Outbound Internet path for the attacker VM only | Lets Kali run apt update, pull Metasploit modules, and download wordlists while Metasploitable and DVWA stay on host-only with no direct route to the Internet |
Install order for this guide
Follow these steps in order. Each step links to a dedicated guide where the full Kali or DVWA install is already documented with screenshots.
| Step | Task | Section |
|---|---|---|
| 1 | Install VirtualBox on your host | Step 1 |
| 2 | Install the VirtualBox Extension Pack | Step 2 |
| 3 | Create the host-only lab network | Step 3 |
| 4 | Install Kali and attach lab adapters | Step 4 |
| 5 | Install DVWA (web target) | Step 5 |
| 6 | Install Metasploitable 2 (network target) | Step 6 |
| 7 | Verify connectivity and take snapshots | Step 7 |
Do not skip ahead — Metasploitable and DVWA need the host-only network from Step 3, and verification in Step 7 assumes Kali is already on that subnet.
What we did not include (and why)
| Not in the base lab | Reason |
|---|---|
| Cloud lab (AWS/Azure) | Valid for scale, but adds cost and networking complexity; local VirtualBox is free and matches our screenshot-based walkthroughs |
| Physical spare PCs | Best for Wi-Fi and hardware attacks; this guide focuses on a laptop-friendly virtual lab first |
After the base lab is running, extend it from the optional targets section at the end of this page.
Lab topology
| Role | VM | Adapters |
|---|---|---|
| Attacker | Kali Linux | Host-only + NAT |
| Network target | Metasploitable 2 | Host-only |
| Web target | DVWA (guest VM or on Kali) | Host-only |
VirtualBox often assigns 192.168.56.0/24 on the default host-only adapter. Refreshed walkthroughs on this site use TARGET = 192.168.56.114 and KALI_IP = 192.168.56.115 on that subnet when your lab matches the default range. Substitute your own addresses from ip addr on each VM.
Metasploitable 2 console: msfadmin / msfadmin
Take a snapshot of each target VM after install and before your first exploit.
Here is the topology for this lab — Kali on host-only with targets DVWA and Metasploitable on the same segment:
Virtualization keeps vulnerable services off your physical network. Malware analysis, ARP spoofing, and Metasploit payloads can disrupt real systems if they leak onto a production LAN. The host-only network in Step 3 limits impact to VMs on that adapter.
Step-by-step lab build
Work through Steps 1–7 in order. Screenshots below were captured on VirtualBox 7.x with a Windows host; menu names may differ slightly on Linux or macOS hosts.
Step 1: Install VirtualBox on the host
- Open the Oracle VirtualBox downloads page.
- Download the installer for your host OS (Windows, macOS, or Linux).
- Run the installer and accept the defaults on Windows, or follow install Oracle VirtualBox on Linux on RHEL-family hosts.
- Confirm VirtualBox opens without errors before you continue to Step 2.
Step 2: Install the VirtualBox Extension Pack
- On the same VirtualBox downloads page, download the Extension Pack that matches your VirtualBox version.
- Double-click the Extension Pack file or install it from Tools → Extension Pack Manager in VirtualBox.
- Accept the license prompt.
Step 3: Create the host-only network
This private subnet keeps lab VMs isolated from your home LAN.
- In VirtualBox, open File → Tools → Network.
- Select Host-only Networks on the right panel.
- Open the default VirtualBox Host-Only Ethernet Adapter and set the Adapter tab values to match your lab plan (default
192.168.56.1/255.255.255.0works with most refreshed course walkthroughs).
- Switch to the DHCP Server tab and enable DHCP or note the assigned range.
- Click Apply and confirm the adapter appears under Host-only Networks.
Step 4: Install Kali Linux and attach lab network adapters
Part A — Install Kali
- Follow Install Kali Linux on VirtualBox from start to finish (bare-metal ISO or pre-built VirtualBox image).
- Confirm the Kali VM boots to a login prompt before you change network settings.
Part B — Wire Kali into this lab topology
- Select the Kali VM → Settings → Network.
- Set Adapter 1: Enabled, Host-only Adapter (the network from Step 3).
- Set Adapter 2: Enabled, NAT (Internet for
aptandmsfupdate).
- Optional: on Adapter 2, add NAT port forwarding if you want SSH from the host without bridging lab traffic.
- Start Kali and log in with the credentials from the Kali download page (often
kali/kali).
- On Kali, run
ip -4 addr showand confirm the host-only interface received an address on your lab subnet.
Step 5: Install DVWA (web target)
Pick one path below.
Option A — DVWA as a separate guest VM (VulnHub ISO)
- Download DVWA 1.0.7 from VulnHub.
- In VirtualBox, click Machine → New and name the VM.
- Allocate 2 GB RAM and 1 vCPU.
- Create a 10 GB dynamically allocated virtual disk.
- Open Settings → Network → Adapter 1: Host-only Adapter (same network as Kali).
- Mount the DVWA ISO, start the VM, and boot the installer.
- At the boot menu, choose start the installer directly.
- Complete installation until the console shows DVWA running.
- From Kali, browse to
http://DVWA_IP/after you read the address withip addron the DVWA guest.
Option B — DVWA on Kali (single-machine web lab)
- Follow Install DVWA on Kali Linux.
- Keep DVWA on localhost or the host-only interface only — do not expose it on a bridged adapter.
- Continue with DVWA SQL injection after the setup wizard completes.
Step 6: Install Metasploitable 2
- Download
metasploitable-linux-2.0.0.zipfrom SourceForge. - Extract the archive to a folder on your host.
- In VirtualBox, click Machine → New → Expert Mode.
- Assign 2 GB RAM (512 MB minimum).
- Attach the extracted VMDK as the virtual hard disk. The VM name must match the extracted folder name.
If you are building an empty VM instead of attaching the VMDK directly, add an 8 GB dynamic VDI under Settings → Storage:
- Open Settings → Network → Adapter 1: Host-only Adapter (same network as Kali). Do not use bridged networking for this lab.
- Start the VM.
- Log in with msfadmin / msfadmin.
- From Kali, open
http://TARGET/in a browser to reach the Metasploitable web menu (after you identifyTARGETwithip addron the Metasploitable console or a subnet scan).
Continue exploitation in Learn hacking with Metasploitable 2.
Step 7: Verify the lab and snapshot each VM
- On Kali, ping Metasploitable (substitute your target address):
ping -c 2 TARGET- Optional: sweep the host-only subnet to list all lab guests:
nmap -sn 192.168.56.0/24- Run spot checks from Kali:
| Check | Command | Expected |
|---|---|---|
| Metasploitable SSH | nmap -p 22 --open TARGET |
Port 22 open |
| Metasploitable web | curl -I http://TARGET/ |
HTTP response |
| DVWA | curl -I http://DVWA_IP/ |
HTTP 200 or redirect to setup |
- In VirtualBox, snapshot Kali, Metasploitable, and DVWA (or note the snapshot name if you use Kali-only DVWA). Restore these snapshots between exercises so each service starts from a known state.
Optional targets
Add more vulnerable apps on the same host-only network as you advance:
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
| Kali cannot ping Metasploitable | Different networks | Match host-only adapter on all lab VMs |
| No Internet on Kali | NAT adapter missing | Enable Adapter 2 NAT on Kali only |
| Wrong IP range | Custom host-only subnet | Run ip -4 addr on each VM; update TARGET / KALI_IP in walkthroughs |
| Metasploitable VM fails to boot | VM name ≠ folder name | Rename VM or re-link VMDK in Settings → Storage |
Summary
You now have a standard ethical hacking lab: Kali on host-only + NAT, Metasploitable 2 and DVWA on host-only only, and snapshots for reset between exercises. Next steps:
- Metasploit tutorial —
msfconsolebasics - Learn hacking with Metasploitable 2 — exploits against the network target
- DNS enumeration or banner grabbing — recon on Metasploitable services
Keep every scan and exploit inside this isolated network.

