AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

i365Finds Editorial is the independent research and editorial organization behind 365 Wiki. We follow changes in tools, products, services, entertainment, and digital life around the world, turning scattered and fast-moving information into clearly sourced, well-structured public content that is easier to understand and compare.
Indexed 92,250 Wiki articles

How to Configure Split DNS on a VPN Router: Preserving Local LAN Hostnames Without DNS Leaks

Boris Graf · 365Finds Editorial

Connecting an entire home or small office network through a VPN router sounds ideal until you try to open your local network-attached storage (NAS) or access a local development server by its hostname. Suddenly, nas.lan, printer.local, or proxmox.home.arpa stop resolving.

At 365Finds, we run into this friction constantly during router hardware tests. Commercial VPN setups and default client scripts apply a blunt-force fix to avoid DNS leaks: they hijack port 53 and shove every single query down the encrypted tunnel to the VPN provider’s public recursive resolvers. The commercial provider's upstream resolver naturally has no record of your internal RFC 1918 private subnets. The lookup returns NXDOMAIN. Local access collapses, leaving users to choose between two bad outcomes: either type raw IP addresses like it is 1985, or disable the tunnel's DNS enforcement and risk leaking private browsing activity to the local ISP.

You do not need to make that compromise. Split DNS on your router allows the local resolver daemon to answer private domain queries locally, forward internal enterprise domains across the tunnel if needed, and route all public internet queries securely through the VPN without leaking a single packet to your ISP.


Why Router VPN Clients Break Local Name Resolution

The breakdown happens because of how typical VPN integration scripts manage DNS hierarchy:

  1. Blind Tunnel Overrides (peerdns): When WireGuard or OpenVPN brings up a tunnel interface, the client often accepts pushed DNS servers and forces the router’s operating system to rewrite /etc/resolv.conf.
  2. Global Port 53 Hijacking: To pass commercial "DNS leak tests," routers often employ firewall NAT rules redirecting all UDP/TCP port 53 traffic straight to the VPN server's DNS.
  3. Loss of Local Context: Client machines send local hostname queries (like homeassistant.lan) to the router. If the router blindly dumps the request into the VPN tunnel, the public VPN resolver responds with non-existent domain errors.
  4. Upstream Leakage Risk: If you attempt a naive fix by configuring your local DHCP server to hand out your router IP for local names and your ISP/VPN for internet lookups, clients query resolvers simultaneously. Windows and macOS will happily blast your private .lan queries to the public internet, or send sensitive public queries unencrypted across your WAN.

To fix this reliably, the router must serve as the authoritative gatekeeper. All client machines query only the router's local DNS service. The router then performs conditional forwarding: local domains stay inside the LAN, designated private remote domains travel across the VPN tunnel, and general internet traffic routes exclusively to the VPN resolver.


Core Architecture of a Leak-Free Split DNS Pipeline

Local Client Query
       │
       ▼
[ Router Local DNS Daemon: dnsmasq / Unbound ]
       │
       ├── Is query in local zone (.lan, .home.arpa)? ──> Resolve via Local DHCP/Static Leases (LAN)
       │
       ├── Is query in corporate/remote subnet zone?   ──> Forward down VPN Tunnel to Internal Resolver
       │
       └── Is query for public internet (e.g. eff.org)? ──> Forward securely via VPN DNS Resolver

To maintain this architecture, three rules must be strictly enforced on the router:


Configuring Split DNS Across Router Platforms

Different router operating systems implement DNS services differently. OpenWrt uses dnsmasq, Asuswrt-Merlin layers custom web controls and JFFS scripts over dnsmasq, and enterprise firewalls like pfSense and OPNsense utilize Unbound.

1. OpenWrt (dnsmasq)

OpenWrt provides the cleanest native control over DNS routing if you disable automatic DNS overrides on your VPN interface.

Step 1: Prevent the VPN from Hijacking Global DNS

When configuring a WireGuard or OpenVPN interface in OpenWrt, stop the tunnel from overwriting system resolvers:

uci set network.vpn.peerdns='0'
uci commit network
/etc/init.d/network restart

