How to Install Opnsense on Virtualbox?
In this tutorial, we are going to explain how to install OPNsense on the VirtualBox environment. Before we jump on the how-to tasks let’s understand what Virtualbox is and what is OPNSense.
VirtualBox is a robust x86 and AMD64/Intel64 virtualization solution that can be used in both the office and at home. VirtualBox is not only a feature-rich, high-performance product for enterprise customers; it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License (GPL) version
VirtualBox is currently available for Windows, Linux, Macintosh, and Solaris hosts, and it supports a wide range of guest operating systems, including but not limited to Windows.
VirtualBox is continuously developed, with frequent releases, and it has an ever-expanding list of features, supported guest operating systems, and platforms.
After giving an overview of Virtualbox let's define the OPNsense.
OPNsense is an open-source, easy-to-use, and easy-to-build firewall and routing platform built on HardenedBSD. OPNsense has almost all of the functions found in pricey commercial firewalls, and in many cases, even more. It combines the benefits of open and verifiable sources with the comprehensive feature set of commercial products.
In 2014, OPNsense was born as a fork of pfSense® and m0n0wall, with the first official release in January 2015. The project has progressed swiftly while still preserving m0n0wall and pfSense characteristics. The project's development is driven by a strong focus on security and code quality.
OPNsense provides weekly security upgrades in tiny increments in order to respond to new emerging threats in a timely manner. Businesses may plan updates ahead of time thanks to a defined release cadence of two major releases per year. A roadmap is created for each major release to guide development and establish clear objectives.
In three basic steps, you can install OPNsense on VirtualBox.
1. The first one is downloading the OPNsense installer file
2. The second step is to configure VirtualBox Settings
3. The third step is to configure OPNsense Settings
1.Download OPNsense
We are going to start with downloading the OPNsense installer from OPNsense.org
Figure 1. OPNsense download page
- System Architecture is only available for amd64
- We will boot on Virtualbox then select the image type as DVD
- Select the Mirror Location as geographically close to you
After selection of 3 required fields, you can start to download by clicking on the Download
When the downloading task is finished you need to extract the iso file to a preferred path on your computer.
Now you have an OPNsense iso file to boot on Virtualbox. We assume that you have Virtualbox on your computer. Let's start to install our OPNsense as a VM instance.
2.Virtual Box Settings
You may follow the next step to complete the Virtual Box settings.
1. Create an OPNsense VM instance.
On VirtualBox, you can create a new VM instance by clicking on the New or by using the CRTL+N shortcut.
Figure 2. Create new Virtual Machine Instance
When you click to New, a Create Virtual Machine window will appear
Figure 3. Create Virtual Machine on VirtualBox
On that window
- Type the name of your OPNsense VM Instance
- Select the preferred folder to create VM files on it.
- Select the Types as BSD
- Lastly, Select the Version as FreeBSD (64-Bit)
Click Next to configure Memory Settings
2. Configure the memory
The recommended memory size is 1024 MB
Depending on your computer’s memory capacity you can allocate more RAM for your VM instance.
Figure 4. Configure Memory Size on VBox
Click Next to configure Virtual Hard Disk Settings
3. Configure the Virtual Hard Disk
Figure 5. Hard Disk Configuration on VirtualBox
If you wish you can add a virtual hard disk to the new machine. You can either create a new hard disk file or select one from the list or from another location using the folder icon.
If you need a more complex storage setup you can skip this step and make the changes to the machine settings once the machine is created.
The recommended size of the hard disk is 16,00 GB.
We are creating VM Instance from scratch so that we will create a virtual hard disk now
Click Create.
Figure 6. Hard Disk File Type Selection on VirtualBox
Please choose the type of file that you would like to use for the new virtual hard disk. If you do not need to use it with other virtualization software you can leave this setting unchanged.
Let's go on as the default setting because we are not planning to use that disk in another virtualization environment. Select VDI (VirtualBox Disk Image)
Click Next to select Storage Type.
Figure 7. Storage on the physical hard disk on VirtualBox
Please choose whether the new virtual hard disk file should grow as it is used (dynamically allocated) or if it should be created at its maximum size (fixed size).
A dynamically allocated hard disk file will only use space on your physical hard disk as it fills up (up to a maximum fixed size), although it will not shrink again automatically when space on it is freed.
A fixed-size hard disk file may take longer to create on some systems but is often faster to use.
We are going to use Dynamically Allocated disk for this tutorial
Click Next to set Files Location and size.
Figure 8. File Location and Size Settings on VirtualBox
Please type the name of the new virtual hard disk file into the box below or click on the folder icon to select a different folder to create the file in.
As you may remember when we are creating a VM we have chosen the Download Folder, we see here that the path of OPNsense is automatically created under that Download folder. You may continue as it is or you may change it now.
Select the size of the virtual hard disk in megabytes. This size is the limit on the amount of file data that a virtual machine will be able to store on the hard disk.
The more disk space you have you can allocate more. For this tutorial, 16GB is enough.
Click Create to finish the VM creation process.
Now you can start to configure VMBox Settings.
Figure 9. VirtualBox - Settings
Click Settings.
4. Attach the OPNsense ISO image to VirtualBox
We will start with storage settings
Figure 10. VirtualBox Storage Settings
Firstly to attach the OPNsense ISO file:
Click the Empty Disc icon, select the ISO file from Attributes > Hard Disk Menu
Figure 11 . OPNsense Boot
5. Connect the network interfaces to the Opnsense firewall
Now we can set the network adapters
We will create 2 network adapters, the first one will be Bridge Adapter.
Figure 12. VirtualBox Network Settings
Select the ‘Bridge Adapter’ option from the “Attach to: “drop-down menu.
Select the network adapter on the host system that traffic to from this network card will go through. We chose the wireless adapter.
Figure 13. Creating a second Network adapter on VirtualBox
The second Network adapter will be Host-only-Adapter.
You should choose the created vboxnet interfaces. In this case vboxnet2
3.OPNsense Firewall Installation on VirtualBoxSettings
Start the OPNsense VM
After completing Network adapter settings, you can start your Virtual OPNsense Machine.
Figure 14. Click Start to boot Virtual OPNsense Machine
Click start to boot.
Figure 15. Select start-up disk on VirtualBox
You will be asked to locate the ISO file again. Locate it and click Start.
A black booting screen will be displayed and it will run automatically. You don't need to do anything until the login line appears.
Figure 16. First login for OPNsense Installer
After network interfaces are defined automatically you can initiate the installation by providing a username and password.
For installation;
Default username is installer
Default password is opnsense
Figure 17. Welcome to OPNsense Installer
The welcome screen will be displayed.
Click OK, Let’s go
Figure 18. Configure Console
Click Accept these Settings
Figure 19. Guided Installation
Select the Guided installation option
Figure 20. Select disk for OPNsense installation
You will be asked to select a disk. Select the disk fie to create VBox on it.
WARNING
All contents of the selected hard disk will be erased. This action is irreversible.
Figure 21. Select Install Mode on OPNsense
Select the installation mode as GPT/UEFI mode.
Figure 22. OPNsense installation - Executing Commands
VBox will start to execute commands. This process can take up to a few minutes according to your Virtual Machine resources.
Figure 23. Change OPNsense root password
When command execution is finished you will be asked to change the default password (opnsense).
You can change it now or you can continue by selecting Accept and Set Password.
Figure 24. OPNsense Installation completed.Reboot
While it is rebooting you should eject the DVD from VirtualBox. To prevent booting from a live cd you need to eject the disk immediately after clicking reboot.
Figure 25. Remove Disk from VirtualBox
Through Attributes Menu, click Optical Drive Icon and select Remove Disk from Virtual Machine
Initial Configuration of OPNsense Firewall
After reboot, you can login as root with the default password (opnsense ) if you haven't changed it during installation.
Figure 26. Login as root after installation
OPNsense menu will welcome you after login
Figure 27. Opnsense Menu
Now, we have to set the interfaces and IP addresses.
Enter an option: 1
Then click enter
Change the interfaces if they are not properly detected.
For WAN interface em0
For LAN interface em1
Figure 28. Network Interface assignments on OPNsense
Do you want to proceed [y/N]: y
Figure 29. Enter 2 to set IP Address
Now we can set IP addresses.
Enter an option: 2
Figure 30. Interface configuration
Enter the number of the interface to configure:1
For LAN interface don't set DHCP
Configure IPv4 address LAN interface via DHCP [y/N] N
Our host-only adapter is using vboxnet2 then we need to give a static IP address from that IP block.
Figure 31. Host-only adapter interface
Figure 32. LAN Interface Settings...
Figure 33. LAN Interface Settings
Figure 34. You can now access the web GUI by opening LAN IP address
Type the LAN IP address of the Virtual Opnsense machine on your browser.
Figure 35. OPNsense Login Page
Username:root
Password:opnsense (if not changed)
You can set the WAN interface now.
Configure IPv4 address WAN interface via DHCP? [y/N] y
Configure IPv6 address WAN interface via DHCP? [y/N] n
Enter for IPv6 Address
Do you want to revert to HTTP as the web GUI protocol? n
Do you want to generate a new self-signed GUI certificate? [y/N] y
Restore web GUI access defaults? [y/N] n
Figure 36. WAN interface settings
Figure 37. OPNsense Shell command
Interface and IP addresses configured
Lest test to ping the google by using menu 8.
Enter an option 8

Figure 38. Check internet connection of OPNsense
If ping works, congratulations you have successfully created your VİrtualBox OPNsense machine. You can update your VBox from GUI or by using menu 12 now.
Figure 39. OPNsense Dashboard
You can find more information about accessing the OPNsense Web GUI and initial configuration of the OPNsense firewall on the OPNsense Installation on Proxmox VE Tutorial.
Also, it is strongly recommended to update the OPNsense firewall after completing the installation. Please, refer to How to Update OPNsense? article written by Sunny Valley Networks.
Lastly, it may be helpful for you to read the How to Configure the OPNsense Firewall Rules article to protect your network infrastructure.