A guide for the deployment and configuration of a virtualized OPNsense firewall for segmentation with Proxmox behind a double NAT.

This is the second part of my homelab “rebuild” project, Homelab Infrastructure Rebuild Overview. In my homelab configuration, my services are behind a double NAT, meaning that there is another router in front of OPNsense. If using OPNsense as your router, some configurations may differ. Keep in mind that the network behind your router, is the WAN side in the context of OPNsense.

Ultimately, I would prefer to not use a double NAT, but I am financially constrained and do not have a dedicated OPNsense machine, and therefore I must place it on my Proxmox server behind my ISP router.

Virtual Switch Creation in Proxmox

The first thing you’ll need to do before your deployment of an OPNsense VM is create a virtual trunked switch to manage your VLANs. To do this, open your Proxmox management GUI:

  1. Navigate to <your-proxmox-node> | System | Network
  2. Click Create | Linux Bridge
  3. Type <your-virtual-trunked-switch-name> in Name:
  4. Tick the VLAN aware: checkbox
  5. Click Create
  6. Click Apply Configuration

OPNsense Virtual Machine Deployment

In order to deploy an OPNsense VM, you’ll need to provide Proxmox the OPNsense ISO. Go to the OPNsense download page, select the “dvd” image type, and download the ISO. To upload the ISO to proxmox:

  1. Navigate to <your-proxmox-node> | local (<your-proxmox-node>) | ISO Images
  2. Click Upload
    1. Alternatively click Download from URL if you have an ISO download URL
  3. Click Select File
  4. Select <your-opnsense-iso>
  5. Click Upload

Now you can deploy your OPNsense VM:

  1. Click Create VM
  2. Configure to the table:
OptionSettingSectionNote
Node<your-proxmox-node>General
VM ID100
Nameopnsense
Start at boot (Advanced)YesSince this is the router, you definitely want this to start at boot
Start/Shutdown order (Advanced)1You also want this to be the first VM to start, since it is the router and network services will not work without it
Use CD/DVD disc image fileYesOS
Storagelocal
ISO image<your-opnsense-iso>
Guest OS TypeOther
Graphic cardDefaultSystem
Machineq35
BIOSSeaBIOS
SCSI controllerVirtIO SCSI Single
Qemu AgentYesOptional but highly recommended agent for Proxmox, see Qemu Agent Installation
Add TPMNo
Bus/DeviceSCSIDisks
Storagelocal-lvm
Disk size32 GB
CacheDefault
DiscardYes
IO threadYes
Sockets1CPU
Cores2
Typehost
Memory4096 MBMemory
Ballooning Device (Advanced)No
Bridgevmbr0Network
VLAN TagLeave blank
FirewallNo
ModelVirtIO
MAC AddressLeave blank
  1. Click Finish

Now you’ll need to add your virtual trunked switch to the VM.

  1. Navigate to 100 (opnsense) | Hardware
  2. Click Add | Network Device
  3. Configure to the table:
OptionSetting
Bridge<your-virtual-trunked-switch-name>
VLAN TagLeave blank
FirewallNo
ModelVirtIO
MAC AddressLeave blank
  1. Click Add

OPNsense Installation

Now that you have an OPNsense VM created and configured, you’ll need to install OPNsense using your mounted ISO. In Proxmox:

  1. Navigate to 100 (opnsense) | Console
  2. Click Start
    1. For the rest of the steps, complete these from the console within Proxmox
  3. Enter installer for login:
  4. Enter opnsense for Password:
  5. Select <your-keyboard-layout>
  6. Press ENTER
  7. Select Install (UFS)
  8. Press ENTER
  9. Select da0
  10. Press ENTER | ENTER
  11. Once installed, select Change root password
  12. Press ENTER
  13. Enter <your-opnsense-password>
  14. Enter <your-opnsense-password> again to confirm
  15. Select Complete Install
  16. Press ENTER
  17. Select Reboot Now
  18. Press Enter

OPNsense Configuration

