OPNsense VLAN Setup: Create, Assign, DHCP and Firewall Rules

  • Post author:Frank Joseph
  • Post published:
  • Post last modified:
  • Post category:OPNsense
  • Reading time:8 mins read

OPNsense VLAN setup comes down to four steps: create the VLAN on a parent interface under Interfaces > Devices > VLAN, assign it as an interface with its own subnet, give it a DHCP range, and add the firewall rules that decide what it can reach. Every OPNsense screen and label below is from 26.7.8, released on October 30, 2026.

If you’re following an older guide, the OPNsense VLAN configuration itself hasn’t changed much, but most of the screens have moved. The VLAN page used to sit under Interfaces > Other Types, and 26.7 switched assignments and firewall rules to new pages. The old Services > DHCPv4 page was ISC DHCP, which is end-of-life and only a plugin now, and Dnsmasq is the default.

Before creating any OPNsense VLANs, decide which networks you actually need. For most people, I’d say that’s three (trusted, IoT and guest), with a fourth for cameras if you have them, and anything past four gets difficult to manage. If you only have one switch, it can live on the trusted VLAN rather than a management VLAN of its own. I’d also get off of 192.168.1.x (OPNsense’s default LAN), but past that the subnet is up to you. The example below builds an IoT VLAN with tag 20 on 192.168.20.1/24.

How to Set Up a VLAN in OPNsense

The cleanest layout, and the one the OPNsense VLAN and LAGG documentation recommends, is an unassigned parent port that carries only tagged VLANs to a managed switch. Here, the parent is em2, a spare port, and em0 stays the LAN. If your box only has two ports, you can put the VLANs on the LAN port instead, though the docs warn that mixing untagged and tagged traffic on one trunk can leak broadcasts like DHCP between them.

Create the VLAN Device

1. Log in to OPNsense, select Interfaces, then Devices, and finally, VLAN.

2. Select + to open Edit Vlan. Leave Device empty (it becomes vlan01), set Parent to the port facing your switch (em2 here), and enter 20 as the VLAN tag. Leave VLAN priority at Best Effort (0, default) unless your switch does QoS on it, enter a Description like IoT, and select Save.

OPNsense Edit Vlan dialog with Device empty, Parent em2, VLAN tag 20, VLAN priority Best Effort (0, default) and Description IoT

3. Select Apply.

OPNsense Interfaces: Devices: VLAN list with vlan01 on parent em2, VLAN tag 20 and description IoT, and the Apply button below it

The tag can be anything from 1 to 4094, but it has to be unique on that parent and match your switch.

Assign the VLAN Interface

OPNsense won’t route for the VLAN until it’s assigned as an interface with an address.

1. Select Interfaces, then Assignments, and select + to add an assignment.

2. In Edit Assignment, choose vlan01 IoT (Parent: em2, Tag: 20) under Device, leave Enabled and Lock checked, and set the Description to IOT.

3. Change IPv4 Configuration Type from None to Static IPv4 and enter 192.168.20.1/24 in IPv4 address. Select Save.

OPNsense Edit Assignment dialog with Enabled and Lock checked, Description IOT, Device vlan01 IoT (Parent: em2, Tag: 20), Static IPv4 and 192.168.20.1/24

4. Select Apply beside the pending-changes banner. The VLAN is listed as opt1.

OPNsense Interfaces: Assignments list with wan, lan and the new opt1 IOT VLAN at 192.168.20.1/24, and the banner asking to apply the pending changes

At the console, option 1) Assign interfaces asks “Do you want to configure VLANs now?” if you’d rather create them there.

Configure DHCP for the VLAN

Dnsmasq is the default DHCP server, so on an OPNsense VLAN, DHCP happens in two places: the interface list in Dnsmasq’s general settings, then a range. A fresh install only serves the LAN, and if IOT isn’t in that list, the VLAN gets no DHCP and none of the automatic DHCP firewall rules.

1. Select Services, then Dnsmasq DNS & DHCP, and finally, General.

2. In Interface, add IOT next to LAN, then select Apply.

OPNsense Dnsmasq DNS & DHCP General tab with Enable checked and Interface set to IOT, LAN

3. Open DHCP ranges and select +. Set Interface to IOT, Start address to 192.168.20.100 and End address to 192.168.20.199. Select Save, then Apply.

OPNsense Edit DHCP range dialog with Interface IOT, Start address 192.168.20.100 and End address 192.168.20.199

Kea DHCP is also built in, but the OPNsense Dnsmasq documentation aims it at larger setups and suggests Dnsmasq when in doubt.

Create the VLAN Firewall Rules

A new VLAN can’t talk to anything by default. Traffic that starts on it is blocked until you add a pass rule, and the rules page says so: “All incoming connections on this interface will be blocked until you add a pass rule.” The LAN is different, as it ships with a Default allow LAN to any rule, so trusted devices can reach into the new VLAN even though the VLAN can’t reach out.

For an IoT VLAN, that’s two rules: a block to the LAN, then a pass to everything else. Rules are first match, so the block rule has to sit above the pass rule. A new rule is added at the bottom of the list, so create the block rule first.

