ByteGuideHub
Networking / Homelab • • 10 min read

Building a Privacy-First Home Network with Pi-hole, VLANs, and WireGuard

Learn how to build a privacy-first home network using Pi-hole for DNS filtering, VLANs for network segmentation, and WireGuard for secure remote access. Step-by-step guide with configuration examples.

Sponsored / Ad Space

Building a Privacy-First Home Network with Pi-hole, VLANs, and WireGuard

Quick Summary (TL;DR) This guide walks you through building a privacy-first home network using three complementary tools: Pi-hole for DNS-level ad and tracker blocking, VLANs for network segmentation, and WireGuard for secure remote access. You’ll learn how to set up each component, integrate them for maximum privacy, and troubleshoot common issues. The complete setup takes 2-4 hours and requires a Raspberry Pi (or always-on Linux machine), a VLAN-capable router or managed switch, and basic networking knowledge.


Introduction: Why Privacy-First Networking Matters

In an era of pervasive tracking and data collection, your home network is the gateway to your digital life. By default, your ISP can see every DNS query you make, third-party trackers follow you across the web, and your devices sit on a flat network where any compromise can spread laterally. This isn’t just a theoretical concern—DNS queries reveal which websites you visit, when you visit them, and how often.

A privacy-first network flips this model. Instead of trusting your ISP and external trackers, you take control at the network level. Pi-hole blocks tracking domains before they load, VLANs contain compromised devices, and WireGuard ensures your traffic is encrypted when you’re away from home. Together, these tools create a layered defense that protects your data and your devices.


Prerequisites and Planning

Before diving in, gather the necessary hardware and software:

Hardware Requirements:

  • Raspberry Pi 4 (2GB+ RAM) or any always-on Linux machine for Pi-hole and WireGuard
  • VLAN-capable router (pfSense, Ubiquiti, TP-Link Omada) or managed switch
  • PoE switch or power adapters for your network equipment
  • Ethernet cables for critical connections

Software Requirements:

  • Raspberry Pi OS Lite (or your preferred Linux distribution)
  • Pi-hole installation script
  • WireGuard packages
  • WireGuard client apps for your devices

Planning Your Network: Map out your device inventory and assign them to VLANs:

VLANPurposeTypical Devices
VLAN 10PersonalLaptops, phones, desktops
VLAN 20IoTSmart home devices, cameras, smart TVs
VLAN 30GuestVisitor devices (isolated)

Draw a simple diagram showing your router, switch, Pi-hole, and which VLAN each device connects to. This roadmap will guide your configuration.

graph TD
    A[Internet] --> B[Router/Firewall]
    B --> C{Managed Switch}
    C --> D[VLAN 10: Personal]
    C --> E[VLAN 20: IoT]
    C --> F[VLAN 30: Guest]
    B --> G[Pi-hole + WireGuard]
    D --> H[Laptops/Phones]
    E --> I[Smart Devices]
    F --> J[Visitors]
    G --> D
    G --> E
    G --> F

Step 1: Setting Up Pi-hole for DNS Filtering

Pi-hole acts as a network-wide ad blocker and privacy shield by intercepting DNS queries and blocking known advertising and tracking domains.

Installation:

# SSH into your Raspberry Pi
curl -sSL https://install.pi-hole.net | bash

During installation, you’ll be prompted to:

  1. Select your network interface (typically eth0)
  2. Choose upstream DNS providers—select Cloudflare (1.1.1.1) or Quad9 (9.9.9.9) for privacy
  3. Set your IPv4 address as static
  4. Review the installation summary