Now you have OPNsense installed on a Proxmox virtual machine. You need to configure it next. In Proxmox:

  1. Navigate to 100 (opnsense) | Console1. Navigate to 100 (opnsense) | Console
  2. Enter root for login:
  3. Enter <your-opnsense-password> for Password:
  4. Enter 1
  5. Configure according to the table:
OptionSetting
Configure LAGGs?No
Configure VLANs?No (You will do this from the GUI)
WANvtnet0
LANvtnet1
  1. Press ENTER
  2. Enter Y | 2 | 1
  3. Configure vtnet1 to the table:
OptionSetting
DHCPNo
IPv4<your-lan-ip>, something like 192.168.1.1 or 10.0.0.1
Subnet bits24
Upstream GatewayNone
IPv6 via WAN trackingNo (Yes if not using double NAT)
DHCP6No
IPv6None
DHCP ServerNo (Probably Yes with a range if not using double NAT)
Revert to HTTPNo
Generate a self-signed certificateYes
Web GUI defaultsYes
If you’re doing the double NAT, you’ll also want to reserve an IP address for OPNsense in your router. On default, OPNsense blocks GUI access from the WAN side, this is important for the double NAT. Because your devices are on the WAN side in regards to OPNsense, you’ll need to temporarily disable them.
In your OPNsense console, from Proxmox:
  1. Enter 8
  2. Enter pfctl -d

Now you can access OPNsense from a WAN side device. To finish configuration of OPNsense from the GUI:

  1. Navigate to <your-opnsense-wan-ip> in a web browser
  2. Type root Username:
  3. Type <your-opnsense-password> for Password:
  4. Click Login
  5. Configure the wizard to the table:
OptionSettingSection
HostnameopnsenseGeneral Information
Domain<your-home-domain>, could be something like home.example.com
LanguageEnglish
TimezoneEtc/UTC
DNS Servers<your-first-router-ip>
Enable ResolverYes
Enable DNSSEC SupportYes
Harden DNSSEC dataYes
Disable WANNoNetwork (WAN)
TypeDHCP
MAC (spoofed)Leave blank
MTULeave blank
MSSLeave blank
DHCP hostnameLeave blank
Block RFC1918 Private NetworksNo (Yes if not using double NAT)
Blog bogon networksNo (Yes if not using double NAT)
Disable LANNoNetwork (LAN)
IP Address<your-lan-ip>
Configure DHCP ServerNo (Probably Yes if not using double NAT)
Optimize for MultiwanNoDeployment Type
Automatic DHCP/DNS RegistrationNo (Probably Yes if not using a double NAT)
Optimize for IPsecNo
When prompted to set an initial password, leave it blank as we already set one when installing OPNsense.
  1. Click Apply

In the context of a double NAT, while the disabled Block RFC1918 Private Networks rule stops private addresses from being dropped, the default state of your WAN side is to deny all incoming traffic, you need to create a temporary firewall rule to allow incoming traffic from the device you are using to configure OPNsense. The reason this is temporary is that we are going to create a VLAN specifically for management, which will be accessible from a VPN or trusted devices on their own VLAN. Proxmox and OPNsense will only be manageable from those connections, as they will have their management interfaces moved to the management VLAN. We will also further segment our external services into its own VLAN and machine, a DMZ, and our internal services into its own VLAN and machine. These will also only be manageable from the VPN or trusted devices. To create the Firewall rule, you likely will need to disable firewall rules again. Refer to the above step to do that again. Once you can access the OPNsense management GUI:

  1. Navigate to Firewall | Rules
  2. Click + Icon
  3. Configure to the table
EnabledCategoriesDescriptionInvert InterfaceInterfaceQuickActionDirectionVersionProtocolInvert SourceSourceSource PortInvert DestinationDestinationDestination PortLogGateway
YesLeave blankTemporary - OPNsense access from trusted PCNoWANYesPassInIPv4TCPNoSingle host or network <your-client-device-ip>AnyNoThis FirewallHTTPS (443)YesNone
  1. Click Save
  2. Click Apply

