OPNsense VLAN segmentation: splitting your network into zones
VLANs split your network into zones, and firewall rules decide what may cross between them, so a hacked smart device can't get to your NAS. This guide sets that up step by step in OPNsense.

OPNsense VLAN segmentation
VLANs split your network into zones, and firewall rules decide what may cross between them, so a hacked smart device can’t get to your NAS. This guide sets that up step by step in OPNsense.
Who this guide is for: IT professionals and home users already running OPNsense who want to split their network into isolated zones. If you are still deciding whether segmentation is worth it, start with the broader home network segmentation guide.
With the rules in this guide, a compromised IoT device has no access to your NAS or work files. The block runs one way on purpose: Private and Work can still reach IoT, so you can use your printer and TV, and Private can reach Work until you add the block from the scenario below.
This article is specifically about OPNsense. Using a GL.iNet router with OpenWrt? See the network segmentation with VLANs guide.
Which OPNsense version? The steps match OPNsense 26.7 (released July 2026). That release rebuilt two screens this guide uses: interface assignments, and the firewall rules page, which used to be called “Rules [new]” (OPNsense 26.7 release notes). Still on 26.1 or older? The settings are the same, but the screens differ in two places; each step says where.
What you gain, and what it costs
You gain fine-grained control over traffic between network zones. With OPNsense, you can separate personal, work, and IoT devices and explicitly decide which zone may or may not reach printers, NAS storage, the internet, or management interfaces.
The cost is that you are now maintaining a real network design. VLANs, firewall rules, switch ports, and access points all need to line up. A small mistake can easily make devices look offline or unexpectedly allow traffic you meant to block.
When this is overkill
If you are not already running OPNsense or only need basic isolation for guests and IoT, start with a guest network or a simpler router setup. This guide only makes sense once you intentionally want an administrator-style network layer and are willing to maintain it.
What you need
- OPNsense running on a Protectli Vault, mini-PC, or virtual machine
- A managed switch supporting 802.1Q VLANs (such as the TP-Link TL-SG108E)
- An access point that can broadcast multiple SSIDs (most modern APs support this)
Design: three zones
For most home users and home workers, three zones are sufficient:
| Zone | VLAN ID | Subnet | Use |
|---|---|---|---|
| Private | 10 | 192.168.10.0/24 | Laptops, phones, NAS |
| Work | 20 | 192.168.20.0/24 | Work laptop, work phone |
| IoT | 30 | 192.168.30.0/24 | Smart TV, printers, cameras, speakers |
On the cable between OPNsense and the switch, every VLAN goes tagged, with no untagged traffic alongside. OPNsense advises against mixing tagged and untagged on that link, because DHCP and other broadcasts can then leak between the networks (OPNsense manual).
Already have a network? Read this first
The steps below assume new subnets. If your home network currently runs as one flat LAN (for example 192.168.1.0/24 on port igb1), you will hit two things.
You can’t use the same subnet twice. Don’t give VLAN 10 192.168.1.1/24 as long as your LAN still has that subnet. Every interface needs its own network; a conflict breaks routing between the VLANs (OPNsense manual). Don’t count on an error message: we found no such check in the code of the 26.7.8 assignment screen.
You have two routes:
- New subnet for Private: follow the guide as written, with
192.168.10.0/24. This route needs a free network port on OPNsense as the parent for the VLANs (most mini-PCs and Protectli boxes have several): OPNsense wants the parent port of VLANs left unassigned, so don’t build them on the port your current LAN uses (OPNsense manual). Keep managing OPNsense through the old LAN until you have logged in from Private, then move your devices over. Devices with a fixed address or a DHCP reservation need setting up again in the new subnet. - Keep your existing subnet: move the LAN interface itself onto the VLAN instead of creating a new interface. This also works with a single LAN port. See below.
Moving your LAN to VLAN 10
- First download a backup of your configuration: System → Configuration → Backups (OPNsense manual: backups).
- Make sure you can reach the OPNsense console (keyboard and screen, or a serial cable). If you lose the web interface during the move, you can reassign the interfaces there.
- Create VLAN 10 on
igb1(step 1 below); it becomes the devicevlan0.10. - Go to Interfaces → Assignments, edit the LAN row and pick the new VLAN device (
vlan0.10) under Device instead ofigb1. Save and press Apply. The physical portigb1is then left unassigned; that is how OPNsense wants it. - Switch the switch over straight away (step 4): the port to OPNsense tagged VLAN 10, the device ports untagged VLAN 10 with PVID 10. Until that is done your network is briefly unreachable, so pick a quiet moment.
The LAN’s IP address, DHCP settings and firewall rules are set on the LAN interface, not on the physical port, so they move with it to the VLAN; that is the point of this route. In the rest of the guide your Private zone is then simply called LAN instead of PRIVATE: in step 2 you only add vlan0.20 and vlan0.30, and in step 3 LAN keeps its existing DHCP range.
Fixed DHCP reservations. If you already use the Dnsmasq DHCP server, your reservations move along with the LAN interface. If your OPNsense still runs the old ISC DHCP server (a separate plugin since 26.1, kept on systems that upgraded), you have to carry them over yourself: OPNsense’s documentation describes no automatic transfer. Re-enter them one device at a time under Services → Dnsmasq DNS & DHCP → Hosts (Host, IP addresses, Hardware addresses), then switch ISC DHCP off. Step 3 explains why.
Step 1 — Create VLANs in OPNsense
Go to Interfaces → Devices → VLAN.
Click + to add a VLAN:
- Device:
vlan0.10. Leave it empty and OPNsense makes up a name (vlan01,vlan02, …); a name with the tag in it is easier to recognise later. OPNsense accepts names that start withvlan0followed by digits and dots. - Parent: the physical interface going to your switch (e.g.
igb1orem1) - VLAN tag: 10
- Description: Private
Repeat for VLAN 20 (vlan0.20, Work) and VLAN 30 (vlan0.30, IoT). Press Apply.
Step 2 — Assign interfaces
Go to Interfaces → Assignments and click + for each new VLAN interface. In the dialog:
- Device:
vlan0.10 - Description:
PRIVATE(letters, digits and underscores only) - Enabled: checked
- IPv4 Configuration Type: Static IPv4
- IPv4 address:
192.168.10.1/24, the gateway address for that subnet
Repeat for vlan0.20 (WORK, 192.168.20.1/24) and vlan0.30 (IOT, 192.168.30.1/24). Save each one and press Apply.
On OPNsense 26.1 or older this happens in two places: on the Assignments page, use the “Assign a new interface” row (Device + Description, then Add), then open each interface under Interfaces → [PRIVATE] to tick Enable and set the IPv4 Configuration Type and address.
Step 3 — Enable DHCP per interface
OPNsense uses Dnsmasq for this. According to OPNsense, the old ISC DHCP server (Services → ISC DHCPv4) no longer receives updates or security patches; the setup wizard now configures Dnsmasq (OPNsense manual: Dnsmasq).
Go to Services → Dnsmasq DNS & DHCP → General:
- Enable: checked
- Interface: PRIVATE, WORK and IOT (the interfaces that get DHCP). LAN is already in this list on a fresh install: leave it there, or your old LAN stops getting addresses.
- DHCP register firewall rules: checked, so the firewall allows DHCP traffic on those interfaces
- Listen port: Unbound is OPNsense’s standard DNS server on port 53, so Dnsmasq must not use that port. A fresh install already has
53053here (OPNsense’s factory default); leave it. Is the field empty? Then set53053, the port OPNsense’s own example uses when Unbound forwards local host names to Dnsmasq, or0to switch off Dnsmasq’s DNS completely (OPNsense manual: Dnsmasq).
Then go to Services → Dnsmasq DNS & DHCP → DHCP ranges and create a range per interface:
- Interface: PRIVATE
- Start address:
192.168.10.100 - End address:
192.168.10.200
Repeat for WORK and IOT. Devices automatically get OPNsense as their gateway and DNS server.
If Dnsmasq doesn’t start, check whether ISC DHCP or Kea DHCP is still enabled. They block the port Dnsmasq needs.
Step 4 — Configure managed switch
On your managed switch, set per port whether it forwards a VLAN tagged or untagged.
Uplink port (to OPNsense): tagged for all VLANs (10, 20, 30), no untagged VLAN. If your switch can’t remove the untagged VLAN from that port, give the port an unused VLAN as its PVID (e.g. 3999) that you don’t use anywhere else. That is the workaround OPNsense itself recommends.
Access ports (for devices): untagged for that zone’s VLAN.
Port to the access point: untagged for the VLAN the AP itself is managed in, tagged for the other SSID VLANs. See step 5.
Example for TP-Link TL-SG108E (via web interface). Under VLAN → 802.1Q VLAN, set 802.1Q VLAN Configuration to Enable, then create VLANs 10, 20 and 30 and mark each port as Untagged, Tagged or Not Member (TP-Link user guide):
- Port 1 (uplink to OPNsense): tagged 10, 20, 30
- Ports 2–4 (private devices): untagged 10
- Ports 5–6 (work): untagged 20
- Port 7 (IoT): untagged 30
- Port 8 (access point): untagged 10, tagged 20 and 30
Then, under VLAN → 802.1Q PVID Setting, set the PVID (Port VLAN ID) per port to the corresponding VLAN (port 8: PVID 10). TP-Link accepts a PVID only for a VLAN that exists, so create VLAN 3999 first if port 1 needs the workaround above. By TP-Link’s description, all ports start in VLAN 1, and a port can only be taken out of VLAN 1 once it is a member of another VLAN; so first build VLANs 10-30, then set the ports to Not Member in VLAN 1.
Mind the management of the switch itself. Many cheap managed switches can only be reached via VLAN 1 or one particular VLAN. Check your switch’s manual for which VLAN its web interface listens on before you take VLAN 1 off ports, or you lock yourself out.
Step 5 — Configure access point (multiple SSIDs)
Configure your access point with three SSIDs. Most access points are managed through the untagged VLAN of their port (VLAN 10 here); the other SSIDs get a VLAN tag:
| SSID | VLAN ID in the AP | Wi-Fi password |
|---|---|---|
| Home_Private | none (untagged, lands in VLAN 10) | Strong password |
| Home_Work | 20 | Strong password |
| Home_IoT | 30 | Separate password |
On UniFi, an SSID gets a network rather than a VLAN number. With OPNsense as the router, first create a network per VLAN under Settings → Networks, choose Third-party Gateway as the router and enter the same VLAN ID (20, 30). Then pick that network in the Network dropdown of the WiFi under Settings → WiFi (UniFi: VLANs, UniFi: WiFi). On a standalone TP-Link EAP: Wireless → Wireless Settings, edit the SSID, Wireless VLAN ID (0 = no tag) (TP-Link); an EAP managed by Omada gets its SSIDs from the controller.
Step 6 — Set firewall rules
This is the critical part. A new interface blocks all traffic until it has a pass rule, so without rules its devices can’t even get online. But the “allow internet” rule they need has destination any, which includes your other VLANs. The block rules above it are what keep the zones apart.
Go to Firewall → Rules and pick the interface (for example IOT) in the interface filter at the top of the page. Click + to add a rule; the interface you picked is already filled in.
Order matters. OPNsense processes rules top to bottom and the first rule that matches decides (OPNsense manual: firewall). If “allow internet” (destination: any) sits at the top, it also matches traffic to your other VLANs and the blocks below it are never reached. A new rule always lands at the bottom of the list, so add the rules below in the order shown. To put a rule higher later, tick its checkbox and press the left-arrow button on the rule it should go above (tooltip: “Move 1 rule(s) before this rule in selection order”).
Leave the fields not listed at their defaults (Version: IPv4, Direction: In, Quick: on). In the Source and Destination lists, each interface appears as “PRIVATE network”, “WORK network” and so on.
On IOT, in this order:
- Allow DNS to OPNsense
- Action: Pass
- Protocol: TCP/UDP
- Source: IOT network
- Destination: This Firewall
- Destination Port:
53(DNS)
- Block IoT → OPNsense
- Action: Block
- Protocol: any
- Source: IOT network
- Destination: This Firewall
- Block IoT → private
- Action: Block
- Protocol: any
- Source: IOT network
- Destination: PRIVATE network
- Block IoT → work
- Action: Block
- Protocol: any
- Source: IOT network
- Destination: WORK network
- Allow internet
- Action: Pass
- Protocol: any
- Source: IOT network
- Destination: any
Rules 1 and 2 keep IoT devices away from OPNsense’s web interface, which they could otherwise open through their gateway address (192.168.30.1). DHCP keeps working: the automatic rules Dnsmasq creates (“DHCP register firewall rules” in step 3) come before your own rules.
Rule 5 allows every destination not blocked above it. That includes your old LAN if you keep it (192.168.1.0/24) and the network of your ISP’s modem on the WAN side. To close those too, use the alias below instead of rules 3 and 4.
On WORK, in this order:
- Block work → private: Action Block, Protocol any, Source WORK network, Destination PRIVATE network
- Allow internet: Action Pass, Protocol any, Source WORK network, Destination any
Want to keep WORK away from the management interface too? Put rules 1 and 2 from IOT at the top here as well, with Source WORK network. Manage OPNsense itself from PRIVATE.
On PRIVATE: one rule, Allow internet (Action Pass, Protocol any, Source PRIVATE network, Destination any). A new interface blocks everything until it has a pass rule. Moved your LAN to VLAN 10 instead? Then LAN already has the “Default allow LAN to any rule” from the factory configuration, which the setup wizard leaves in place, and you add nothing here.
Don’t lock yourself out. OPNsense puts an automatic “anti-lockout rule” on LAN, ahead of your own rules, so the web interface (and SSH, if on) stays reachable from there. PRIVATE doesn’t get it: there, only your pass rule lets you in, so never put a block on This Firewall on PRIVATE. Without a LAN interface, the rule moves to the optional interface with the lowest number, which may be a zone you want closed; so keep LAN assigned until you have logged in from PRIVATE. If you do lose access, the console (see above) still works.
Press Apply when the rules are in place.
Alternative: use aliases
Create an alias RFC1918 under Firewall → Aliases (Type: Network(s)) with the private subnets 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16. Then on IOT, replace rules 3 and 4 with one block: source = IOT network, destination = RFC1918. This blocks all inter-LAN traffic in a single rule, including an old LAN and your ISP modem’s network. Note: that rule also blocks DNS to OPNsense itself, because the IoT gateway address (192.168.30.1) is in RFC1918 too. The “Allow DNS to OPNsense” rule covers that, as long as it sits above the alias block.
Upgraded from 26.1 or older? Your existing rules keep working. OPNsense 26.7 moved the old rules pages to the os-firewall-legacy plugin and shows a Migration assistant under Firewall to move them to the new page (release notes). On 26.1 itself, the old pages are still Firewall → Rules → [interface] and the new page is “Rules [new]”.
Step 7 — Testing
Test isolation: Connect a laptop to the IoT Wi-Fi. Open the web page of a device in Private, such as your NAS at its 192.168.10.x address: this must fail, while it does work from Private. Don’t test this with ping 192.168.10.1: that address belongs to OPNsense itself, so rule 2 blocks it even if rule 3 is wrong.
Try ping 8.8.8.8 — this must work (internet).
From the same laptop, open https://192.168.30.1 — the OPNsense login page must not load. A website like example.com must load (DNS works).
Test DHCP: Connect a device to each Wi-Fi network. Verify it gets an IP address in the correct subnet.
Optional: DNS per zone
OPNsense can offer different DNS servers per interface. This lets you run a DNS filter like AdGuard Home or Pi-hole on the IoT interface, while the private zone uses regular DNS.
Go to Services → Dnsmasq DNS & DHCP → DHCP options and add an option: Type Set, Option dns-server [6], Interface IOT, Value: the IP address of your DNS filter. If that filter sits in another VLAN (for example Private), add a rule on IOT that allows DNS (port 53, Protocol TCP/UDP) to exactly that address and move it above the blocks; otherwise your own IoT → private rule blocks the DNS requests.
Scenario: WORK VLAN for SSH access to production
If you have SSH access to production environments from home — servers, cloud infrastructure, a VPN to the office — your home network is part of your employer’s attack surface. A compromised IoT device or an infected personal laptop on the same network can act as a stepping stone to your work traffic.
The WORK VLAN from the configuration above solves this. These are the additional steps:
Step 1 — Only the work laptop on VLAN 20
Connect your work laptop to the Home_Work SSID (VLAN 20), or plug it into switch ports configured as untagged VLAN 20. All other devices — personal laptop, phone, IoT — stay on other VLANs.
Step 2 — Firewall: block PRIVATE and IoT → WORK
On the PRIVATE interface, add:
- Action: Block
- Protocol: any
- Source: PRIVATE network
- Destination: WORK network
- Description: Block private → work
This rule must sit above the allow-internet rule on PRIVATE, otherwise that rule matches first and the block never applies. A new rule lands at the bottom, so tick its checkbox and press the left-arrow button on the allow-internet rule. After moving your LAN, move it above the “Default allow LAN to any rule” the same way; that default rule is at the very top. This prevents a compromised personal device from moving laterally into your work traffic.
Step 3 — Outbound NAT for SSH tunnels
SSH connections to production go via the WORK subnet. OPNsense NAT ensures outbound traffic from 192.168.20.0/24 uses the correct external IP. Check: Firewall → NAT → Source NAT (on 26.1 and older: Firewall → NAT → Outbound). With the default mode, “Automatic Source NAT rule generation”, all VLANs are already included.
Step 4 — No personal DNS filter on WORK
If you gave WORK your AdGuard Home or Pi-hole as DNS server (the optional DNS per zone above), consider giving the WORK VLAN a direct DNS server instead (e.g. 9.9.9.9) so work-related DNS queries don’t pass through a personal filter. Without that option, WORK uses OPNsense itself as its DNS server and there’s nothing to change.
Step 5 — Tailscale or WireGuard on the work laptop
If you connect to the office via VPN, that runs over the WORK VLAN. Your firewall rules block personal devices on PRIVATE and IoT from reaching the work laptop, so they can’t get at the tunnel through it.
Result: your personal devices and IoT have no path to your work traffic — even if one of them gets compromised.
Next step
Go further
- Tailscale mesh VPN guide — reach this segmented home network safely from outside
- Network segmentation with VLANs at home — OpenWrt/GL.iNet variant
- GL.iNet travel router setup — simpler alternative
Profiles
- Profile: IT professional — context for this level of network control