Skip to content

Later in this course, you will run programs that are built to be attacked, and you will break the system on purpose. Two questions decide whether that is safe. Who else can reach the VM while it runs? And when something breaks, how do you get the system back exactly as it was?

Your VM already has answers to both, chosen by VirtualBox’s defaults. By the end of this lesson, you can say what the VM can reach in each network mode, check its connection from inside Ubuntu, and undo a change with a snapshot.

  • Creating and installing the VM (B02.3). You need the VM rootvolt-lab with Ubuntu installed and the image removed from its optical drive.
  • About 20 minutes.

The steps were tested with Oracle VirtualBox 7.2.18 on a Windows host, with Ubuntu 24.04.4 LTS in the VM.

In lesson B02.3, the installer was online without any setup: you chose Use wired connection, and it worked. VirtualBox gave the VM a network card and connected it for you.

To see how, power off the VM, select rootvolt-lab in the VirtualBox Manager, and open Settings, then Network. The page has four tabs, Adapter 1 to Adapter 4: each is one virtual network card. Only Adapter 1 is enabled. Its Attached to field sets the network mode, which decides what the card is connected to.

The rootvolt-lab Settings window on the Network page. The Adapter 1 tab is open, Enable Network Adapter is ticked, Attached to is NAT, Adapter Type is Intel PRO/1000 MT Desktop (82540EM), the MAC Address field is covered, Virtual Cable Connected is ticked, and a Port Forwarding button is below it.
The VM’s network settings after the installation. VirtualBox 7.2.18 on Windows, with Ubuntu 24.04.4. The MAC address, a hardware address that identifies the virtual network card, is covered.
  1. The Network page of the VM’s settings.
  2. Adapter 1, the VM’s only enabled network card.
  3. Attached to: NAT, the mode VirtualBox chose when it created the VM.
  4. Port Forwarding, used later in this lesson.

You do not need to change anything here. Close the window with Cancel.

With the VM still powered off, open the settings again and click Attached to to see the list of modes. Look only, then close the window with Cancel.

The Attached to list open on the Adapter 1 tab, with eight entries: NAT, Bridged Adapter, Internal Network, Host-only Adapter, Generic Driver, NAT Network, Cloud Network [EXPERIMENTAL], and Not attached.
The modes in the Attached to list. VirtualBox 7.2.18 on Windows.
  1. NAT, the course default.
  2. Bridged Adapter.
  3. Internal Network.
  4. Host-only Adapter.
  5. NAT Network.

Five modes matter for this course:

  • NAT (Network Address Translation). The manual says a VM with NAT “acts much like a real computer that connects to the Internet through a router”. The router is part of VirtualBox. The VM can go out to the internet, but “the virtual machine is invisible and unreachable from the outside internet”.
  • NAT Network. The same idea, but several VMs share one NAT network and can reach each other. You create it first in VirtualBox’s Network Manager.
  • Bridged Adapter. VirtualBox connects the VM to one of your host’s real network cards. The manual says it then “looks to the host system as though the guest were physically connected to the interface using a network cable”. The VM joins your home network as another device, next to your phone and your laptop.
  • Internal Network. A network “visible to selected virtual machines, but not to applications running on the host or to the outside world”. Only VMs attached to the same internal network, by name, can reach each other.
  • Host-only Adapter. A network of the host and its VMs, “without the need for the host’s physical network interface”. The VMs and the host reach each other, but not the outside world.

Not attached keeps a network card in the VM with no connection, “as if no Ethernet cable was plugged into the card”. Generic Driver and Cloud Network are for special setups that this course does not use.

The manual has an overview table of the five modes. Here it is with the endpoints a home user has: the host, which is your computer; another VM on the same host; and your home network, meaning your router and the other devices on it, plus the internet behind it. “Out” means the VM can start a connection to that endpoint; “In” means the endpoint can start one to the VM.

Mode Host Another VM Home network and internet
NAT Out; In only by port forwarding No Out; In only by port forwarding
NAT Network Out; In only by port forwarding Yes, on the same NAT network Out; In only by port forwarding
Bridged Adapter Out and In Out and In Out and In
Internal Network No Yes, on the same internal network No
Host-only Adapter Out and In Out and In No

Port forwarding is a rule that passes connections arriving at a port on the host to a port in the VM. It is how something outside reaches a NAT VM, one service at a time. Module B14 explains ports.

What a VM can reach in each network mode For each VirtualBox network mode, whether the VM and each endpoint can reach each other, from the manual's overview table. NAT, the course default: the VM reaches the host and the home network and internet, which reach it only through port forwarding; other VMs are not reachable. NAT Network: the same, and VMs on the same NAT network reach each other both ways. Bridged Adapter: the host, other VMs, and the home network and internet, all both ways. Internal Network: only other VMs on the same internal network, both ways; not the host, not the home network or internet. Host-only Adapter: the host and other VMs both ways; not the home network or internet. Mode Host Another VM Home network and internet NAT course default Out only in: forwarded Not reachable Out only in: forwarded NAT Network Out only in: forwarded Both ways Out only in: forwarded Bridged Adapter Both ways Both ways Both ways Internal Network Not reachable Both ways Not reachable Host-only Adapter Both ways Both ways Not reachable
What a VM can reach in each network mode For each VirtualBox network mode, whether the VM and each endpoint can reach each other, from the manual's overview table. NAT, the course default: the VM reaches the host and the home network and internet, which reach it only through port forwarding; other VMs are not reachable. NAT Network: the same, and VMs on the same NAT network reach each other both ways. Bridged Adapter: the host, other VMs, and the home network and internet, all both ways. Internal Network: only other VMs on the same internal network, both ways; not the host, not the home network or internet. Host-only Adapter: the host and other VMs both ways; not the home network or internet. NAT, the course default Host Out only in: forwarded Another VM Not reachable Home network and internet Out only in: forwarded NAT Network Host Out only in: forwarded Another VM Both ways Home network and internet Out only in: forwarded Bridged Adapter Host Both ways Another VM Both ways Home network and internet Both ways Internal Network Host Not reachable Another VM Both ways Home network and internet Not reachable Host-only Adapter Host Both ways Another VM Both ways Home network and internet Not reachable
What a VM can reach in each network mode, from the manual's overview table: Both ways, Out only (in only through port forwarding), or Not reachable.

Read the diagram one row at a time. Only one mode reaches everything both ways: Bridged Adapter. Only two modes cannot reach your home network or the internet at all: Internal Network and Host-only Adapter.

NAT is the course default, and it is what your VM has now. The VM can download updates and software, and nothing on your home network can start a connection to it. The manual adds that NAT keeps VMs apart: “by default virtual machines cannot talk to each other”.

Later security labs run a target VM, a system with weaknesses that you practice finding. A weak system must not be reachable from your home network, and it must not reach your home network either. Those labs use Internal Network, when only the VMs need to reach each other, or Host-only Adapter, when the host must reach them too. Each lab says which one, and why.

Bridged Adapter puts the VM on your real home network as another device. Every device there can try to connect to it, and it can reach every device there. The course does not use it. Use it only on a network you control, never with a target VM.

Start the VM, log in, and open a terminal. Type these three commands, pressing Enter after each:

Terminal window
ip -br address
ip route
ping -c 3 example.com
  • ip -br address lists the VM’s network interfaces and their addresses, in a short table (-br, brief).
  • ip route lists the routes: where the system sends traffic for each destination.
  • ping -c 3 example.com sends three test messages (-c 3, count) to example.com, a website reserved for examples, and waits for each reply.

Module B14 explains these commands in detail. Here, they answer one question: is the VM on the network that NAT promises?

Guess first: your home router has an address on your home network. Will the VM’s route to the internet go through that address?

Run it, then compare with your guess

In the tested VM, the three commands printed:

