« prev :: next »


Disconnect from the hal9k-wifi and reconnect to your normal network, where you can reach the hal9k host. We’re now going to set up VirtualBox so that it automatically launches a specific VM – the OPNsense router – when the system boots. Without this, we’ll have no way to get everything booted without either a secondary network or a mouse, keyboard and monitor.

Go ahead and SSH into hal9k.

We need to modify the /etc/default/virtualbox file again. You’ll have to use sudo to gain permissions to modify the file. Add the following lines:

VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg

Then add the following to the /etc/vbox/autostart.cfg file:

default_policy = deny
# Create an entry for each user allowed to use autostart
vbox = {
    allow = true
}

Next, we take a few more steps to get everything just right:

sudo chgrp vboxusers /etc/vbox
sudo chmod 1775 /etc/vbox

Then su into the vbox account, and do the following:

vboxmanage setproperty autostartdbpath /etc/vbox
vboxmanage list vms

Get the UUID of the OPNsense VM. Then execute the following, replacing [UUID] with the UUID of the VM:

VBoxManage modifyvm [UUID] --autostart-enabled on

Let’s also tell the system how to auto-halt the VM on system shutdown:

VBoxManage modifyvm [UUID] --autostop-type acpishutdown

For example:

vbox@hal9k-0vermind:~$ vboxmanage setproperty autostartdbpath /etc/vbox
vbox@hal9k-0vermind:~$ vboxmanage list vms
"OPNsense 20.1 x64 (CORE ROUTER)" {aea0b12d-e13b-4783-90d0-89a0e462752a}
"Vulnerable Webservice Demo" {555959a1-baba-4d99-a3c5-b4a84a5b6ac7}
vbox@hal9k-0vermind:~$ vboxmanage modifyvm aea0b12d-e13b-4783-90d0-89a0e462752a --autostart-enabled on
vbox@hal9k-0vermind:~$ vboxmanage modifyvm aea0b12d-e13b-4783-90d0-89a0e462752a --autostop-type acpishutdown

Finally, exit the vbox user, return to haxys and run:

sudo service vboxautostart-service restart

Next, reboot the system. If everything goes well, the OPNsense will start automatically on the next boot. Check on the status of the OPNsense VM after the system boots; it should be running. Connect to hal9k-wifi.

Now, if you take this system on the road and you don’t have a mouse/keyboard/monitor/internet connection, you can still boot up the machine, connect to hal9k-wifi, and be within the lab network.

If you need access to the hal9k host within the lab network, just hook up enp0s25 to the switch (or directly to enp2s0f1) and it’ll get an IP and join the network.

At this point, I’ll go ahead and make a system snapshot in timeshift. Call it “Lab Setup Complete.” From here out, any changes we make will be primarily to the VMs themselves. Our core lab setup is complete!


« prev :: next »