1. Select Firewall, then Rules, and set the interface filter to IOT.

OPNsense Firewall: Rules filtered to IOT with the banner saying no IOT rules are defined and incoming connections are blocked until a pass rule is added

2. Select +. Interface (rule) should already show IOT. Add a Description like Block IoT to LAN under Organisation at the top (click its header if it’s collapsed), set Action to Block, set Destination to LAN network, and select Save.

OPNsense Edit rule dialog with Description Block IoT to LAN, Interface (rule) IOT, Action Block, Direction In, Version IPv4 and Destination LAN network

3. Select + again. Leave Action at Pass, set Source to IOT network, leave Destination at any, and select Save.

4. Select Apply.

OPNsense Firewall: Rules for IOT with the Block IoT to LAN rule, destination LAN network, listed above the pass rule from IOT network

If the rules end up the wrong way around, check the block rule’s box and select the Move rule before this rule arrow on the pass rule, then Apply. With both applied, IOT can reach the internet but not the LAN, while the LAN can still reach IoT devices, which is how I’d set up an IoT network. The pass rule’s any includes OPNsense’s own login page, though, and IoT devices should never need it. A guest VLAN uses the same two rules, and a camera VLAN that shouldn’t reach anything can skip the pass rule. With more VLANs, add a block rule for each network a VLAN should stay out of.

Connect the VLAN to Your Switch and Access Point

OPNsense tags the traffic, but your switch has to understand those tags. An unmanaged switch can’t handle VLANs at all (it has no idea what they are), so you’ll need a managed switch.

The OPNsense VLAN trunk to the switch is the port your parent interface plugs into. Set that switch port to carry VLAN 20 tagged, and with a spare parent like em2, give it no untagged (native) VLAN. If your switch can’t remove the default VLAN from a trunk, the docs suggest setting the native VLAN to a tag nothing uses (their example is 3999). Ports for your devices are access ports on VLAN 20, which add the tag on the way in and strip it on the way out.

Access points are the exception. Most want their management network untagged and extra SSIDs tagged, so the switch port to an AP carries the default network untagged plus VLAN 20 tagged, and the SSID is mapped to VLAN 20 in the AP’s settings. The SSID is just a name, and the VLAN is the actual boundary.

With UniFi switches and access points behind OPNsense, open UniFi Network, select Settings, then Networks, and finally, New Virtual Network. Set the Router dropdown to Third-party Gateway and use the same VLAN ID as in OPNsense (20 here). The UniFi guest network VLAN guide covers the WiFi side.

If OPNsense is a VM, set up the hypervisor below first. Then connect a device to the VLAN and check that it gets a 192.168.20.x address, loads a website, and can’t open anything on the LAN.

If the VLAN Isn’t Working (Including in a VM)

If a device on the VLAN gets no address or no internet, check these in order.

  • Nothing was applied. The VLAN, the assignment, Dnsmasq and the rules each have their own Apply, and an unapplied assignment is gone after a reboot.
  • No DHCP address. IOT isn’t selected under Dnsmasq DNS & DHCP > General > Interface.
  • An address, but no internet. There’s no pass rule on IOT yet.
  • IoT devices can reach the LAN. The block rule is below the pass rule.
  • Still no address. Usually the switch: it has to allow tagging for that specific VLAN on every trunk between OPNsense and the device.
  • Two networks share a subnet. Each VLAN needs its own, or routing between them breaks.
  • A NIC driver problem. VLAN Hardware Filtering under Interfaces > Settings may be broken in some drivers, according to its help text, so set it to Disable VLAN Hardware Filtering as a test.

OPNsense Running as a Proxmox VM

If OPNsense runs as a virtual machine, the hypervisor has to pass the tags through. In Proxmox, the Linux bridge OPNsense’s network device sits on needs VLAN aware checked (it’s off on a new bridge), and that network device gets no VLAN Tag, because OPNsense does the tagging itself (Proxmox calls this trunk mode). The host’s physical port then goes to a switch port carrying those VLANs tagged. Other hypervisors name the setting differently, but OPNsense’s virtual NIC still needs every tag.

That’s the opposite of a normal VM. On my Proxmox hosts, VLAN aware is checked on the bridge and a VM that belongs on one VLAN gets that tag on its network device (my IoT VLAN is 210). My Proxmox VLAN guide covers the bridge, and installing OPNsense in Proxmox covers the VM.

Test from a device on each VLAN every time you add a rule. Security changes over time and nothing here is guaranteed, so treat these rules as a starting point, not a finished firewall.

Frank Joseph

I'm Frank, founder of WunderTech. I've been working in enterprise IT for 15+ years and running home labs for nearly a decade — every tutorial on this site is tested on hardware I actually own, including Synology NAS units, a DIY TrueNAS server, a Proxmox cluster, a full UniFi network, and more. I hold a BS in Computer Information Systems and an MBA, but most of what you'll read here comes from my home lab, not a classroom. You can also find video versions of these tutorials on my YouTube channel.