Most home networks grow the same way. One router serves one flat subnet, and every device from the laptop to the smart plug to the NAS shares the same broadcast domain. A compromised camera can then probe your file server, and a misbehaving IoT gadget can see everything your personal machines see. This guide is for home lab operators and self-hosters who want to fix that in one afternoon. You will split the network into VLANs for trusted devices, IoT devices, and servers, route them through an OPNsense firewall, write rules that enforce the boundaries, and then test that the isolation holds.
Before you start
- OPNsense installed on a dedicated box or virtual machine, with at least two network interfaces (one for WAN, one for the LAN trunk to your switch).
- A managed switch that supports 802.1Q VLAN tagging, or an access point and switch whose VLAN settings you can change.
- Administrator access to the OPNsense web interface, plus a console or keyboard and monitor for recovery if you lock yourself out.
- A current configuration backup. Download it from System, then Configuration, then Backups.
- At least one device you can use as a test client on the trusted network.
- A written addressing plan (see step 1). Substitute your own subnets wherever the examples use 10.10.x.x.
1. Write down your addressing plan
Decide on the VLAN IDs and subnets before you touch any settings. Keeping a plain list prevents overlapping ranges and makes firewall rules easier to read later. This guide uses the following layout. Replace the values with your own if you already have devices on a different range.
VLAN 10 TRUSTED 10.10.10.0/24 gateway 10.10.10.1 laptops, desktops, phones
VLAN 20 SERVERS 10.10.20.0/24 gateway 10.10.20.1 NAS, Docker host, self-hosted apps
VLAN 30 IOT 10.10.30.0/24 gateway 10.10.30.1 cameras, plugs, speakers, TVs
Use your own internal domain name wherever a local hostname is needed, for example YOUR_DOMAIN.lan. Do not reuse your ISP’s address range or any subnet already in use on the WAN side.
2. Create the VLAN interfaces in OPNsense
VLANs in OPNsense sit on top of a physical parent interface. Go to Interfaces, then Other Types, then VLAN, and click Add. For each network:
- Set Parent to the physical LAN port that connects to your switch (for example igb1, em1, or vtnet1, depending on your hardware).
- Set VLAN tag to the ID from your plan (10, 20, or 30).
- Set Description to TRUSTED, SERVERS, or IOT so the interface names are clear in logs and rules.
- Save, then repeat for the other two VLANs.
Nothing is routed yet. The VLANs exist only as tagged interfaces that you will assign in the next step.
3. Assign and address each VLAN
Go to Interfaces, then Assignments. In the new device dropdown, choose each VLAN device (for example vlan0.30) and click Add. Then open each new interface from the Interfaces menu and configure it:
- Check Enable interface.
- Set IPv4 Configuration Type to Static IPv4.
- Enter the gateway address for that VLAN, such as
10.10.30.1/24for IoT. - Save and apply the changes.
Give each interface a clear name (OPT1, OPT2, and so on are renamed to something like IOT). This makes rules and logs easy to read.
4. Set up DHCP for each VLAN
Each segment needs its own address pool. Go to Services, then DHCPv4 (the exact menu name depends on your OPNsense version), and select each interface. For every VLAN:
- Enable DHCP on that interface.
- Set the range to the upper part of the subnet, for example 10.10.30.100 to 10.10.30.199 for IoT. Leave the lower addresses free for static assignments.
- Set the DNS server to the interface address of the firewall (for example 10.10.30.1). This keeps DNS queries inside the firewall, where you can log and control them.
- For servers, add static mappings by MAC address so your NAS and Docker host always get the same address.
5. Configure the switch and access points
OPNsense only sees the tags your switch sends it, so the switch side must match. The exact commands depend on the vendor, but the design is the same everywhere:
- Uplink port to OPNsense: tagged (trunk) for VLANs 10, 20, and 30. It should carry all three tagged and should not carry an untagged native VLAN unless you have a specific reason.
- Port to a trusted device: untagged access port on VLAN 10.
- Port to a server: untagged access port on VLAN 20.
- Port to an IoT device: untagged access port on VLAN 30.
- Access points: create one SSID per segment and map each SSID to its VLAN ID. Keep the IoT SSID separate from your primary SSID, even if the devices are not particularly sensitive.
After you save the switch config, check that the uplink port is tagged on all three VLANs. If one is missing, the matching devices will get no address or the wrong one.
6. Create aliases for your networks
Aliases let you write rules in plain language and update them in one place. Go to Firewall, then Aliases, and add the following entries, each as type Network(s) unless noted:
TRUSTED_NET 10.10.10.0/24
SERVER_NET 10.10.20.0/24
IOT_NET 10.10.30.0/24
PRIVATE_NETS 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
NAS_HOST 10.10.20.5 (type Host)
PRIVATE_NETS covers every RFC 1918 range, so one rule can block all internal traffic while still allowing the internet. Adjust NAS_HOST to whatever address your file server actually uses.
7. Write the firewall rules
OPNsense evaluates rules on each interface from top to bottom and stops at the first match. Rules apply to traffic entering the firewall on that interface, so you write each segment’s rules on its own interface tab. New interfaces start with no pass rules, which means everything is blocked by default. That is the behavior you want, but you must explicitly allow DNS and DHCP or the segment will appear broken.
Create the rules in this order on each interface. Enable logging on the block rules so you can see what is being stopped.
IOT (VLAN 30): internet only
1. Pass IOT_NET -> This Firewall TCP/UDP port 53 DNS
2. Pass IOT_NET -> This Firewall UDP port 67 DHCP
3. Block IOT_NET -> PRIVATE_NETS any log
4. Pass IOT_NET -> any any internet
Rule 1 lets IoT devices use the firewall as their resolver and nothing else on the firewall, so the web interface and SSH are unreachable from this segment. Rule 3 stops IoT devices from reaching any other internal network, and rule 4 allows everything else, which is effectively internet access.
SERVERS (VLAN 20): reachable from trusted, outbound internet only
1. Pass SERVER_NET -> This Firewall TCP/UDP port 53 DNS
2. Pass SERVER_NET -> This Firewall UDP port 67 DHCP
3. Block SERVER_NET -> PRIVATE_NETS any log
4. Pass SERVER_NET -> any any internet
Servers can answer requests from trusted clients because the firewall tracks connection state, so return traffic for allowed sessions passes automatically. A server cannot start new connections into IoT or trusted networks.
TRUSTED (VLAN 10): management and access
1. Pass TRUSTED_NET -> any any full access
Trusted devices can reach servers and IoT devices for management. Because IoT and server rules block them from starting connections back into trusted space, a compromised IoT device cannot pivot into your laptops. If you want stricter access, replace rule 1 with narrower pass rules, such as allowing TRUSTED_NET to reach NAS_HOST on ports 443 and 445, and keep the block rules in the other segments as they are.
Finally, restrict access to the firewall itself. Go to System, then Settings, then Administration, and set the web interface to listen only on the TRUSTED interface. Then make sure the WAN interface does not expose the management page.
Verify it worked
A firewall is only as good as its tests. Run each of these checks from the device named in the step, and do not skip the negative tests, since those are the ones that prove isolation.
- Addressing: Confirm each device received an address from the correct range. On a Linux client, run
ip -br addrand check that the address matches its VLAN subnet. A device on the wrong subnet usually means a switch port is untagged on the wrong VLAN. - Internet from IoT: From an IoT device or a test host on VLAN 30, run
ping -c 3 1.1.1.1andnslookup example.com 10.10.30.1. Both should succeed. - IoT cannot reach trusted: From the same IoT host, run
ping -c 3 10.10.10.10(or any trusted device). It should fail with no reply. - IoT cannot reach servers: From the IoT host, run
nmap -Pn -p 22,80,443,445 10.10.20.5. All ports should show as filtered or closed. - IoT cannot reach the firewall UI: From the IoT host, run
curl -k -m 5 https://10.10.30.1. It should time out. - Trusted reaches servers: From a trusted client, run
curl -k -m 5 https://10.10.20.5or open the NAS in a browser. It should respond. - Trusted reaches IoT for management: From the trusted client, run
ping -c 3 10.10.30.150against a known IoT device. It should succeed. - Logs show blocks: Go to Firewall, then Log Files, then Live View, and filter by the IOT interface while repeating step 3. You should see blocked entries that match rule 3.
If every positive test passes and every negative test fails as described, the segmentation is working.
Common mistakes
- Forgetting the DNS and DHCP pass rules. Without them, IoT devices get no address or cannot resolve names, and the problem looks like a broken device rather than a firewall rule.
- Putting the block rule below the pass-to-any rule. Rules are evaluated top to bottom, so a pass rule above a block rule wins. Check the order after every edit.
- Writing rules on the wrong interface. A rule on the TRUSTED tab does not restrict traffic from IOT. Each rule belongs on the interface where the traffic enters.
- Assuming stateful means inbound is open. Stateful tracking only allows replies to connections that a client started. It does not let outside or other-segment devices start connections to yours.
- Leaving the switch uplink untagged. If the uplink carries an untagged VLAN, traffic can land on the wrong segment. Make all three VLANs tagged on the trunk.
- Using a single SSID for everything. If the IoT devices share the primary Wi-Fi, a shared password means they are not really isolated. Map each SSID to its own VLAN.
- Locking yourself out. Apply changes one interface at a time and keep a console session open. If you change management access, confirm you can still reach the web interface from the trusted network before closing your session.
- Overlapping DHCP ranges and static addresses. If a DHCP pool includes a reserved address, two devices can end up with the same IP.
Takeaway
Segmentation turns a single compromised device from a full network breach into a contained incident. You now have three VLANs, a firewall that enforces the boundaries with explicit rules, and a set of tests that prove the walls hold. Review the rules when you add new devices, keep the logs readable, and rerun the negative tests after any firewall or switch change. The network will stay understandable as it grows, which is the real payoff.