Screen
learner@rootvolt:~$ ip -br address
lo UNKNOWN 127.0.0.1/8 ::1/128
enp0s3 UP 10.0.2.15/24 2001:db8::1/64 2001:db8::2/64 fe80::2/64
learner@rootvolt:~$ ip route
default via 10.0.2.2 dev enp0s3 proto dhcp src 10.0.2.15 metric 100
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 100
learner@rootvolt:~$ ping -c 3 example.com
PING example.com (203.0.113.10) 56(84) bytes of data.
64 bytes from 203.0.113.10: icmp_seq=1 ttl=64 time=24.7 ms
64 bytes from 203.0.113.10: icmp_seq=2 ttl=64 time=28.7 ms
64 bytes from 203.0.113.10: icmp_seq=3 ttl=64 time=27.2 ms
--- example.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 24.705/26.858/28.695/1.644 ms

No. The route goes through 10.0.2.2, which is not your router. It is VirtualBox’s NAT engine, the router that the manual describes, and VirtualBox passes the traffic on through your host.

Some values in this output were changed before publishing. Every other character is as the tested VM printed it:

  • On the enp0s3 line, the three IPv6 addresses (the longer addresses with colons) are replaced with the example addresses 2001:db8::1/64, 2001:db8::2/64, and fe80::2/64, because part of them is made from the network card’s MAC address. This lesson uses only the IPv4 address before them.
  • In the ping lines, example.com’s real address is replaced with the documentation address 203.0.113.10, on the first line and in each reply line. Your output shows the real one.

lo is the loopback interface: the system’s connection to itself. Its address 127.0.0.1 always means “this computer”. Its state is UNKNOWN, which is normal for loopback; Ubuntu’s own documentation shows the same.

enp0s3 is the VM’s network card, Adapter 1 from the settings. Ubuntu’s documentation says Ethernet cards get “predictable network interface names”, such as enp0s3 here. The state UP means the card is working and connected.

10.0.2.15/24 is the VM’s address. The manual says that with one NAT card, “the guest is assigned to the address 10.0.2.15, the gateway is set to 10.0.2.2 and the name server can be found at 10.0.2.3”. So your VM has the same address as the tested one, and so does every other VirtualBox VM using NAT. The /24 means the first three numbers name the network: 10.0.2.0/24 is every address from 10.0.2.0 to 10.0.2.255. This private network exists only inside VirtualBox, which is why devices on your home network cannot see the VM.

default via 10.0.2.2 is the default route: traffic for any address not covered by another route goes to 10.0.2.2, the gateway. proto dhcp means the VM received this route automatically, from the DHCP server built into VirtualBox. The second route says that addresses in 10.0.2.0/24 are reached directly through enp0s3.

The ping lines. Each 64 bytes from 203.0.113.10 line is one reply from example.com’s address. time=24.7 ms is the round trip in milliseconds; the three replies took between 24.7 and 28.7 ms, and yours will differ. ttl=64 is the reply’s time to live, a limit on how many routers it may pass; you can ignore it here. The summary shows 3 packets transmitted, 3 received, 0% packet loss: the VM reached the internet. The manual notes that VirtualBox’s NAT has limits for some network tools, but “ping should work”.

A snapshot saves the VM’s state so you can return to it later. Lesson B02.1 introduced the idea; now you take one.

The manual describes what a snapshot holds:

  • A copy of the VM’s settings. When you restore the snapshot, “the VM settings are restored as well”.
  • The state of the virtual disks. Restoring means “Files that were since created will disappear, files that were deleted will be restored, changes to files will be reverted.”
  • If the VM was running, also its memory.

A snapshot is not a backup. When you take a snapshot, VirtualBox does not copy the disk. It keeps the disk as it is and writes later changes to a separate file, a differencing image, in a Snapshots folder inside the VM folder. The snapshot needs the original disk file, and both sit in D:\VMs\rootvolt-lab. If that folder is deleted, or the host’s drive fails, the snapshots are gone with it. A backup is a copy kept somewhere else.

Your VM is freshly installed and works. That is the state to keep: if a later lesson goes wrong, you can return to it. The course names it clean-install.

  1. Power off the VM. In Ubuntu, open the menu at the top right and choose Power Off. A snapshot of a running VM also stores its memory, which the manual says “can be as large as the memory size of the VM”, here 4 GB. A snapshot of the powered-off VM has no memory file, and restoring it gives you a powered-off VM.
  2. In the VirtualBox Manager, select rootvolt-lab and click Snapshots. The list holds one item, Current State: “the current point in the lifetime of the virtual machine”.
  3. Click Take in the Snapshots toolbar, or right-click Current State and choose Take.
  4. In the Take Snapshot of Virtual Machine window, set Snapshot Name to clean-install. In Snapshot Description, write what the state is, so you still know in a month.
  5. Click Ok.
The Take Snapshot of Virtual Machine window. Snapshot Name is clean-install, and Snapshot Description is Fresh Ubuntu 24.04 install, before any lessons. The buttons are Ok, Cancel, and Help.
Taking the course’s first snapshot of the powered-off VM. VirtualBox 7.2.18 on Windows, with Ubuntu 24.04.4.
  1. Snapshot Name: clean-install.
  2. Snapshot Description: in the tested VM, Fresh Ubuntu 24.04 install, before any lessons.
  3. Ok takes the snapshot.

The snapshot appears in the list, with Current State below it. The manual explains the order: the current state “is a variation based on the snapshot you took earlier”.

The top left of the Snapshots view of rootvolt-lab: the row of tool tabs with Snapshots selected, and the Name column of the list, showing the snapshot clean-install with Current State (changed) below it.
The Snapshots view with the clean-install snapshot. VirtualBox 7.2.18 on Windows, with Ubuntu 24.04.4.
  1. Snapshots, the view that lists the VM’s snapshots.
  2. The snapshot to keep: clean-install.
  3. Current State: the VM as it is now. In the tested VM, it reads Current State (changed).

To the right of the names, outside this cropped view, the Taken column shows when each snapshot was made; in the tested VM, 11/2/2026 4:20 AM (50 seconds ago).

To test the snapshot, change something you can see, then undo it. Start the VM, log in, open a terminal, and type:

Terminal window
echo "This file should disappear" > ~/snapshot-test.txt
ls ~

echo prints its text, and > sends that text into a file instead of the screen, creating snapshot-test.txt in your home directory, ~. Module B09 explains >. Then ls ~ lists your home directory. In the tested VM:

Screen
learner@rootvolt:~/Desktop$ echo "This file should disappear" > ~/snapshot-test.txt
learner@rootvolt:~/Desktop$ ls ~
Desktop Downloads Pictures snap Templates
Documents Music Public snapshot-test.txt Videos

The file is there, next to the folders Ubuntu created. The prompt shows ~/Desktop because this terminal was opened from the desktop; the commands use ~, so they work the same from any folder. Power off the VM again, from Ubuntu’s menu.

In Snapshots, select clean-install and click Restore in the toolbar. VirtualBox asks for confirmation:

The VirtualBox - Question window. It says: You are about to restore snapshot clean-install. You can create a snapshot of the current state of the virtual machine first by checking the box below; if you do not do this the current state will be permanently lost. Do you wish to proceed? Below is a ticked box, Create a snapshot of the current machine state, and the buttons Restore and Cancel.
The confirmation before a restore, with the box as it first appeared in testing. VirtualBox 7.2.18 on Windows, with Ubuntu 24.04.4.
  1. The snapshot it restores: check that it says clean-install.
  2. Create a snapshot of the current machine state: ticked when the window opened in testing. Untick it.
  3. Restore, after you have checked 1 and 2.

The box offers to save the current state as another snapshot before it is replaced. That is useful when the current state holds work you may want back; the manual says, “To avoid losing the current state when restoring a snapshot, you can create a new snapshot before the restore operation.” Here, the current state holds only the test file, which you want gone. A saved copy of it would be one more snapshot in the list, taking disk space and inviting you to restore the wrong one later. So untick the box, then click Restore.

Guess first: start the VM and run ls ~ again. Is snapshot-test.txt there?

Run it, then compare with your guess

In the tested VM:

Screen
learner@rootvolt:~/Desktop$ ls ~
Desktop Documents Downloads Music Pictures Public snap Templates Videos

The file is gone. The VM’s disk is back to the moment you took clean-install, when the file did not exist yet. With one name fewer, ls fits all the names on one line.

No internet on an Internal Network. You attached the VM to Internal Network, and nothing online works: updates and ping to a website fail. This is the mode working as designed; an internal network has no route to the outside. VirtualBox shows no error for it, so check Settings, Network, Attached to first. For lessons that need the internet, use NAT.

The host cannot reach a service in a NAT guest. You start a service in the VM, and the host cannot connect to it. The manual explains: “network services on the guest are not accessible to the host machine or to other computers on the same network”. The fix is a port forwarding rule, set with the Port Forwarding button on the adapter’s page. Module B14 explains ports and remote connections.

Restoring the wrong snapshot. With several snapshots, you restore an older one by mistake, and newer work disappears. The manual is plain: “The current state of the machine is lost.” Read the name in the confirmation before you click Restore: in testing, it said You are about to restore snapshot clean-install. If the current state holds anything you want to keep, leave Create a snapshot of the current machine state ticked.

The VM folder keeps growing. Each snapshot’s differencing image starts empty, and the manual says, “The longer you use the machine after having created the snapshot, however, the more the differencing image will grow in size.” Snapshots of a running VM add a memory file as well. To free space, select a snapshot you no longer need and click Delete. This “does not affect the state of the virtual machine”, but it “can take a considerable amount of time”.

Snapshots include the settings. A restore also undoes changes to memory, processors, or the network mode made after the snapshot. Try it yourself, below, uses this.

Host-only on a Mac. On macOS hosts, the manual says to choose Host-Only Network instead: “The Host-Only Adapter option is provided for legacy support.”

Snapshots tree. If you restore an older snapshot and take new ones from there, the list becomes a tree with branches. The course keeps one line: clean-install, then the snapshots each lab asks for.

A target VM in a security lab is weak on purpose. On a Bridged Adapter, it is a weak device on your home network, next to your family’s laptops and phones, and a program attacking it can reach them as well. On an Internal Network, the manual says the network is not visible “to applications running on the host or to the outside world”: the target and the attacking VM reach each other and nothing else. That is the setup the security labs use, together with a snapshot taken before each lab, so that whatever the lab changes in the target is removed by one restore.

Goal: Show that a snapshot restores the VM’s settings, not only its files.

  1. Power off the VM. In Snapshots, take a snapshot named before-network-test.
  2. In Settings, Network, set Attached to to Not attached and click OK.
  3. Start the VM, open a terminal, and run ping -c 3 example.com. Then power off.
  4. Restore before-network-test, with Create a snapshot of the current machine state unticked.
  5. Open Settings, Network and read Attached to.
  6. Delete before-network-test: select it in Snapshots and click Delete.

Expected: In step 3, ping fails and prints an error instead of replies. The exact message may differ. In step 5, Attached to is NAT again. After step 6, only clean-install remains.

Hint

The manual says a snapshot holds “a complete copy of the VM settings, including the hardware configuration”. Which settings were in place when you took before-network-test?

Solution

Not attached leaves the network card without a connection, so the VM has no network, and ping fails with an error instead of replies. The exact message may differ. The snapshot was taken while the adapter was attached to NAT, and a restore brings back the settings as well as the disk, so Attached to shows NAT again.

Deleting before-network-test does not change the VM; it only removes the stored snapshot. clean-install stays as your way back to the fresh installation.

  • Attached to, in the VM’s Settings, Network, sets the network mode for each adapter. The course uses NAT: the VM reaches the internet, and nothing outside reaches it without port forwarding.
  • Internal Network and Host-only Adapter keep a VM away from your home network; later security labs use them. Bridged Adapter puts the VM on your home network as another device.
  • In the VM, ip -br address shows enp0s3 UP with 10.0.2.15/24, ip route shows the default route via 10.0.2.2, and ping confirms the internet connection.
  • A snapshot saves the disks and settings so you can return to them; it is not a backup. clean-install is the course’s way back to a fresh system. Restoring it removed snapshot-test.txt.

Next, in Practice: Building Your Lab, you use everything from this module in one task.

All sources were checked on 2 November 2026, for VirtualBox 7.2. The steps were tested with VirtualBox 7.2.18.