Contrary to what you may believe, your NAS is quite a versatile device. While its main purpose is obviously to store data and facilitate file-sharing between all your systems, a Network-Attached Storage enclosure can come in handy for several projects. Home lab enthusiasts can use it to self-host their favorite services, while gaming aficionados turn it into a makeshift server for private multiplayer lobbies.
In fact, you can even turn your NAS into an all-in-one network security solution with the help of pfSense. Since this process can be a tad complicated, we’ve compiled a step-by-step guide to help you out!
If you’re attempting to set up a network-wide firewall using your NAS, you’ll have to ensure it remains operational 24/7. That’s because all your devices will get disconnected from the Internet in case the NAS goes offline.
What you’ll need
With pfSense requiring a modest set of CPU and memory resources, you can replicate this project on most NAS devices that support virtualization. As such, any old system with a few cores and around 2GB of RAM should be enough to run pfSense inside a virtual machine. However, I’d recommend using a device with at least two Ethernet ports to avoid dealing with extra VLAN hijinks.
Most NICs should work with your NAS so long as you have a vacant PCIe slot. But you should be able to run the WAN/modem side of the connection using a USB-to-Ethernet adapter. Speaking of the modem, you’ll want to connect one of the Ethernet ports to the router/modem as the WAN connection, while the other port should be relegated to a network switch for the other LAN devices in your computing setup.
OS-wise, I’ve used TrueNAS Scale for this project because it’s available for free and has robust virtualization facilities. However, the overall procedure should be the same for other NAS operating systems.
Creating a pfSense VM inside the NAS
To keep things simple, we’ll set up pfSense inside a virtual machine. Once you’re ready, head to the official pfSense website and download the ISO file for the tool after signing up. Then, follow these steps after powering on your NAS and logging in to the UI:
- Head to the Virtualization tab and click on Add.
- Pick FreeBSD as the Guest Operating System.
- Give a Name and a Password to your pfSense VM. Be sure to hit the Next button after each step.
- Allocate some processor Cores and Memory to the virtual machine.
- Pick your preferred Zvol Location and set a handful of GBs as the Size parameter.
- Select a network interface card under the Attach NIC option.
- Tap the Upload new image button, use the Choose File option to add the pfSense ISO file you downloaded earlier, and hit Upload.
- Leave the GPU tab as is, and press Save to initialize the VM.
- To add other NICs, click on the drop-down arrow inside the virtual machine and select Devices.
- Under the Add Device header, choose NIC as the Type, pick your preferred card under the NIC to Attach option, and tap the Save button.
Installing pfSense in the VM
With the virtual machine all set, it’s time to install pfSense.
- Use the toggle to start the virtual machine and select Display.
- Enter the password you set earlier into the Spice UI.
- Hit Accept and choose Install on the welcome screen.
- Select Auto (ZFS) as the Partition method before taping Install.
- Pick Stripe as the Virtual Device type.
- Use the Spacebar key to select the disk and hit Yes at the final confirmation tab.
- Select Reboot when pfSense is finished installing.
- Once the VM restarts, enter the names of the WAN and LAN NICs.
- Open the web UI using the WAN IP address.
Configuring the pfSense web UI
Now that the pfSense virtual machine is up and running, you’re free to tweak the network settings inside the web UI.
- Enter admin as the Username and pfsense as the Password before clicking on Sign in.
- Hit Next twice, pick the Hostname and enter 1.1.1.1 as the Primary DNS Server. As usual, be sure to press Next after each step.
- Configure the Time Server settings.
- On the WAN page, you can either use DHCP to assign most options accordingly or choose Static and enter the IP address, Subnet mask, and other settings manually.
- (Optional) Set a new admin password for better security.
- Press Reload and hit Finish to wrap up the installation.
That’s it for the configuration part. Although pfSense is too vast for a single article, there are a couple of essential settings you should tweak to harden your network settings.
- Pick Rules under the Firewall tab and click on the Add button.
- Under the Add section, you can modify the Action (Pass, Block, or Reject) for the packets arriving from the Source and Destination addresses for all the Protocols. Be sure to hit the Save button once you’re done.
- Next, select OpenVPN inside the VPN header and tap Add.
- Inside, you can choose the Mode, Endpoint, Cryptographic, and Tunnel settings for your pfSense VPN.
Keeping your network (and files) safe from all harm using a NAS
Aside from the VPN and Firewall settings I’ve highlighted in the article, pfSense has a myriad of useful security features to safeguard your home network. If you’re a complete novice, I’d suggest doing some research before experimenting with the settings. That’s because a few badly configured settings are all you need to accidentally disconnect your home network from the Internet.
How to protect your home network with a Raspberry Pi firewall
Here's how you can configure a network-wide firewall with your Raspberry Pi
