This post may contain affiliate links/ads and I may earn a small commission when you click on the links/ads at no additional cost to you. As an Amazon Affiliate, I earn from qualifying purchases. Techsphinx also participates in the StationX Affiliate program. You can read my full disclaimer here.
In this tutorial, I will show you how to install pfSense on VirtualBox.
pfSense is a free and open-source firewall software. You can install pfSense on an old PC, Mini PC or even run pfSense as a virtual machine.
Netgate makes the official hardware for pfSense that are pre-loaded with the pfSense plus software. The community edition of pfSense (pfSense CE) which is free to use for home and non-commercial purposes is what we’re going to install on VirtualBox.
Note: Although you can install pfSense on VirtualBox, for the best performance, it is recommended to install pfSense on compatible hardware.
Pre-Requisites to Install pfSense on VirtualBox
Complete the following things before proceeding with the pfSense installation steps.
1. Download and install the latest Oracle VirtualBox software.
2. Download the pfSense ISO image file.
- Select the AMD64 (64-bit) architecture.
- Choose the DVD Image (ISO) Installer.
- Select the closest mirror for faster download.
- Click on the “Download” button and wait for it to finish.
3. Extract the pfSense ISO file.
The downloaded file is in a compressed (gz) format. You need to extract the ISO file. For that, you can use the “7-zip” software (on Windows) or the “gzip” command (on Linux):
gzip -d pfsense.gz
(Replace the “pfsense.gz” with your downloaded filename.)
4. Make sure, you have sufficient RAM (at least 1 GB) and storage (at least 8 GB) for pfSense VM.
This is the setup I am going for. First, I will install and configure the pfSense VM with two network interfaces (WAN and LAN). Secondly, I will connect the WAN interface to the internet and the LAN interface to my other two virtual machines (Ubuntu and Debian). These two machines will act as end-user machines.
Lastly, I will test the connectivity and make sure everything is working correctly.
Steps to install pfSense on VirtualBox
Create pfSense VM
1. Start VirtualBox and Click on “New” to create a pfSense instance.
2. Provide a name to your pfSense VM, I am using “pfSense” here.
3. Next, choose a location where the VM is saved on the computer. I am leaving it as default.
4. Leave the ISO image part for now, we will add the ISO image later.
5. For “Type”, choose BSD from the dropdown and for “Version”, choose FreeBSD (64-bit).
6. Click on “Next”.
Configure RAM and vCPU
On this screen, you will be provided with the option to choose RAM and virtual CPU for your pfSense instance.
1. Select the amount of RAM by moving the slider (or typing it manually in the adjacent box). I am giving 4 GB RAM to my pfSense VM.
2. Repeat the same for the processor part. I am allocating 2 CPUs for the VM.
3. Click on “Next”.
Configure Storage for pfSense
Now, it’s time to allocate storage by creating a virtual hard disk for our pfSense VM.
1. Select the first option “Create a virtual Hard disk now”.
2. Choose the disk size by moving the slider (or typing). I am allocating 20 GB; you can choose a lower or higher amount.
3. Click on “Next”.
4. VirtualBox will show you the summary of the configuration for your new VM. Click on “Finish”.
Configure Network for pfSense
Next, we need to configure the network. This is a crucial step, so let me explain everything before proceeding with the configuration of the interfaces.
The pfSense firewall needs two interfaces. First is the WAN interface that connects to the internet and second is the LAN interface that connects the inside devices.
Usually, when deploying pfSense on a physical machine, you’ll require two NICs (Network Interface Cards). However, things are simple in virtualized environments. You can easily create two virtual NICs in VirtualBox for pfSense WAN and LAN interfaces.
For the WAN interface, you can use the NAT or Bridged Adapter mode in VirtualBox. Here, I am creating a bridge interface that will get IP directly from my router’s DHCP.
Configure the WAN Interface:
1. Click on the pfSense instance and then click on “Settings”.
2. Navigate to the “Network” tab.
3. Under Adapter 1, check the “Enable Network Adapter” option.
4. Set the “Attached to:” option to “Bridged Adapter”.
Configure the LAN Interface:
Now, to configure the LAN interface:
1. Click on “Adapter 2” and check the “Enable Network Adapter” option.
2. Set the “Attached to:” option to “Internal Network”.
3. Provide a name for your internal network. I am using “pfSense-LAN”.
Attach the pfSense ISO Image and Change Boot Order.
After configuring the network, it’s time to attach the pfSense ISO image.
1. Navigate to the “Storage” tab.
2. Click on “Empty” under storage devices.
3. Click on the blue CD icon (next to the “Optical drive” option).
4. Click on “Choose a disk file” from the dropdown.
5. Locate and select the downloaded pfSense ISO file.
6. Once it’s loaded, you’ll see the name of the pfSense ISO file instead of the “Empty” under storage devices.
7. Navigate to the “System” tab. You’ll see the boot order there.
With the default boot order, VirtualBox will load the floppy drive first, since it’s empty, it will try to load the next option which is the optical drive that contains the pfSense ISO image.
Now, this setup is good. However, after the pfSense installation, the VM will reboot and during that time, it will follow the same boot order. First floppy, then Optical drive, then hard disk. That’s a problem because after installation we want it to boot from the hard disk first.
Therefore, changing the boot order to Hard disk first, then the optical drive will be more appropriate. This way during the first time, VirtualBox will try to boot from the hard disk (which is empty), and then go to the second option, the optical drive. Once, the installation is finished and the system is rebooted. It will boot from the hard disk.
8. Select the “hard disk” and use the up arrow to make it the first on the boot order list. Repeat the same for the “Optical Drive” and keep it in the second position.
9. Finally, click on “OK”.
Start the pfSense Installation
Now, start the pfSense VirtualBox instance and initiate the installation process.
1. Select the pfSense instance and click on “Start”. After a few seconds, you will see the pfSense installer screen.
The pfSense installer is TUI (Text-based User Interface), use the arrow keys on your keyboard for navigation.
2. Hit enter to accept the copyright and trademark notice.
3. Select the “Install pfSense” option and click on “OK”.
4. Choose your preferred keymap and hit enter. I am continuing with the default keymap.
5. On the partitioning tab, choose the “Auto (ZFS)” option and click on “OK”.
6. Choose the “Proceed with installation” option and click “Select”.
7. Select “Stripe” as the virtual device type and click on “OK”.
8. Use the space key to select the VBOX Harddisk and click “OK”.
9. Lastly, click on “YES” to start the installation process.
10. At the final stage of installation, you will be asked if you want to make any final manual modifications. Click on “NO”.
Once the installation is finished, click on “Reboot”. After booting up, you will see the pfSense welcome screen.
Configure pfSense LAN Interface IP Range
On the welcome screen, you will see the WAN and LAN interfaces and their assigned IP addresses.
In my case, the WAN IP is 192.168.29.71 (got from the router) and LAN IP is 192.168.1.1. Now, for me, it’s all good. However, some routers use the 192.168.1.1 series, in that case, your LAN and WAN will be on the same network.
To change the LAN interface IP, follow these steps:
1. Press 2 and hit enter to set the interface IP address.
2. From the available interfaces, select the LAN interface by typing the corresponding number and hitting enter. In my case, it is “2”.
3. Enter the new LAN IP address and hit enter, I am giving it 10.0.1.1.
4. Enter the new LAN IPv4 subnet and hit enter. I am using the 255.255.255.0, so I will type “24”.
5. You don’t have to type anything for the next setting, just hit enter.
6. Next, enter the new LAN IPv6 address and hit enter. I am not configuring the IPv6 address, hence I am leaving it empty.
7. Type “y” and hit enter to enable the DHCP server on LAN. With this, all the VM connected to pfSense LAN will be automatically assigned an IP address.
8. Enter the starting address of the IPv4 address Range and hit enter. I am starting it from 10.0.1.5.
9. Subsequently, enter the end address or the IPv4 address Range and hit enter. I am choosing the last address – 10.0.1.255.
10. When asked to revert to HTTP as the “webConfigurator protocol”, type “n” and press enter.
The LAN IP address is changed. Hit enter key to continue and the change will be reflected on the pfSense welcome screen.
Test pfSense connectivity
1. To test the pfSense connectivity to the internet, press 7 and hit enter.
2. Enter the IP address or hostname and hit enter. I am entering “www.google.com”.
If you see the successful ping result on the screen, it means there is no issue in connecting to the internet via the pfSense VM.
Connect other VMs to the pfSense VM
If you have other virtual machines installed and running, then you can connect them to the pfSense firewall. I have Ubuntu installed on VirtualBox here.
1. Click on the Ubuntu (or any other VM) and click on “Settings”.
2. Navigate to the “Network” tab.
3. Under “Adapter 1”, check the “Enable Network Adapter” option.
4. Set the “Attached to” option to “Internal Network”.
5. Using the down arrow next to the name field, choose the LAN network we created earlier. In my case, it is the “pfSense-LAN”.
6. Click on “OK” and start the virtual machine.
7. Once the virtual machine is booted, check its IP address. You’ll see that it is getting IP from the pfSense LAN we set up earlier.
8. Use the ping utility to check if you can reach the internet.
If you want to know the path that the packet is taking, use the traceroute utility.
And you’ll see that it is going through the pfSense firewall.
The Ubuntu machine is connected to the pfSense LAN side. You can repeat the same process for any other virtual machine. I also have Debian installed on VirtualBox, I am connecting that too.
Access pfSense GUI and complete the Initial setup wizard
You can now access the pfSense GUI from the web browser of any virtual machine that is connected to the pfSense LAN.
1. Open the web browser and type pfSense LAN IP address. In my case it is:
2. You’ll get a certificate warning; you can ignore that. Click on “Advanced” and then click on the “Proceed to URL (Unsafe)” option.
3. After that, you will see the pfSense login screen.
4. Enter username – admin and password – pfsense to log in to the pfSense dashboard.
Once logged in, you’ll see the pfSense initial setup wizard. You can configure the time zone, change the admin username and password, set the hostname, set the domain and many other settings through this wizard.
Just click “Next” and go through different screens, you can also leave things as it is. Click the “Reload” button to reload pfSense with new changes. After that, you’ll see the “Wizard completed” screen.
Additionally, you can navigate to the Status > DHCP Leases to view all the machines to which the pfSense assigned the IP address. In my case, I have two IPs, one for Ubuntu and the other for a Debian VM.
That’s it! You have successfully installed pfSense on VirtualBox. The installation steps are pretty straightforward. As I mentioned in the beginning, it is recommended to install pfSense on a Mini PC for optimum performance.
Another great open-source firewall solution is OPNsense. It is also based on FreeBSD and you can install OPNsense on VirtualBox and try that out too.