Step 2: Configure Upstream Resolvers and Leak Shields

Open /etc/config/dhcp or go to Network > DHCP and DNS > General Settings:

uci set dhcp.@dnsmasq[0].domainneeded='1'
uci set dhcp.@dnsmasq[0].boguspriv='1'
uci set dhcp.@dnsmasq[0].localise_queries='1'
uci set dhcp.@dnsmasq[0].authoritative='1'

Step 3: Define Conditional Forwarding and Upstream DNS

Direct general public DNS queries to the VPN provider's DNS IP (for example, 10.8.0.1 or your provider’s designated resolver), while routing local domains locally:

# Add upstream VPN DNS resolver
uci add_list dhcp.@dnsmasq[0].server='10.8.0.1'

# If connecting to an enterprise split-tunnel (e.g., corp.internal)
uci add_list dhcp.@dnsmasq[0].server='/corp.internal/10.8.0.1'
uci add_list dhcp.@dnsmasq[0].server='/10.in-addr.arpa/10.8.0.1'

# Rebind protection whitelist for local domains
uci add_list dhcp.@dnsmasq[0].rebind_domain='lan'
uci add_list dhcp.@dnsmasq[0].rebind_domain='corp.internal'

uci commit dhcp
/etc/init.d/dnsmasq restart

2. Asuswrt-Merlin (DNS Director & VPN Director)

Asus routers running Asuswrt-Merlin feature VPN Director (policy-based routing) and DNS Director (enforced DNS assignment). Because these features can easily conflict, 365Finds recommends explicit configuration.

Step 1: Configure LAN DHCP

  1. Go to LAN > DHCP Server.
  2. Leave DNS Server 1 empty or set it explicitly to the router’s LAN IP (e.g., 192.168.1.1). Never put an external IP address here; all LAN clients must query the router.
  3. Under RT-AC/AX/BE features, ensure Advertise router's IP in addition to user-specified DNS is disabled if you configure custom DNS.

Step 2: Adjust VPN Client DNS Settings

  1. Navigate to VPN > VPN Client.
  2. Under your active OpenVPN or WireGuard profile, locate Accept DNS Configuration.
  3. Set this to Exclusive if all routed clients should use VPN DNS, or Strict if using policy-based split tunneling. "Exclusive" forces dnsmasq to push queries originating from tunneled IPs into the tunnel’s DNS without poisoning the router's base lookup table.

Step 3: Handle Split Domains via JFFS

If you run an internal server (such as a Pi-hole, AdGuard Home, or private NAS zone) that requires split forwarding:

  1. Enable JFFS custom scripts under Administration > System.
  2. SSH into your Asus router and edit /jffs/configs/dnsmasq.conf.add:
# Forward local lab domain to your internal resolver
server=/home.arpa/192.168.1.50
server=/lab.internal/192.168.1.50

# Ensure upstream queries do not leak local reverse lookups
bogus-priv
domain-needed
  1. Restart the daemon:
service restart_dnsmasq

3. pfSense / OPNsense (Unbound DNS Resolver)

In pfSense, Unbound functions as an authoritative validating resolver. It offers granular control over which network interface issues outbound queries.

Step 1: Set Interface Bindings

  1. Navigate to Services > DNS Resolver > General Settings.
  2. Network Interfaces: Select only LAN, any internal VLANs, and Localhost. Do not select WAN or VPN interfaces here. This restricts client query listening to safe, local zones.
  3. Outgoing Network Interfaces: Select your active VPN interface (e.g., OVPN_WAN or WG_VPN). This guarantees that all upstream recursive queries leave the firewall exclusively across the encrypted tunnel.

Step 2: Prevent WAN Fallback and Overrides

  1. Go to System > General Setup.
  2. Uncheck Allow DNS server list to be overridden by DHCP/PPP on WAN. This stops your ISP from overwriting gateway resolvers when DHCP renews.
  3. If DNS servers are specified under DNS Server Settings, assign the Gateway for those IPs explicitly to your VPN gateway.

