Skip to main content
Virtualization, Hypervisors & Safe Labs
Lesson 5 of 10

Virtualization, Hypervisors & Safe Labs

Build isolated virtual machines with VirtualBox or QEMU, choose safe NAT or Host-Only networking, and use snapshots to reset lab states cleanly.

Beginner 25 min IT foundations

Learning objectives

  • Explain how a hypervisor isolates guest operating systems from the host hardware
  • Distinguish Type 1 and Type 2 hypervisors and match them to common lab tools
  • Select NAT, NAT Network, Host-Only, or Bridged networking based on lab safety needs
  • Create and restore VM snapshots cleanly without exposing vulnerable targets to a LAN

Recommended first: Operating Systems, Kernels & ProcessesCommand Line & Shell Workflow

#Why this matters

Cybersecurity practice often requires running deliberately vulnerable web servers, testing risky configuration changes, or inspecting unfamiliar binaries. Running those experiments directly on your primary operating system risks damaging personal files, corrupting system services, or exposing weak services to everyone on campus Wi-Fi.

Virtualization solves this by wrapping each test system inside a virtual machine (VM) whose virtual disk is just a file on your host filesystem and whose virtual network card connects only where you allow.

#How hypervisors isolate guests

Earlier lessons explained how a single OS kernel manages CPU time and RAM for processes. A hypervisor (virtual machine monitor) adds a layer that lets multiple independent guest OS kernels run safely on one physical computer. Using hardware virtualization extensions such as Intel VT-x or AMD-V, the CPU enforces memory and privilege boundaries so a crash inside a guest stays inside that guest.

  1. 4Guest applicationsWeb target, scanner, shell tools
  2. 3Guest OS kernelLinux or Windows inside the VM
  3. 2HypervisorVirtualBox, QEMU/KVM
  4. 1Host hardware / Host OSPhysical CPU, RAM, storage, NIC

Hypervisors fall into two main categories:

  • Type 1 (bare-metal): runs directly on hardware or inside the host kernel itself, such as Linux KVM, VMware ESXi, or Microsoft Hyper-V. Datacenters and cloud providers favour Type 1 for efficiency.
  • Type 2 (hosted): runs as a regular program inside your desktop OS, such as Oracle VirtualBox or QEMU in user-space emulation mode (note that on Linux, QEMU commonly pairs with KVM to gain Type 1 hardware acceleration).

#Choosing safe virtual networking modes

Networking is the single most critical safety choice in a security lab. Putting an unpatched target VM directly onto a shared campus or coffee-shop network invites automated scans and violates acceptable-use policies.

Mode Guest reaches internet External LAN reaches guest Best lab use
NAT Yes (via host) No Downloading OS updates on one VM
NAT Network Yes (via virtual router) No Multi-VM lab needing updates
Host-Only No Host only (private subnet) Attacker and target VMs talking safely
Internal No No (VMs only) Fully isolated multi-VM malware/target tests
Bridged Yes (direct LAN IP) Yes (exposed on physical LAN) Avoid for vulnerable labs on shared Wi-Fi

For a typical two-VM practice range, place both your attacker VM and your vulnerable target VM on a Host-Only or Internal network (such as 10.10.10.0/24 or VirtualBox's default 192.168.56.0/24). Neither VM is reachable from the physical Wi-Fi network.

  1. Attacker VM (10.10.10.10)Virtual Host-Only Switch | Vulnerable Target VM (10.10.10.20)

#Snapshots, disk images, and clean resets

Virtual disks are stored as files on the host, such as .vdi in VirtualBox or .qcow2 in QEMU. When you take a snapshot, the hypervisor freezes the base virtual disk as read-only and writes every subsequent change to a separate differencing file. If a lab experiment breaks system configs or leaves messy artifacts behind, restoring the snapshot discards the differencing layer and returns the VM to its exact clean state in seconds.

You can manage snapshots and verify network modes directly from the command line:

Managing snapshots and checking NIC mode with VirtualBox and QEMU
$ VBoxManage snapshot "ubuntu-target" take "clean-base"
$ VBoxManage showvminfo "ubuntu-target" | grep "NIC 1"
NIC 1:           MAC: 080027112233, Attachment: Host-only Interface 'vboxnet0', Cable connected: on
$ VBoxManage snapshot "ubuntu-target" restore "clean-base"
$ qemu-img create -f qcow2 lab-disk.qcow2 20G
$ qemu-img snapshot -c clean-base lab-disk.qcow2
$ qemu-img snapshot -l lab-disk.qcow2

#Defending and common mistakes

  • Using Bridged mode for vulnerable VMs: anyone on the same Wi-Fi or office VLAN can scan and exploit your target VM. Always verify adapter settings before powering on.
  • Leaving Shared Folders and Shared Clipboard enabled: bidirectional clipboard or host folder mounts give a compromised guest a direct path to read or modify host files. Disable them for untrusted targets.
  • Treating snapshots as backups: snapshots depend on an intact chain back to the base disk image. If the host drive fails or the base file is altered, every snapshot breaks; export full appliances or copy base images for backups.
  • Leaving NAT enabled during untrusted binary tests: outbound NAT lets suspicious programs phone home or download second-stage files. Disconnect the virtual cable or switch to an Internal network before detonate tests.

#Summary

  • A hypervisor allocates virtual CPU, memory, storage, and networking to keep guest operating systems isolated from the host.
  • Choose Host-Only or Internal networks for vulnerable targets and avoid Bridged mode on shared LANs.
  • Take a clean-base snapshot before testing so you can roll back broken configs or messy changes reliably.
  • Disable shared folders, shared clipboards, and unnecessary outbound NAT when working with untrusted files.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge