OPNsense

Home›Blog›Virtual Machines›Install OPNsense in VirtualBox or VMware for a Home Lab

Install OPNsense in VirtualBox or VMware for a Home Lab

Category: Virtual Machines · Updated 2026-11-19 · Applies to OPNsense 26.7

Illustration of a laptop running an isolated virtual firewall lab

You do not need spare hardware or a server to learn OPNsense. VirtualBox and VMware Workstation, running on the computer already on your desk, can host a complete little firewall lab: one OPNsense VM acting as the firewall, and one ordinary VM sitting behind it as a client. The trick is not the install, which follows the same DVD ISO process as anywhere else. The trick is the network design. A lab firewall wired carelessly can hand out addresses on your real home network or route your household traffic through a half-configured VM. This guide designs the lab so that cannot happen, then walks through the setup for both hypervisors.

The safety principle: your lab must not touch your real LAN

A firewall has two sides, and the danger lives on both of them. On the LAN side, OPNsense runs a DHCP server by default. If that LAN side is accidentally connected to your home network (for example through a bridged adapter), your real devices may start taking addresses and a default gateway from the lab VM, and parts of your network will quietly break or route through the lab. On the WAN side, a bridged connection makes the lab firewall a real participant on your home network, competing with your actual router.

The safe pattern avoids bridged adapters entirely:

OPNsense interfaceAdapter typeWhat it connects to
WANNATThe host's own network connection, outbound only. OPNsense gets internet access through the hypervisor's NAT, and nothing on your real LAN can reach in.
LANHost-only or internal networkA private virtual network containing only the OPNsense VM and your lab client VMs. It has no path to your real LAN.

With this design, the worst a misconfiguration can do is confuse the lab itself. Your household network never sees the lab's DHCP server, and the lab never depends on your real router's address range. Keep this rule absolute for desktop hypervisors: no bridged adapters on a lab firewall, at least until you can explain exactly why a specific exception is safe.

Planning the lab

  • One OPNsense VM: 2 virtual network adapters (NAT first, host-only/internal second), at least 3 GB of RAM and an 8 GB virtual disk, following the official VM minimums described in OPNsense Virtual Machine Requirements and Sizing.
  • One client VM: any lightweight desktop operating system you already use, with a single adapter on the same host-only or internal network as the OPNsense LAN.
  • The OPNsense DVD ISO image, decompressed and ready to attach. (Why the DVD image? See VGA vs DVD vs Serial vs Nano.)
  • An address plan that does not collide with your home network. OPNsense defaults its LAN to 192.168.1.1/24; if your home network uses the same range, change the lab LAN to something clearly different. Avoid 192.168.56.0/24, because VirtualBox host-only networks traditionally live there; pick a range like 10.10.10.0/24 that clashes with nothing you own.

A note on the hypervisor's own defaults: in VirtualBox, host-only networks come with their own DHCP service from the hypervisor. Disable DHCP on the host-only network you use for the lab LAN, because OPNsense is supposed to be the DHCP server there, and two DHCP servers on one segment is the lab equivalent of the leak you are trying to avoid. In VMware Workstation, custom VMnet networks have a similar optional DHCP service; turn it off for the lab LAN network for the same reason.

VirtualBox: creating the firewall VM

Create a new VM and set its type to BSD / FreeBSD (64-bit) so VirtualBox picks sensible defaults. Give it the memory and disk from the plan above, and attach the DVD ISO to its virtual optical drive. Before starting it, open the network settings and configure two adapters:

  • Adapter 1: enabled, attached to NAT. This will be the WAN side.
  • Adapter 2: enabled, attached to Host-only Adapter (or Internal Network if you never need the host itself to reach the lab), using the host-only network whose DHCP you disabled.

Create the client VM the same way, with a single adapter attached to that same host-only network. Note the order of the OPNsense adapters: the first adapter the guest sees tends to be listed first during interface assignment, but you will confirm identities by MAC address during setup, so write both MAC addresses down from the VM settings.

VMware Workstation: creating the firewall VM

The VMware path mirrors the same design. Create a custom VM, choose a FreeBSD 64-bit guest type if offered, give it the planned memory and disk, and attach the DVD ISO. Then give it two network adapters:

  • Adapter 1: NAT (VMnet8 by default in Workstation). This is the WAN side.
  • Adapter 2: a custom VMnet with no connection to the host's physical network and its built-in DHCP service switched off in the Virtual Network Editor. This is the LAN side. Attach the client VM to the same VMnet.

One VMware-specific, officially documented point: the OPNsense VM guide advises VMware users to use VMXNET3 network adapters and to install the os-vmware plugin in OPNsense afterwards, which provides VMware tools integration for the guest. VMXNET3 is VMware's paravirtualised adapter and is the right default there, unlike the generic emulated options. Install the plugin from System → Firmware → Plugins once the firewall is up, the same way you would install any other plugin.

Installing OPNsense in the lab

Start the firewall VM and let it boot from the DVD ISO into the live environment. Log in as installer with the password opnsense to start the installer, then work through the same choices as any install: keymap, install to the virtual disk (ZFS is generally the recommended option and fits comfortably here; skip the swap file on small disks, as the official guide advises for targets under 16 GB), accept the warning that the disk will be overwritten, set a root password when asked, complete the installation and reboot, detaching the ISO so the VM boots from its disk.

On the first boot from disk, OPNsense asks you to assign interfaces. Remember the rule: the first interface you assign becomes LAN, the second becomes WAN. This is the one step where lab builders trip, because the adapter you configured first in the hypervisor (NAT, intended as WAN) is not necessarily the one you should assign first. Slow down, match the interfaces to the MAC addresses you wrote down, assign the host-only/internal adapter as LAN and the NAT adapter as WAN, and skip VLAN setup. Afterwards, use console option 2) Set interface(s) IP address to move the LAN to your planned lab range if it differs from the 192.168.1.1/24 default.

How to confirm the lab is both working and sealed

  • Start the client VM. It receives an address by DHCP from OPNsense in your lab range, with OPNsense's LAN address as its gateway.
  • From the client, open the OPNsense web GUI at the lab LAN address and log in with root and the password you set.
  • From the client, browse the web: traffic should flow out through the NAT adapter, proving the WAN side works.
  • From a real device on your home network (your phone, for example), confirm you cannot reach the lab LAN address, and that your home devices still show your real router as their gateway. This is the leak test, and it must pass.
  • Reboot the OPNsense VM and confirm the client still works afterwards, proving the configuration is installed on disk and not just running from the ISO.

Host resources and what performance to expect

Desktop hypervisors share one machine with everything else you are doing, so calibrate your expectations. The lab firewall gets CPU time alongside your browser, your editor and whatever else is open, and its virtual network cards are software constructs whose throughput depends on the host's spare capacity. For learning the interface, testing rules and rehearsing procedures, none of that matters: the GUI feels the same at lab speeds as it does in production. For judging real-world throughput, VPN performance or IPS overhead, it matters a great deal, and numbers measured in a desktop lab should never be quoted as what OPNsense would do on a server or on bare metal. Treat the lab as a flight simulator: perfect for learning the controls and practising emergencies, not a measurement of the aircraft.

Practically, give the host some slack. If your computer has limited RAM, close heavy applications before a long lab session, and do not run the firewall and client VMs plus a third heavy VM at once and then blame OPNsense for the sluggishness. Within those limits, a modern laptop or desktop runs this two-VM lab comfortably.

Putting the lab to work: three exercises worth doing

A lab earns its disk space when you use it to rehearse the things that are stressful to do live. These three exercises cover the skills you will actually need:

  • Break and restore the configuration. Download a configuration backup (System → Configuration → Backups), then deliberately make a mess: change the LAN address, add bad rules, reassign interfaces. Restore the backup and watch the lab return to health. On a real firewall this procedure is your safety net; in the lab you can learn it without an audience.
  • Rehearse an update. Snapshot the VM, run a firmware update from System → Firmware, and observe what reboots when and how long the firewall is away. If anything surprises you, roll the snapshot back and read the release notes properly. This is exactly the routine you will later perform on a production firewall, minus the pressure.
  • Build a second segment. Add a third adapter to the OPNsense VM on a second internal network, assign it as an OPT interface, give it its own subnet and rules, and put a second client VM on it. You now have a miniature version of the classic LAN-plus-guest-network design, and you can test inter-network rules where a mistake costs nothing.

One honest limitation to keep in mind while experimenting: desktop hypervisors are not ideal for VLAN-heavy designs, because tagged traffic inside host-only and internal networks behaves differently from a real switch trunk. Learn the OPNsense side of VLAN configuration in the lab, but expect the switching details to change when you move to real hardware or Proxmox.

Common lab mistakes

MistakeWhat happensThe fix
Bridged adapter on the LAN sideThe lab's DHCP server answers real devices on your home network; chaos followsChange the adapter to host-only or internal networking immediately; this is the leak the design exists to prevent.
Hypervisor DHCP left on for the lab LAN networkClients get addresses from VirtualBox or VMware instead of OPNsense, or from both in turnDisable DHCP on that host-only or VMnet network; OPNsense is the only DHCP server there.
WAN and LAN assigned the wrong way roundThe GUI is unreachable from the client, or the firewall routes backwardsUse console option 1) Assign interfaces and match MAC addresses to the adapters you configured.
Lab LAN range identical to the home LAN rangeRouting confusion: the client cannot tell lab from home, and NAT hides the problem intermittentlyChange the lab LAN to a distinct private range with console option 2).
Testing from the host instead of the client VMResults reflect the host's special position on host-only networks, not a real client's viewAlways judge the lab from inside the client VM.

What a desktop lab is good for, and what it is not

This setup is ideal for learning the web GUI without consequences, rehearsing changes (a VLAN design, a VPN configuration, a rules reorganisation) before applying them to a real firewall, testing updates, and breaking things on purpose to see how recovery works. Snapshots make it even better: snapshot the firewall VM before an experiment and roll back in seconds when it goes wrong.

It is not a way to protect your home. Performance is limited by your desktop, the firewall only exists while your computer is awake, and NAT-on-NAT hides the lab behind two layers of translation that real deployments do not have. When you outgrow the lab, the natural next step is the same firewall on a hypervisor that runs full time: installing OPNsense on Proxmox VE. The official background for virtual installs is the OPNsense virtual machines documentation.

Keep going in Virtual Machines