Enable DNSSEC: After installation, log into the Pi-hole admin interface (http://your-pi-ip/admin), navigate to Settings → DNS, and enable DNSSEC. This validates DNS responses, preventing DNS spoofing attacks.

Configure Your Router: In your router’s DHCP settings, set the DNS server to your Pi-hole’s IP address (e.g., 192.168.1.100). This ensures all devices on your network use Pi-hole automatically.

Verify: Visit the Pi-hole dashboard and check that queries are appearing. Try visiting a site with ads (like a news site) and confirm the blocked query count increases.


Step 2: Implementing VLANs for Network Segmentation

VLANs isolate traffic, so a compromised IoT device can’t reach your personal computers. This is critical—many IoT devices have poor security and are frequently targeted.

Create VLANs on Your Router/Switch:

For a Ubiquiti or TP-Link managed switch, access the admin interface and configure:

VLAN 10: Personal  - Subnet 192.168.10.0/24
VLAN 20: IoT       - Subnet 192.168.20.0/24
VLAN 30: Guest     - Subnet 192.168.30.0/24

Assign Ports: Tag ports for each VLAN. For example:

  • Ports 1-8: VLAN 10 (Personal)
  • Ports 9-16: VLAN 20 (IoT)
  • Ports 17-24: VLAN 30 (Guest)

Configure Firewall Rules: The critical part is inter-VLAN routing rules. On your router/firewall:

Rule 1: Allow VLAN 10 → Internet (all)
Rule 2: Allow VLAN 20 → Internet (all)
Rule 3: Allow VLAN 30 → Internet (all)
Rule 4: Deny VLAN 20 → VLAN 10 (IoT cannot access personal)
Rule 5: Deny VLAN 30 → VLAN 10, 20 (Guest isolation)
Rule 6: Allow all VLANs → Pi-hole (192.168.1.100) on port 53

Configure Wi-Fi: If using access points, create separate SSIDs mapped to each VLAN:

  • “Home-Personal” → VLAN 10
  • “Home-IoT” → VLAN 20
  • “Home-Guest” → VLAN 30

Step 3: Setting Up WireGuard for Secure Remote Access

WireGuard provides a fast, modern VPN for secure remote access to your home network. It’s significantly faster than OpenVPN and has a minimal attack surface.

Install WireGuard on Your Pi:

sudo apt update && sudo apt install wireguard

Generate Server Keys:

cd /etc/wireguard
umask 077
wg genkey | tee server_private.key | wg pubkey > server_public.key

Create Server Configuration (/etc/wireguard/wg0.conf):

[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = <server_private_key>

[Peer]
# Client 1 (Laptop)
PublicKey = <client1_public_key>
AllowedIPs = 10.0.0.2/32

[Peer]
# Client 2 (Phone)
PublicKey = <client2_public_key>
AllowedIPs = 10.0.0.3/32

Enable IP Forwarding:

sudo sysctl -w net.ipv4.ip_forward=1
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf

Configure NAT for VPN traffic:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Create Client Configuration: On your laptop, generate a key pair and create a client config:

[Interface]
Address = 10.0.0.2/24
PrivateKey = <client1_private_key>
DNS = 192.168.1.100  # Pi-hole IP

[Peer]
PublicKey = <server_public_key>
Endpoint = your-home-public-ip:51820
AllowedIPs = 192.168.1.0/24, 10.0.0.0/24

Step 4: Integrating Pi-hole with WireGuard

To ensure privacy even when you’re away, configure WireGuard clients to use your Pi-hole as their DNS server. This routes all DNS queries through the encrypted VPN tunnel.

Update WireGuard Server: Add a firewall rule to allow VPN clients to reach Pi-hole:

sudo iptables -A FORWARD -i wg0 -d 192.168.1.100 -p udp --dport 53 -j ACCEPT

Update Client Configurations: Ensure each client’s [Interface] section has:

DNS = 192.168.1.100

Test DNS Resolution: From a connected VPN client:

nslookup google.com

The response should show your Pi-hole’s IP as the server.

Verify in Pi-hole Dashboard: Check the Pi-hole query log—you should see queries coming from the VPN subnet (10.0.0.x), confirming that remote devices are being filtered.


Step 5: Testing and Verification

DNS Filtering Test:

  1. Visit a site with ads (e.g., a news site)
  2. Check Pi-hole dashboard—blocked queries should increase
  3. Use dig example.com @192.168.1.100 to verify DNS resolution

VLAN Isolation Test:

# From a device on VLAN 20 (IoT)
ping 192.168.10.1  # Should fail
ping 8.8.8.8       # Should succeed

WireGuard Test:

  1. Disconnect your phone from Wi-Fi and enable WireGuard
  2. Try accessing a local resource (e.g., your Pi-hole admin page at http://192.168.1.100/admin)
  3. Run wg show on the server to see connected peers

Privacy Verification: Use a DNS leak test website to confirm your DNS queries are going through Pi-hole, not your ISP’s DNS servers.


Comparison: Pi-hole vs. Other DNS Filters

FeaturePi-holeAdGuard HomeNextDNS
HostingSelf-hostedSelf-hostedCloud-based
CostFreeFreeFreemium
PrivacyFull controlFull controlThird-party dependency
UIFunctionalModernExcellent
MaintenanceManual updatesManual updatesAutomatic
CustomizationHighHighMedium
PerformanceExcellentExcellentGood (latency dependent)

For privacy enthusiasts, self-hosting with Pi-hole offers the best balance of control, cost, and performance. AdGuard Home is worth considering if you prefer a more polished interface. NextDNS is convenient but introduces a third-party dependency.


Troubleshooting Common Issues

DNS Not Resolving:

  • Verify Pi-hole is running: sudo systemctl status pihole-FTL
  • Check router DHCP is handing out Pi-hole’s IP
  • Test with dig google.com @your-pi-hole-ip

VLANs Not Isolating Traffic:

  • Verify switch ports are tagged correctly
  • Check firewall rule order (deny rules should come before allow rules)
  • Confirm inter-VLAN routing is enabled on your router

WireGuard Connection Failures:

  • Check server is listening: sudo wg show
  • Verify client’s public key matches server’s peer config
  • Ensure port 51820/udp is forwarded on your router
  • Check firewall rules allow UDP traffic on the VPN port

Pi-hole Not Blocking Ads:

  • Update blocklists: pihole -g
  • Verify devices are using Pi-hole (check dashboard for queries)
  • Clear your browser cache and DNS cache

Conclusion and Next Steps

You’ve now built a privacy-first home network with Pi-hole, VLANs, and WireGuard. This setup significantly reduces tracking, limits the blast radius of compromised devices, and gives you secure remote access to your home network.

Suggested Next Steps:

  1. Add a firewall like pfSense for more advanced control and intrusion detection
  2. Set up a reverse proxy (like Nginx Proxy Manager) for secure access to web services
  3. Implement automatic updates for Pi-hole and WireGuard
  4. Create a backup of your configurations for disaster recovery
  5. Monitor your network with tools like Grafana and Prometheus

Remember to regularly update your Pi and review your firewall rules to maintain security. Your privacy isn’t a one-time setup—it’s an ongoing commitment.


FAQ

What is Pi-hole and how does it enhance privacy? Pi-hole is a network-wide ad blocker that acts as a DNS sinkhole. It intercepts DNS queries and blocks requests to known ad and tracking domains, preventing your devices from communicating with them. This enhances privacy by reducing the amount of data collected about your browsing habits and speeds up your network by eliminating unwanted content.

Do I need a managed switch to set up VLANs? Yes, VLANs require a managed switch or a router that supports VLAN configuration. Unmanaged switches do not support VLAN tagging. If your router supports VLANs (e.g., pfSense, Ubiquiti, or some consumer routers with custom firmware), you can use it to segment your network without a separate managed switch.

Can I run Pi-hole and WireGuard on the same Raspberry Pi? Absolutely. A Raspberry Pi 4 or newer can handle both Pi-hole and WireGuard simultaneously without performance issues. This is a common setup for homelab enthusiasts. Just ensure you have adequate cooling and a reliable power supply.

How do I ensure my WireGuard VPN is secure? WireGuard is secure by design, but you should follow best practices: use strong pre-shared keys, keep your server’s private key secret, and regularly update the WireGuard software. Also, configure firewall rules to only allow necessary ports and restrict access to the VPN server’s management interface.

Will VLANs affect my device’s ability to communicate with each other? VLANs isolate traffic, so devices on different VLANs cannot communicate directly unless you configure routing and firewall rules to allow it. This is intentional for security. You can create inter-VLAN rules to allow specific traffic, such as allowing IoT devices to reach the internet but not your personal computers.

Sponsored / Ad Space