10 Create a pfSense Firewall VM
Mathew J. Heath Van Horn, PhD
The software product pfSense is a popular open-source firewall used by small and mid-sized companies. The software can run on hardware or a virtual machine. It is based on Unix FreeBSD which differs from Linux. This lab leads the learner to create a pfSense VM in VirtualBox.
Learning Objectives
- Successfully download, install, and run pfSense in VirtualBox
Prerequisites
Deliverables
- None – this is a preparatory lab that supports other labs in this book
Resources
- Download pfSense
- Kingatua, Amos, “How to install pfSense Firewall on Ubuntu and CentOS?”, https://geekflare.com/pfsense-installation-guide/
Contributors and Testers
- Jacob M. Christensen, Cybersecurity Student, ERAU-Prescott
- Julian H. Romano, Cybersecurity Student, ERAU-Prescott
- Evan Paddock, Cybersecurity Student, ERAU-Prescott
- Dante Rocca, Cybersecurity Student, ERAU-Prescott
Phase I – Download pfSense
pfSense is an operating system (OS), like Windows, Linux, or MacOS.
- Download the installer for pfSense Community Edition
NOTE: At the time this was written, Netgate made a surprising update that requires users to register for a new account and give up personal information just to download the Community Edition image of pfSense. For many, this compromise of privacy for the sake of corporate data harvesting is not worth this extra road block for learning. Therefore, we will provide two different methods for downloading pfSense.
- The “Official” Method: https://www.pfsense.org/download/
NOTE: It is strongly advised to avoid using to real personally identifiable information (PII) for online accounts you’ll only use once. Companies get hacked all the time; the last thing you want is your name, physical address, and phone number leaked just because you wanted to mess around with firewalls! However, you are not restricted from using temporary emails, temporary phone numbers or false addresses when needed.
- The “Unofficial” Method (Recommended): https://www.pfsense.app/download/
- Select the following options from the associated drop-down menus (Figure 1)
NOTE: This example uses CE version 2.7.2.
- Architecture: AMD64 (64-bit)
- Installer: DVD Image (ISO) Installer
- Click Download
NOTE: At this point, a file named pfSense-CE-x.x.x-RELEASE-amd64.iso.gz should be downloaded by your browser. The .gz file extension stands for GNU Zip, which is an application commonly used for file compression.
- Select the following options from the associated drop-down menus (Figure 1)
- The “Official” Method: https://www.pfsense.org/download/
- Navigate to the folder where you downloaded the ISO and decompress (unzip) it
- If you’re on Windows, use 7zip
- If you’re on Linux, use GNU unzip
$ gunzip ~/Downloads/file-name.gz
- You should now see a file name pfSense-CE-x.x.x-RELEASE-amd64.iso in your Downloads directory
Phase II – Create a pfSense VM
Creating a pfSense VM is a pretty standard exercise.
- Start the Oracle VM VirtualBox Manager application
NOTE: This example uses VirtualBox GUI Version 6.1.X in the following steps. While your version may vary in organization and layout, the fundamental process should remain the same.
- At the top of the dashboard, select New
- A new sub-menu called Create Virtual Machine should appear (Figure 4)
- Fill in the following information:
Option Recommended Value Description Name pfSense-Firewall Custom name of the Virtual Machine. Can be anything, but should probably be somewhat descriptive to differentiate from other VMs. Machine Folder <Leave as default path> The directory in which to store all files related to VM creation. Type BSD Selects the generic operating system of the VM such as Windows, Linux, or Mac OS. Version FreeBSD (64-bit) Specifies the specific sub-category of the selected OS and whether it will use a 32bit or 64bit processor. Memory size 1024 MB (1 GB) Determines how much RAM to allocate to the VM. Hard disk Create a virtual hard disk now Determines whether or not to allocate physical storage to act as a hard disk or to use an existing virtual hard disk file. - Select Create
- Fill in the following information:
- A new sub-menu called Create Virtual Hard Disk should appear (Figure 5)
- Fill in the following information:
Option Recommended Value Description File location <Leave as default path> The directory in which to save the virtual hard disk. This will often be the same directory as the Machine Folder path. File size 8 GB Determines the size of the virtual hard disk. The minimum requirements for pfSense is 8 GB. Hard disk file type VDI (VirtualBox Disk Image) Selects the type of virtual hard disk to create. Storage on physical hard disk Dynamically allocated Selects whether to allocate physical hard disk space as needed (dynamically), or all at once (fixed). Choosing fixed will may result in slightly better performance at the cost of a higher storage footprint that will potentially go unused. - Select Create
- Fill in the following information:
- This will create a new virtual machine in your VM list
Phase III – Configure VM settings for the pfSense Server
Depending on your existing VirtualBox configuration, some configurations may already be applied.
- Select (highlight) the pfSense-Firewall VM and then click Settings
- A new sub-menu called pfSense-Firewall – Settings should appear
- Modify the System settings to make booting off the virtual hard disk highest priority (Figure 9)
- On the left-side menu, select System
- Under Boot Order, highlight Hard Disk and click on the UP arrow until it’s at the top of the list
- Modify the Storage settings to add the pfSense ISO installer (Figure 11)
- On the left-side menu, select Storage
- Under Storage Devices, select Controller: IDE
- Select the small icon labeled Add optical drive
- A new sub-menu called pfSense-Firewall – Optical Disk Selector should appear (Figure 12)
- Select Add Disk Image
- Navigate to the location where you unzipped the pfSense ISO installer and click Open
- Ensure that the .iso file is highlighted and click Choose (Figure 14)
- Select Add Disk Image
- You should now see the pfSense installer in the list of Storage Devices
- Modify the Network settings to give the VM internet connectivity (Figure 16)
- On the left-side menu, select Network
- Click the Adapter 1 tab
- Ensure that Enable Network Adapter is selected
- Attached to: NAT
- Click on OK to save the new configuration settings
Phase IV – Installing the pfSense VM to the Virtual Hard Disk
Launch the pfSense VM like any other virtual machine.
- Start the pfSense-Firewall virtual machine
- Select the DVD Image files to begin the installation sequence then press Start
- Follow the installation guide to install pfSense to the VDI
NOTE: Place your mouse inside the VM and left-click to make the VM active. To navigate out of the VM, press the Right-Ctrl key on the keyboard.
- Press Enter to accept the Copyright and distribution notice (Figure 19)
- Use the arrow keys to highlight Install and then tab to select OK and press Enter (Figure 20)
- Use the arrow keys to highlight Auto (ZFS) and then tab to select OK and press Enter (Figure 21)
- Use the arrow keys to highlight >>> Install and then tab to select Select and press Enter (Figure 22)
- Use the arrow keys to highlight stripe and then tab to select OK and press Enter (Figure 23)
- Use the spacebar to select ada0 and then tab to select OK and press Enter (Figure 24)
NOTE: You’ll know it’s selected when you see an asterisk (*) next to the disk name.
- Use the tab key to select YES to overwrite all data and press Enter (Figure 25)
- When installation is finished, use the tab key to select Reboot and press Enter
- Wait a minute for the machine to reboot
- Once the machine has booted from disk, you will be prompted for some post-installation configuration settings
NOTE: You may have to press Enter for the menu to appear.
- You should now see the main menu for pfSense!
- Now pfSense is installed, we can remove the DVD installer image from the VM’s virtual disk drive
- Type 6 and press Enter in the pfSense console menu to gracefully shutdown the device
- Type y and press Enter to proceed
- Navigate back to the VirtualBox dashboard
- Highlight the VM, click Settings, then Storage
- Under Storage Devices, select the ISO file (Figure 32)
- Near the bottom of the window, click Remove selected storage attachment
NOTE: Sometimes two copies of the ISO file appear. Remove them both.
- Click OK to save your settings
- Your pfSense firewall VM is now successfully built if it boots again to the main console menu!