From Flat LAN to Zero Trust: A Complete UniFi VLAN Segmentation & Firewall Deep Dive
For years, many homelabs operate on what network engineers affectionately call "The M&M Network": a hard, crunchy exterior (your edge router and firewall) and a soft, chewy interior where everything lives flat on a single /24 subnet.
On a flat network, smart light bulbs, random IoT gadgets, Wi-Fi cameras, your primary workstation, and high-performance storage arrays all share the same broadcast domain. If an unpatched microcontroller in a smart plug is compromised, or an outdoor camera cable is tapped, the attacker is already inside the perimeter—free to ping your NAS, probe SSH ports, or listen to unencrypted multicast chatter.
Recently, I completed an overhaul of my homelab infrastructure: segmenting a 10G/20G optical spine into four air-gapped Layer-2/Layer-3 security zones with strict, stateful firewall policies.
Here is an architectural walkthrough of how we planned, implemented, and verified this migration—and why separating your network doesn't have to compromise 10G throughput.
(You can explore the interactive topology diagram of this architecture live at lab.fahim.ca).
1. The 4-Tier Security Zone Architecture
Rather than creating dozens of micro-subnets that complicate routing, we grouped the infrastructure into four functional tiers aligned to IEEE 802.1Q VLAN IDs and a clean RFC 1918 Class B addressing schema:
Why VLAN 2 for Core Management?
A common design trap is attempting to assign infrastructure hardware to "VLAN 0" or leaving switches on untagged VLAN 1. Under the IEEE 802.1Q standard, VLAN ID 0 is strictly reserved for 802.1p priority-tagged frames with no VLAN identity. UniFi Network properly rejects VLAN 0, so VLAN ID 2 (172.16.2.0/24) was established as the dedicated, isolated management plane.
2. The Zero-Trust Policy Matrix (UniFi v2 Policy Engine)
VLANs only define Layer-2 broadcast boundaries. Without firewall rules, a router will route traffic between subnets by default.
Using UniFi's zone-based v2 policy engine, we deployed a stateful firewall chain evaluated in strict priority order:
| Rule Index | Policy Name | Action | Source Enclave | Destination Enclave | Purpose & Security Enforcement |
|---|---|---|---|---|---|
| 10000 | Allow LAN to IoT | ALLOW | Trusted (172.16.1.0/24) |
IoT (172.16.10.0/24) |
Permits trusted endpoints to manage smart home appliances; auto-creates conntrack state for return traffic. |
| 10001 | Allow Admin to Core | ALLOW | Admin IPs (.3, .116) |
Core (172.16.2.0/24) |
Exclusive management ingress to switch and AP control interfaces from authorized workstations. |
| 10002 | Block All to Core | BLOCK | ANY Internal Source |
Core (172.16.2.0/24) |
Protects switch and AP operating systems against lateral compromise or scanning. |
| 10003 | Allow Viewers to Security | ALLOW | Authorized Viewers (.3, .111, .116, .142, .191) |
Security (172.16.3.0/24) |
Enables authorized family endpoints to view live Protect video feeds on UNVR. |
| 10004 | Block All to Security | BLOCK | ANY Internal Source |
Security (172.16.3.0/24) |
Surveillance Shield. Drops IoT, guest, and untrusted endpoints. |
| 40000 | Block IoT Outbound | BLOCK | IoT (172.16.10.0/24) |
ANY Internal Zone |
Evaluates after stateful return (Index 30000); drops all unsolicited smart home connections to private LAN. |
The Principle of Asymmetric Ingress
Notice the relationship between rules 10003 and 40001:
- An authorized phone or tablet in
Trustedcan open the Protect app and initiate a connection to the NVR (172.16.3.2). The gateway establishes a stateful tracking entry (30002), allowing live video frames to return. - However, if an outdoor camera is physically disconnected or tampered with, rule
40001immediately drops any packet that the camera port attempts to initiate intoTrustedorCore. The surveillance enclave acts as a one-way mirror.
3. Implementation: Switch Port Overrides vs. Virtual Network Overrides (VNO)
Assigning wired equipment to VLANs is straightforward: you assign a native switch port profile. But how do you handle wireless cameras without broadcasting a separate SSID for every security tier?
1. Physical Switch Port Overrides (Wired Endpoints)
For fixed infrastructure, switch ports on the core switches (Grand Central and edge Flex switches) were locked to specific native networks:
- Port 20 (UNVR Gen 2): Native VLAN 3 (
Security) - Port 4 (PoE Doorbell): Native VLAN 3 (
Security) - Port 1 (Smart PDU): Native VLAN 2 (
Core) - Port 21 (Secondary NAS): Native VLAN 1 (
Trusted)
Any rogue device plugged into Port 4 or Port 20 is immediately quarantined into the air-gapped Security enclave with zero access to compute or management.
2. Virtual Network Overrides (VNO for Wireless Cameras)
Broadcasting multiple SSIDs introduces radio beacon overhead, consuming valuable 2.4 GHz and 5 GHz airtime. Instead, we leveraged UniFi's Virtual Network Override (VNO):
- All wireless cameras associate with the primary Wi-Fi 7 SSID (
Primary-WLAN). - At the access point level, the AP inspects the camera's MAC address and dynamically tags its traffic onto VLAN 3, bypassing the native VLAN 1 bridge entirely.
- The camera receives a DHCP lease in
172.16.3.0/24and is instantly bound by Policy40001.
4. Performance Analysis: Did VLAN Routing Kill 10G Speeds?
The most common hesitation in homelab VLAN segmentation is the fear of bottlenecking high-speed storage transfers through the router's CPU.
Layer-2 Hardware Switching (0% CPU Overhead)
Our primary media compute engine and 126TB 7-bay storage array (NASferatu) both reside on VLAN 1 (Trusted).
- Because they share the same subnet, their 10G SFP+ optical links and 20G LACP bonded trunk switch directly at Layer 2 hardware line-rate through the 8-port 10G optical core (
Funnel). - Gateway CPU Impact: 0%. Intranet NFSv3 and SMB 3.1.1 transfers never touch the UDM Pro Max routing engine or firewall pipeline.
Inter-VLAN Surveillance Overhead (<1% CPU Overhead)
Traffic only crosses the router when crossing enclave boundaries (e.g., streaming cameras from Trusted).
- Seven active 2K and 4K cameras generate roughly 20–50 Mbps of aggregate H.264/H.265 video.
- The UDM Pro Max provides 5,000 Mbps (5 Gbps) of routing throughput with full Intrusion Prevention (IPS) active.
- Inter-VLAN camera traffic consumes less than 1% of gateway capacity.
5. Explore the Architecture Live
If you'd like to see how this entire switching hierarchy, optical backbone, port allocation, and power distribution fits together visually: