Homelab Networking — VLANs, DNS, and Firewall Rules That Actually Work

Split a flat home network into VLANs for trusted devices, IoT, guests and servers, then add pfSense firewall rules and Pi-hole DNS filtering that actually isolate them.

A Mohammed Habib Sep 01, 2026 17 min read 129 views Updated Oct 24, 2026
Cover for Homelab Networking — VLANs, DNS, and Firewall Rules That Actually Work

Most home networks are flat: every device sits on the same network and can talk to every other device. That means the cheap smart plug on your shelf can reach your NAS, and a guest's laptop can open your router's admin page.

In this guide I split a homelab into separate networks for trusted devices, IoT gadgets, guests, management and servers. Then I add a firewall to control what can talk to what, and Pi-hole to filter DNS for the whole house. None of it needs a $2000 enterprise switch.

What you need

  • A router that can run pfSense or OPNsense (a small PC with two network ports works), or another router with VLAN support.
  • A managed switch (one with a web interface and VLAN settings).
  • A Wi-Fi access point that supports several network names (SSIDs) with VLAN tags.
  • A Raspberry Pi, a Docker host or a small VM for Pi-hole.
  • Basic networking knowledge: you know what an IP address is and how to log in to a router's web page.

Budget is roughly $200–$800 depending on the hardware you pick.

A few terms first

  • Subnet: a range of IP addresses that belong together, written like 192.168.10.0/24. The /24 means the first three numbers are fixed, so this subnet covers 192.168.10.1 to 192.168.10.254.
  • VLAN (virtual LAN): a way to run several separate networks over the same cables and switch. Each VLAN has a number (its tag or ID) and usually its own subnet.
  • Tagged / untagged: on a link that carries several VLANs, each packet gets a small label with its VLAN number. That's "tagged." One VLAN per port can travel without a label, "untagged," which is what normal devices expect.
  • Trunk port: a switch port that carries several VLANs at once, usually tagged. You use it to connect the switch to the router or to an access point.
  • Access port: a switch port that belongs to exactly one VLAN, untagged. Plug a normal device in and it lands on that VLAN without knowing VLANs exist.
  • PVID: the VLAN a port puts untagged traffic into.
  • RFC1918: the three private IP ranges used inside home and office networks: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. "Block RFC1918" means "block everything local."
  • DNS: the system that turns names like example.com into IP addresses.

The plan

Components VLANs + DNS (Pi-hole/AdGuard Home) + Firewall (pfSense/OPNsense/Ubiquiti)
Purpose Network segmentation, DNS filtering, and access control
Hardware Managed switch + router/firewall + AP
Budget $200–$800 (depending on hardware choices)
Topology Single-router with VLAN trunking to a managed switch

Network design

VLAN Name Subnet Purpose
1 Trusted 192.168.1.0/24 Laptops, phones, workstations
10 IoT 192.168.10.0/24 Smart home devices, cameras
20 Guest 192.168.20.0/24 Guest Wi-Fi, visitors
30 Management 192.168.30.0/24 Switches, APs, router admin
40 Servers 192.168.40.0/24 Homelab servers, NAS, VMs

The router gets the .1 address in each subnet and routes between them. The firewall decides which of those routes are allowed.

Why a flat network is a problem

When everything shares one subnet:

  1. Any device can reach any other. Your $15 smart plug can scan your database server.
  2. Nothing filters the traffic. A hacked IoT device becomes a stepping stone into everything else.
  3. You have no DNS control. Devices phone home to ad servers, trackers and malware command servers.
  4. Busy devices affect everyone. A camera streaming 40 Mbps of video shares the same network as your workstation.

VLANs split the network up. Firewall rules decide what may cross between the pieces. DNS filtering cuts off ads and known-bad domains.

PACKET ANALYSIS
Flat Network
VLAN-Segmented Network
VLAN 1 (Trusted)
192.168.1.0/24
VLAN 10 (IoT)
192.168.10.0/24
VLAN 20 (Guest)
192.168.20.0/24
VLAN 30 (Mgmt)
192.168.30.0/24
VLAN 40 (Servers)
192.168.40.0/24

Step 0: Pick the hardware

Component Recommended Budget Option
Router/Firewall Ubiquiti USG or pfSense box TP-Link ER605
Managed Switch Ubiquiti USW-Lite-16-PoE TP-Link TL-SG108E
Access Point Ubiquiti U6 Lite TP-Link EAP245
DNS Pi-hole on Raspberry Pi or Docker Pi-hole in VM

Why a managed switch?

An unmanaged switch treats every port the same and knows nothing about VLANs. A managed switch lets you:

  • put each port into a specific VLAN,
  • create trunk ports that carry several VLANs over one cable,
  • control which devices can use which port.

The budget TL-SG108E has 8 ports, so you'll need to squeeze the port plan below onto fewer ports.

Step 1: Router and firewall (pfSense or OPNsense)

I'll use pfSense menu names here. OPNsense has the same ideas under slightly different menus.

Install pfSense

  1. Download the installer from pfsense.org.
  2. Write it to a USB stick, boot the router PC from it and install to the internal drive.
  3. Assign interfaces: WAN (the port to your internet modem) and LAN (the port to your switch, which becomes the Trusted network).

Check it: plug a laptop into the LAN side and open https://192.168.1.1. You should see the pfSense login page.

Create the VLANs

Go to Interfaces → Assignments → VLANs and add one VLAN per row. The parent interface is the LAN port (em0 here; yours may be called something else, like igb1).

Parent Interface VLAN Tag Description
em0 (LAN) 10 IoT
em0 (LAN) 20 Guest
em0 (LAN) 30 Management
em0 (LAN) 40 Servers

VLAN 1 doesn't need an entry. It's the untagged traffic on the LAN port itself.

Turn each VLAN into an interface

Go back to Interfaces → Assignments, add each new VLAN from the "Available network ports" list, then open each one, tick Enable, set IPv4 Configuration Type to Static IPv4 and give it the router's address:

Interface Name IPv4 Address
VLAN 10 IoT 192.168.10.1/24
VLAN 20 Guest 192.168.20.1/24
VLAN 30 Management 192.168.30.1/24
VLAN 40 Servers 192.168.40.1/24

Hand out addresses with DHCP

DHCP is what gives a device its IP address automatically when it joins a network. Each VLAN needs its own DHCP server, or devices on it get no address at all.

Go to Services → DHCP Server. There's a tab per interface. On each VLAN's tab, enable it and set a range, for example 192.168.10.100 to 192.168.10.199 for IoT. Point the DNS server at your Pi-hole once it exists (Step 3).

Firewall rules: how pfSense reads them

Two things about pfSense rules trip up almost everyone:

  • Rules go on the interface where traffic enters. To control what IoT devices can reach, you edit the rules on the IoT tab, not on the Servers tab.
  • Rules are read top to bottom, and the first match wins. Order matters. Anything that matches no rule is blocked by a hidden default-deny rule.

So the block rule for local networks must sit above the broad "allow internet" rule. If you put "allow any on port 443" first, IoT devices could reach port 443 on your servers too.

Firewall → Rules → IoT (VLAN 10)

Action Source Destination Port Description
Allow IoT net DNS server 53 DNS resolution
Block IoT net RFC1918 * Block IoT from reaching internal networks
Allow IoT net Any 80, 443 HTTP/HTTPS to the internet
Block IoT net * * Block all else

Firewall → Rules → Guest (VLAN 20)

Action Source Destination Port Description
Allow Guest net DNS server 53 DNS resolution
Block Guest net RFC1918 * No internal access
Allow Guest net Any 80, 443 HTTP/HTTPS only
Block Guest net * * Block all else

The easy way to make "RFC1918" a destination is an alias: under Firewall → Aliases, create one called RFC1918 with the three private ranges listed above, then pick it in the rule.

Firewall → Rules → Servers (VLAN 40)

Action Source Destination Port Description
Allow Servers net Any * Full access (trusted)

Firewall → Rules → LAN (Trusted, VLAN 1)

Action Source Destination Port Description
Allow Trusted net Any * Trusted can reach servers and everything else

The original version of this table put "IoT cannot reach servers" and "Guest cannot reach servers" on the Servers tab. Those rules would never match, because IoT and Guest traffic enters on its own interface. The RFC1918 block rules on the IoT and Guest tabs already do that job.

pfSense remembers connections, so when a trusted laptop opens a connection to an IoT device, the reply is allowed back automatically. You don't need a separate rule for return traffic.

Step 2: Configure the managed switch

Create the VLANs

In the switch's web interface (often under Switch Settings → VLANs or similar), create:

VLAN ID Name
1 Trusted (default)
10 IoT
20 Guest
30 Management
40 Servers

Assign the ports

Port Mode VLANs Device
1 Trunk 1, 10, 20, 30, 40 Router (uplink)
2–4 Access 1 (Trusted) Workstations
5–6 Access 10 (IoT) Smart plugs, cameras
7 Trunk 1 untagged; 10, 20 tagged Access point
8 Access 30 (Mgmt) Management devices (e.g. Pi-hole host)
9–12 Access 40 (Servers) NAS, Proxmox, servers

The access point gets a trunk port because it broadcasts several Wi-Fi networks, each on its own VLAN (Step 5). The original plan had the AP on a single-VLAN access port, which can't carry the IoT and Guest SSIDs.

Trunk port to the router

Port 1 carries every VLAN between switch and router:

Port 1: Mode=Trunk, PVID=1, Tagged=10,20,30,40

Check it: plug a laptop into port 5 (IoT). It should get a 192.168.10.x address. On port 2 it should get 192.168.1.x. If it gets nothing, the VLAN or DHCP setup is wrong. See Troubleshooting.

Step 3: Pi-hole for DNS filtering

Pi-hole is a DNS server that refuses to resolve ad, tracker and malware domains. Every device that uses it as its DNS server gets the filtering, with no software on the device.

Install Pi-hole

Pick one of the two methods:

# On a Raspberry Pi or Docker host
curl -sSL https://install.pi-hole.net | bash

# Or with Docker
docker run -d \
  --name pihole \
  -p 53:53/tcp -p 53:53/udp \
  -p 8053:80 \
  -e TZ=America/New_York \
  -e FTLCONF_webserver_api_password=your_admin_password \
  -e FTLCONF_dns_listeningMode=ALL \
  -v pihole:/etc/pihole \
  --restart unless-stopped \
  pihole/pihole:latest

The Docker image is Pi-hole v6, which replaced the old WEBPASSWORD variable with FTLCONF_webserver_api_password. If you leave it out, Pi-hole picks a random password and prints it in docker logs pihole. FTLCONF_dns_listeningMode=ALL comes from the official Docker example: by default Pi-hole only answers devices on its own subnet, and here the queries arrive from every VLAN.

Give the Pi-hole host a fixed IP. In my plan it lives on the management VLAN at 192.168.30.53.

Configure Pi-hole

  1. Open the admin page. With the script install it's http://PIHOLE_IP/admin. With the Docker command above, the web interface is mapped to port 8053, so use http://PIHOLE_IP:8053/admin.
  2. Go to Settings → DNS:
  3. Upstream DNS: Cloudflare (1.1.1.1) + Google (8.8.8.8)
  4. Enable conditional forwarding for local domains (explained below)

Conditional forwarding sends lookups for your local network back to the router. That lets Pi-hole show device names instead of bare IPs in its logs, using the names your router's DHCP server knows.

Block lists

Add these under Lists (called Adlists in older versions):

List URL Purpose
Steven Black's https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts Ads + malware
OISD https://big.oisd.nl Comprehensive blocking

