
Infrastructure
Homelab VLANs and DNS-Based Policy Routing
How I segment a homelab with VLANs and route traffic through country-specific VPN tunnels, driven by a YAML intent file and Jinja2 templates on OpenWRT.
By Paul Bentley9 min read
On this page
- The VLAN layout
- The problem: per-domain routing
- How DNS-based policy routing works
- Layer 1: DNS resolution and nftset tagging
- Layer 2: packet marking in nftables
- Layer 3: policy routing via ip rule
- Intent-based domain routing
- Template-driven configuration
- Safety rails
- WAN egress guard
- DNS enforcement
- RFC1918 exemption
- Lessons learned
- nftset timeout tuning
- Firewall forwarding rules for intent traffic
- Priority ordering in ip rules
- Counters for debugging
- WAN-exempt needs a non-zero mark
Most homelabs start as a flat network. A NAS, a few Docker containers, some IoT devices, maybe a Proxmox host, all share the same subnet, the same default gateway, the same path to the internet. It works fine until you start asking questions like "why can my smart plug talk to my backup server?" or "can I route BBC iPlayer through a UK exit without affecting everything else on this VLAN?"
This post describes the network as I first built it. By September 2026 it had grown: the router is now a high availability pair, there are more VLANs, the VPN tunnels form a failover pool, and deployment runs per node with health checks and automatic rollback. The routing approach below is unchanged.
These are the questions that turned my flat network into a VLAN-segmented, policy-routed setup running on an OpenWRT instance inside a Proxmox LXC. The result is a system where adding a new domain to a specific VPN tunnel is a one-line YAML change, and the entire network configuration is rendered from templates, with no manual edits on the router, ever.