Now, we can configure our VLANs for segmentation.

OPNsense VLAN Configuration

Our VLANs will serve the segmentation of your network, allowing for granular management of network traffic. In your OPNsense management GUI:

  1. Navigate to Interfaces | Devices | VLAN
  2. Click +
  3. Create VLANs according to the table, click Save after you fill each out.
DeviceParentVLAN TagVLAN priorityDescription
Leave blankvtnet110Best Effort (0, default)MANAGEMENT
Leave blankvtnet120Best Effort (0, default)TRUSTED
Leave blankvtnet130Best Effort (0, default)INTERNAL
Leave blankvtnet140Best Effort (0, default)DMZ
Leave blankvtnet150Best Effort (0, default)STORAGE
  1. After all VLANs are created, click Apply

Each VLAN serves a different purpose. 10 is for managing our main services, like Proxmox. 20 is for our trusted devices, which will be able to manage all of our homelab services. 30 is for internal services, so only services that will not be publicly available. 40 is our DMZ, for publicly available services. 50 is for storage devices, such as NAS.

Now, we need to assign these VLANs network interfaces.

  1. Navigate to Interfaces | Assignments
  2. Click +
  3. Create interface assignments according to the table
LockDescriptionDevice
YesMANAGEMENTvlan01
YesTRUSTEDvlan02
YesINTERNALvlan03
YesDMZvlan04
YesSTORAGEvlan05
  1. Click Apply

Lastly, we need to configure our VLAN network interfaces.

  1. For each interface, navigate to Interfaces | <interface-name>
  2. For each interface, configure according to the table:
NameEnableLockDescriptionBlock private networksBlock bogon networksIPv4 Configuration TypeIPv6 Configuration TypeMAC addressPromiscuous modeMTUMSSDynamic Gateway PolicyIPv4 AddressIPv4 Gateway Rules
MANAGEMENTYesYesMANAGEMENTNoNoStatic IPv4NoneLeave blankNoLeave blankLeave blankNo10.0.10.1/24Disabled
TRUSTEDYesYesTRUSTEDNoNoStatic IPv4NoneLeave blankNoLeave blankLeave blankNo10.0.20.1/24Disabled
INTERNALYesYesINTERNALNoNoStatic IPv4NoneLeave blankNoLeave blankLeave blankNo10.0.30.1/24Disabled
DMZYesYesDMZNoNoStatic IPv4NoneLeave blankNoLeave blankLeave blankNo10.0.40.1/24Disabled
STORAGEYesYesSTORAGENoNoStatic IPv4NoneLeave blankNoLeave blankLeave blankNo10.0.50.1/24Disabled
  1. Click Save after each configuration
  2. Click Apply Changes

Qemu Guest Agent Installation

Qemu Agent is a daemon that you can install on your Proxmox VMs. It helps to properly shutdown your VM and properly freeze the filesystem when backing up or taking snapshots. It also provides some monitoring insights, like IP address info from the Proxmox management GUI. To install and configure this on OPNsense, you’ll first want to make sure your OPNsense is up to date. Navigate to your OPNsense management GUI:

  1. Navigate to System | Firmware | Status
  2. Click Check for updates
  3. In System | Firmware | Updates, scroll down and click Update | OK

After the reboot has occurred and your OPNsense is up-to-date and back online, you may install the qemu guest agent:

  1. Navigate to System | Firmware | Plugins
  2. Type qemu in the Name text box
  3. Click Click to view the community plugins.
  4. Click the + in the os-qemu-guest-agent package
  5. Navigate to Services | QEMU Guest Agent | Settings
  6. Tick Enable Service
  7. Click Apply

The Qemu guest agent is now installed and enabled.

Closing Notes

You should now have an OPNsense firewall configured with the ability to deploy Proxmox virtual machines to their respective VLANs. In my next post I will discuss the deployment of a virtual machine for hosted services and the creation of firewall rules to manage and access them.