Skip to content

VPN DNS leak prevention, per OS

How DNS leaks happen on VPN-connected clients — and the per-OS fixes for Windows, macOS, Linux, iOS, and Android that we ship in our profiles.

A DNS leak is the failure mode where your client uses the VPN tunnel for IP traffic but sends DNS queries outside it — usually to the local network’s resolver. The destination IP eventually goes through the VPN, but the resolver (your ISP, your hotel Wi-Fi, your office) has already seen the hostname. This article covers how DNS leaks happen on each OS, what the VPN’s push DNS directive does and does not fix, and the operational patterns we ship with every profile to make leaks not happen.

How to verify

The starting test is the same on every OS — make a DNS request and confirm which resolver answered.

dig +short whoami.cloudflare TXT @1.1.1.1
dig +short whoami.cloudflare TXT
resolvectl status   # Linux (systemd-resolved)
ipconfig /displaydns  # Windows
scutil --dns | grep -E 'nameserver|search' | head -20  # macOS

If the resolver shown when you do not specify one is your ISP’s IP rather than the VPN’s pushed resolver, you have a leak. Online “DNS leak test” sites work too — they make a DNS query for a unique subdomain and tell you which resolver they saw the lookup from.

What’s happening

DNS resolution is its own routing decision separate from IP traffic. The OS asks “where do I send DNS queries?” and the answer comes from a stack of sources:

  • The interface that came up most recently.
  • The interface with the lowest metric.
  • A system-wide override (/etc/resolv.conf, Windows registry, macOS scutil --set-dns).
  • A per-interface override pushed by the VPN.

When the VPN comes up, it usually pushes a resolver via dhcp-option DNS (OpenVPN), DNS = (WireGuard config), or a strongSwan/IKEv2 attribute. The OS may or may not honour it cleanly. Common failure modes:

  • Multiple resolvers, parallel queries. Some OSes (modern Windows since the “Smart Multi-Homed Name Resolution” change) query all configured resolvers in parallel and use the first response. If the local Wi-Fi resolver is faster than the VPN’s, the LAN sees the query.
  • Split DNS not configured. The VPN pushes its resolver as the global resolver; the OS queries the VPN for whatever.com too, leaking your full DNS pattern to the VPN’s operator (which may be fine if you trust them, not fine if you do not).
  • IPv6 separately. The VPN pushes only an IPv4 DNS; the OS keeps the LAN’s IPv6 resolver. Lookups go via IPv6 to the LAN.
  • Service-specific DNS. Browsers (Chrome, Firefox) can do DNS-over-HTTPS to their own resolvers, ignoring the OS configuration entirely.

The fix per OS is different.

The procedure

Linux (systemd-resolved)

WireGuard config:

[Interface]
DNS = 10.99.0.53
PostUp = resolvectl dns %i 10.99.0.53; resolvectl domain %i ~.
PostDown = resolvectl revert %i

The domain ~. tells systemd-resolved that this interface is authoritative for all DNS — no parallel queries to other interfaces.

OpenVPN with the update-resolv-conf script (Debian/Ubuntu package):

script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

Windows

Windows has “Smart Multi-Homed Name Resolution” which queries all interfaces in parallel. Disable it:

Set-DnsClientGlobalSetting -SuffixSearchList @() -UseSuffixSearchList $false
# Disable SMHNR system-wide:
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" /v DisableSmartNameResolution /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters" /v DisableParallelAandAAAA /t REG_DWORD /d 1 /f

Reboot. After that, Windows uses the VPN interface’s DNS exclusively when the VPN is up.

For WireGuard on Windows, the wireguard.exe GUI sets the interface DNS but does not disable parallel queries — the registry tweak above is still needed.

macOS

macOS has its own behaviour: it ranks resolvers by interface service order and prefers the topmost active interface. The OpenVPN Connect app and the official WireGuard app both insert the VPN at the top of the interface list, which usually works.

The leak case is when the user manually configured a system-wide DNS (System Settings -> Network -> Advanced -> DNS). That overrides the VPN’s push. Fix: remove the manual entry, let the VPN drive DNS.

For split DNS, scutil:

sudo scutil <<EOF
d.init
d.add ServerAddresses * 10.99.0.53
d.add SupplementalMatchDomains * corp.example.org
set State:/Network/Service/wg0/DNS
quit
EOF

iOS / Android

Mobile OSes route DNS through the VPN by default when the profile specifies it (in WireGuard’s DNS = field or in the IKEv2 profile). The leak case is private DNS (Android 9+) configured to a non-VPN provider — that overrides. Document this in onboarding: “turn off Private DNS, or set it to the VPN’s DoT endpoint.”

On iOS, the per-app VPN scope can leak DNS for apps not in the scope. If the VPN is supposed to be “all traffic,” use a system-wide VPN profile, not per-app.

Browsers — the new leak vector

Chrome and Firefox default to DNS-over-HTTPS to their built-in resolvers (Cloudflare, NextDNS, Google) when the OS supports it. This bypasses the OS DNS entirely and leaks to the browser’s resolver.

Fix at the browser level:

  • Chrome enterprise policy — set BuiltInDnsClientEnabled to false, set DnsOverHttpsMode to off or to your VPN resolver.
  • Firefox — network.trr.mode = 5 (off) or set network.trr.uri to your VPN’s DoH endpoint.

Distribute via MDM for managed devices.

Common pitfalls

  • Pushing a DNS but not the search-domain list — split-DNS for internal hostnames does not work unless the OS knows which suffix belongs to the VPN.
  • Assuming the VPN’s DNS = line is enough — on Windows it is not, without the SMHNR registry tweak. On Linux you also need resolvectl domain ~..
  • Forgetting IPv6. Push a v6 DNS too, or the OS will use the LAN’s v6 resolver.
  • Allowing browsers to do their own DoH — bypasses everything OS-level.
  • Testing once at setup, never again. OS updates routinely change DNS behaviour. Add the leak test to your quarterly review.

In the engagements we run, DNS leak prevention is part of the profile we ship — registry tweaks, scutil snippets, browser policies, the works. Without that, a “working” VPN profile silently leaks every domain its user looks up, which is exactly the failure mode the Managed Operations discipline exists to prevent. Pair this with the split tunnel leak tests and you have a configuration an auditor can validate.