Then update gravity (Pi-hole's name for its compiled blocklist) with pihole -g, or from Tools → Update Gravity in the web interface.

Names for your own services

Pi-hole can also answer for names you make up. In Pi-hole v6 this lives under Settings → Local DNS Records.

Domain IP Purpose
nas.home.arpa 192.168.40.10 TrueNAS
proxmox.home.arpa 192.168.40.20 Proxmox
homeassistant.home.arpa 192.168.10.50 Home Assistant
pihole.home.arpa 192.168.30.53 Pi-hole admin

I use home.arpa rather than .local. home.arpa is reserved (RFC 8375) for exactly this: names that only mean something inside a home network. .local is reserved for mDNS, the zero-config naming that Apple devices and Linux's Avahi use, and mixing the two causes lookups that work on one device and fail on another.

Finally, point each VLAN's DHCP server (pfSense, Services → DHCP Server) at 192.168.30.53 as the DNS server, so every device uses Pi-hole.

Step 4: The rules at a glance

Who can talk to whom

From To Allow Block
Trusted All Everything —
IoT DNS, Internet 53, 80, 443 All RFC1918
Guest DNS, Internet 53, 80, 443 All RFC1918
Management Trusted, Servers SSH, HTTP(S) —
Servers Trusted Everything —
Servers IoT, Guest Nothing All

The "Servers → IoT, Guest: block" row needs its own block rules on the Servers tab, placed above the "allow any" rule, if you want servers kept out of those networks.

Exceptions you'll probably need

Add each exception as a single allow rule, above the RFC1918 block rule on the interface where the traffic starts.

Scenario Rule
IoT camera → NAS (recording) Allow IoT:192.168.10.30 → Servers:192.168.40.10:554 (RTSP)
Guest → Printer Block Guest → Trusted (no printer access)
Proxmox → Internet Allow Servers → Internet (updates)
IoT → Home Assistant Allow IoT:192.168.10.0/24 → IoT:192.168.10.50:8123

One note on the last row: devices on the same VLAN talk to each other through the switch, not the router, so the firewall never sees that traffic. It works without a rule.

Step 5: Wi-Fi networks

One SSID per VLAN

An SSID is the network name you see in the Wi-Fi list. The access point tags each SSID's traffic with a VLAN.

SSID VLAN Password Purpose
HomeWiFi 1 (Trusted) Strong WPA3 Family devices
HomeWiFi_IoT 10 (IoT) Strong WPA2 Smart home devices
HomeWiFi_Guest 20 (Guest) Simple WPA2 Guests

IoT gets WPA2 because many cheap devices can't join WPA3 networks.

Ubiquiti example

Settings → WiFi → Create New Network

Network: HomeWiFi
VLAN: 1 (or untagged for default)
Security: WPA3-Personal

Network: HomeWiFi_IoT
VLAN: 10
Security: WPA2-Personal

Network: HomeWiFi_Guest
VLAN: 20
Security: WPA2-Personal
Guest Hotspot: Enabled

Check it: join HomeWiFi_Guest from a phone and look at its IP address. It should be 192.168.20.x.

Step 6: Test that it works

Test isolation

# From Trusted VLAN (192.168.1.x):
ping 192.168.10.1    # Should work (router)
ping 192.168.10.30   # Should work (Trusted may reach IoT)
ping 192.168.40.10   # Should work (NAS)

# From IoT VLAN (192.168.10.x):
ping 192.168.1.1     # Should fail (Trusted blocked)
ping 192.168.1.10    # Should fail (workstation blocked)
curl -I https://example.com   # Should work (Internet on 443)

Two things that look like failures but aren't:

  • The IoT rules only allow DNS, HTTP and HTTPS, so ping 8.8.8.8 from IoT fails by design. Ping uses ICMP, which isn't on the list. Test internet access with curl instead, or add an ICMP allow rule if you want ping.
  • Many IoT devices and cameras ignore ping completely, even when the network path is open.

Test DNS filtering

# From any device:
nslookup ads.google.com
# Should return 0.0.0.0 (blocked)

nslookup google.com
# Should return real IP (allowed)

nslookup nas.home.arpa
# Should return 192.168.40.10 (local DNS)

Whether a given ad domain is blocked depends on your lists. The query log in the Pi-hole web interface shows each lookup and whether it was blocked.

Troubleshooting

A device on a new VLAN gets no IP address. Either the DHCP server isn't enabled on that VLAN's interface in pfSense, or the switch port is in the wrong VLAN, or the trunk to the router doesn't carry that VLAN tagged. Check all three.

Everything on a VLAN can't reach the internet. pfSense blocks anything without an allow rule. A new VLAN interface starts with no rules, so it's blocked until you add some.

IoT devices can still reach my servers. Look at the rule order on the IoT tab. The RFC1918 block must sit above any broad allow rule.

Pi-hole's Docker container won't start: "address already in use" on port 53. On Ubuntu, systemd-resolved already listens on port 53. Check with sudo ss -lunp | grep :53. Either run Pi-hole on a host without it, or turn off its stub listener (DNSStubListener=no in /etc/systemd/resolved.conf, then restart systemd-resolved).

I locked myself out of the switch. You probably moved the port you were connected through into another VLAN. Connect to a port that's still on the management or default VLAN, or factory-reset the switch.

Pi-hole answers devices on its own VLAN but not on others. Pi-hole's default only answers its local subnet. On a script install, change the interface setting under Settings → DNS to allow all origins. Also check that the firewall allows port 53 from that VLAN to the Pi-hole's IP.

Local names don't resolve. The device isn't using Pi-hole. Check with nslookup nas.home.arpa 192.168.30.53. If that works, fix the DNS server handed out by DHCP.

What I'd tell anyone building one

  1. Start with VLANs, then tighten the firewall. Separating IoT and guests onto their own VLANs gets you most of the benefit. You can refine rules later.

  2. Block IoT from the start. Every IoT device is a possible way in. Put them on their own VLAN, block all RFC1918 traffic, and add single allow rules for the specific internal services they need.

  3. Pi-hole is the best $0 you'll spend. It blocks ads, trackers and malware domains for every device on the network. Point DNS at it and you're done.

  4. Use real names for local services. Local DNS records in Pi-hole under home.arpa give you nas.home.arpa instead of remembering IPs. Conditional forwarding adds names for devices that get their address from DHCP.

  5. Don't over-segment. Four or five VLANs (Trusted, IoT, Guest, Servers, maybe Management) cover most homelabs. Every extra VLAN is more rules to manage and more things that can break.

  6. Label your ports. When you're debugging at 11 PM, you don't want to trace cables. A label maker or colored cables per VLAN saves real time.

Next steps

  • Add a VPN so you can reach the Servers VLAN from outside. See my WireGuard guide.
  • Run your servers on Proxmox with a VLAN-aware bridge so each VM can sit on the right VLAN.
  • Turn on logging for the block rules for a week and see what your IoT devices are actually trying to reach.

Get it


Last updated: 2026-09-01. Tested with Ubiquiti USG + USW-Lite-16-PoE + U6 Lite, Pi-hole v6, pfSense 2.7.

Comments (0)

Join the discussion — sign in to comment.

Sign in

No comments yet — be the first to share your thoughts.

Related reading