BlogNetworking
NetworkingSegmenting a Homelab with OPNsense and VLANs
A practical VLAN plan for a small lab: management, compute, storage, and services, with OPNsense interface, DHCP, and easy-to-audit firewall rules.
- Published
- Updated
- Reading time
- 8 min read
- Category
- Networking
- opnsense
- vlan
- firewall
- segmentation
On this page
A lab that shares one flat LAN is easy to stand up and hard to reason about later. Guest networks, storage traffic, and admin interfaces end up in the same broadcast domain, and a single misconfigured VM can talk to everything. The fix is not a dozen exotic zones. It is a small, documented VLAN plan with policy enforced at the gateway.
This note is the pattern I use on a compact rack: fiber WAN into OPNsense, a tagged 10 Gbps trunk to a managed core switch, and four VLANs that cover almost every port in the closet.
The four-VLAN map
I keep the numbering boring and stable so documentation, switch ports, and firewall rules all say the same thing:
- VLAN 10 — Management (
10.10.10.0/24). Switches, iDRAC/iLO, OPNsense LAN, hypervisor management. No general-purpose guests live here. - VLAN 20 — Compute (
10.10.20.0/24). Proxmoxvmbrnetworks for most virtual machines. Cluster traffic (Corosync) stays on this VLAN in this design. - VLAN 30 — Storage (
10.10.30.0/24). NFS and iSCSI only. No default route if I can avoid it; the NAS and hypervisors meet here and almost nowhere else. - VLAN 99 — Services (
10.10.99.0/24). DNS, monitoring, and other always-on utilities that many VLANs need to reach, narrowly.
The WAN interface is untagged and untrusted. Nothing from VLANs 10, 20, 30, or 99 is allowed out without an explicit rule, and nothing from the WAN is allowed in except the VPN endpoints I actually use.
OPNsense interfaces
On the firewall the physical LAN NIC is a 10 GbE SFP+ uplink. The VLAN interfaces are parented to that NIC, then assigned under Interfaces → Assignments. A typical config.xml fragment looks like this after the assignments exist:
<vlan>
<if>ix0</if>
<tag>10</tag>
<vlanif>ix0_vlan10</vlanif>
<descr>MGMT</descr>
</vlan>
I give each VLAN a short description (MGMT, COMPUTE, STORAGE, SERVICES) and a static IPv4 address on .1. DHCP is enabled only where endpoints actually need it — usually compute and services, not storage or management devices that should be reserved or static.
Trunk on the core switch
The switch port facing OPNsense is a tagged trunk for 10, 20, 30, and 99. Management of the switch itself lives on VLAN 10. Access ports are untagged members of a single VLAN unless the attached host is a hypervisor or the NAS, which get trunks.
A UniFi-style port profile is enough: Trunk: OPNsense tagged 10/20/30/99, and Access: Services untagged 99 for the DNS and monitoring VMs when they are on discrete NICs. For Proxmox, the guest bridge is a trunk so VM NICs can be placed on a VLAN without recabling.
Firewall rules that stay auditable
The default deny on each VLAN interface is the feature, not an inconvenience. I add a short, named set of rules and I try not to invent one-off exceptions. A representative policy:
MGMT -> any : allow HTTPS/SSH to known infra, deny the rest
COMPUTE -> SERVICES : allow DNS (53) and VPN-bound internet via WAN
COMPUTE -> STORAGE : allow NFS/iSCSI only to 10.10.30.10
STORAGE -> any : deny; replies follow state
SERVICES -> WAN : allow HTTPS for updates and DoT fallback
SERVICES -> COMPUTE : allow Prometheus scrape ports only
any -> MGMT : deny, except jump hosts I name explicitly
OPNsense rule order is first-match, so I keep the allow list tight and put a log-enabled deny at the bottom of each interface while I am still proving the design. Once the logs are quiet, the default deny is enough.
Floating rules are tempting and I almost never use them here. Per-interface rules are easier to read six months later.
DNS, DHCP, and a quick sanity check
DHCP on compute and services hands out 10.10.99.53 as the resolver (AdGuard in front of Unbound). Management devices get reserved addresses and the same resolver so firmware updates do not depend on a random public DNS.
After a change I verify three things before I walk away:
# From a compute guest: DNS works, storage is reachable, management is not.
dig @10.10.99.53 lab.internal +short
showmount -e 10.10.30.10
ping -c 2 10.10.10.2 # should fail unless this host is supposed to manage the switch
If those three answers are right, the VLAN plan is doing its job. The rest is documentation: a table of VLAN, subnet, gateway, and purpose living next to the topology, not only in the firewall UI.