Step 3: Configure Domain Overrides for Split DNS

  1. Under Services > DNS Resolver > General Settings, scroll down to Domain Overrides.
  2. Click Add to route specific internal or enterprise domains:
    • Domain: corp.internal (or office.lan)
    • IP Address: IP of your internal domain controller or DNS server (e.g., 10.200.1.5)
  3. For local devices managed directly by pfSense, verify Register DHCP leases in the DNS Resolver and Register DHCP static mappings in the DNS Resolver are enabled.

Step 4: Intercept Port 53 Traffic (NAT Port Forward)

To ensure stubborn devices or embedded operating systems do not bypass your resolver by querying public DNS directly, redirect port 53 back into the firewall:

  1. Navigate to Firewall > NAT > Port Forward and create a rule:
    • Interface: LAN
    • Protocol: TCP/UDP
    • Destination: Invert Match ([x]), Destination: LAN Address
    • Destination Port Range: 53 to 53
    • Redirect Target IP: 127.0.0.1
    • Redirect Target Port: 53
    • Description: Redirect rogue DNS queries to local Unbound resolver.

Technical Comparison of Platform Configurations

PlatformPrimary DNS DaemonSplit Forwarding SyntaxLeak Prevention MechanismBest Use Case
OpenWrtdnsmasqserver=/internal.domain/IP in dhcp configoption peerdns '0', domainneeded, bogusprivLightweight, open-source routers; granular terminal control
Asuswrt-Merlindnsmasqserver=/internal.domain/IP in /jffs/configs/dnsmasq.conf.addDNS Director rules; VPN Client DNS set to "Exclusive"Home networks wanting high-speed Wi-Fi 6/7 with policy routing
pfSense / OPNsenseUnboundDomain Overrides in Resolver GUIOutgoing interface lock to VPN; Port 53 NAT interceptSmall business, homelabs, complex multi-VLAN environments

Mitigating Hidden DNS Leaks and Edge Cases

Even with split DNS configured properly, three modern protocol behaviors can silently unravel your setup.

1. The DNS-over-HTTPS (DoH) Bypass

Modern web browsers (Firefox, Chrome, Safari) and mobile operating systems aggressively push Encrypted DNS / DoH. If a browser activates DoH, it makes encrypted HTTPS connections on port 443 directly to Cloudflare, Google, or NextDNS.

2. mDNS and the .local Suffix Trap

Many home administrators assign .local as their router's DHCP domain name. This violates RFC 6762. The .local top-level domain is strictly reserved for Multicast DNS (mDNS / Bonjour / ZeroConf).

When a macOS, Linux (systemd-resolved), or Windows machine encounters a .local hostname, it often routes the lookup via multicast link-local packets (224.0.0.251:5353) rather than sending a unicast DNS query to your router's port 53. If the host is on a different VLAN or the mDNS repeater is disabled, lookup fails.

3. DNS Rebinding Protections

Most modern router firmware blocks upstream resolvers from returning private RFC 1918 IP addresses (e.g., 192.168.x.x, 10.x.x.x, 172.16.x.x) to protect against browser-based intranet hijacking.


Verification and Leak Testing

Do not rely solely on commercial one-click leak tests; these sites only check whether their own tracking servers detect your ISP’s public IP address. Verify both local resolution and tunnel isolation from a connected LAN terminal.

1. Test Local Name Resolution

Run an explicit query against the router's LAN IP:

nslookup nas.home.arpa 192.168.1.1

The query must return your local RFC 1918 address immediately with an authoritative answer from the router.

2. Verify Corporate / Split-Domain Forwarding

nslookup git.corp.internal 192.168.1.1

The response should originate from your internal VPN resolver address without timing out.

3. Audit for Public Leaks

Use standard diagnostic utilities to inspect the public resolution path:

dig whoami.akamai.net @192.168.1.1

Or query a leak identification service:

curl https://am.i.mullvad.net/dns

The returned resolver address must strictly identify your VPN provider's DNS endpoints. If your residential ISP’s name or IP appears anywhere in the output, check whether your router's WAN interface is receiving upstream servers via DHCP and ensure peerdns or WAN DNS override checkboxes are properly disabled.


References