You bring up a WireGuard interface or start an OpenVPN tunnel on Linux. Your public IP changes. IP leak tests show the VPN server address. You assume your connection is watertight.
It often isn't.
Underneath your running applications, your local resolver might still be shipping DNS lookups in plaintext straight to your home router or local ISP. At 365Finds, we consider this one of the most insidious networking traps on modern Linux distributions: a silent DNS leak where everything looks connected, but the privacy promise of the tunnel has quietly broken down.
The culprit is almost always systemd-resolved and its split-DNS resolution engine.
Why systemd-resolved Leaks Your Queries
Traditional Unix systems handled DNS through /etc/resolv.conf as a sequential list of nameservers. Applications read that file, queried the first IP on the list, waited for a timeout, and only then fell back to the second.
Modern Linux distributions—including Ubuntu, Debian, Fedora, and Arch—replace that simple mechanism with systemd-resolved. Instead of a dumb list of upstream servers, systemd-resolved runs a local caching stub resolver listening on 127.0.0.53:53 (and 127.0.0.54). It manages DNS configuration on a per-link basis.
+--------------------------------------------------------------------+
| Application |
+--------------------------------------------------------------------+
|
v
+--------------------------------------------------------------------+
| systemd-resolved (127.0.0.53:53) |
| - Evaluates domain against per-link routing scopes |
+--------------------------------------------------------------------+
| |
v (Matching domain / ~. ) v (Fallback / Parallel)
+------------------------------------+ +---------------------------+
| Link wg0 / tun0 (VPN Interface) | | Link eth0 / wlan0 (LAN) |
| DNS: 10.2.0.1 | | DNS: 192.168.1.1 (ISP) |
| Routing Domain: ~. (Catch-all) | | Routing Domain: (None) |
+------------------------------------+ +---------------------------+
This architecture was designed to make split-horizon networks effortless. A laptop could stay connected to corporate Wi-Fi while running a VPN tunnel back to the office: queries for intranet.corp would traverse the VPN tunnel, while Spotify or YouTube lookups went straight to the fast local router.
For privacy-first users, this behavior is a hazard.
When you launch open-source WireGuard via wg-quick or run standard openvpn from the command line, three failure modes routinely emerge:
- Missing Routing Scope (
~.): If a network interface does not explicitly claim the root routing domain (~.),systemd-resolvedtreats it merely as one possible outbound interface among several. If your physical Wi-Fi or Ethernet link still retains a default route flag,systemd-resolvedwill query both interfaces in parallel or prefer the physical link if the tunnel's DNS responder experiences slight latency. - Missing
resolvconfBridge:wg-quickrelies on an external utility calledresolvconfto register DNS servers. If your system runssystemd-resolvedbut lacks thesystemd-resolvconfshim package,wg-quickfails silently or leaves DNS settings unmodified. Your tunnel carries raw packet traffic, but your DNS lookups never touch the tunnel. - OpenVPN's Complete Ignorance of systemd-resolved: Plain
openvpnhas zero native integration withsystemd-resolved. It receives DNS server addresses pushed by the server via DHCP options (dhcp-option DNS ...), but does nothing with them unless an explicitupscript bridges those variables into the system's D-Bus interface. Without such a script, the VPN tunnel comes up, the default IP gateway changes, but/etc/resolv.confcontinues pointing to your local gateway over the physical interface's direct local subnet route.
The Concept You Must Understand: Routing Domains and ~.
In systemd-resolved, domains attached to an interface serve two very different purposes:
- Search domains: Suffixes appended to single-word lookups (e.g., looking up
devboxautomatically attemptsdevbox.home.arpa). - Routing domains (route-only domains): Prefixed with a tilde (
~). These define domain matching rules without modifying single-label lookups.
The wildcard notation ~. combines the route-only prefix with the root domain.
When ~. is assigned to an interface:
resolvectl domain <interface> '~.'
It instructs systemd-resolved that all standard DNS lookups must be directed to the DNS servers registered on this specific link, unless a more specific search domain matches elsewhere.
If your VPN interface does not own ~., your privacy is not enforced at the DNS layer.
Step 1: Diagnose Your Current DNS Routing
Before altering files, run resolvectl status to inspect how systemd-resolved currently views your active links:
resolvectl status
Examine the output carefully:
Link 2 (wlan0)
Current DNS Server: 192.168.1.1
DNS Servers: 192.168.1.1
DNS Domain: lan
Link 3 (wg0)
Current DNS Server: 10.2.0.1
DNS Servers: 10.2.0.1
DNS Domain: none
In the configuration above, a DNS leak is actively occurring. wg0 lists an encrypted VPN resolver, but because its DNS Domain is empty and wlan0 remains an active default link, systemd-resolved will send standard web queries through 192.168.1.1 to your ISP.
To see which server handles a specific lookup in real-time, execute:
resolvectl query example.com
If the responding link in the terminal is wlan0 or eth0 instead of your VPN interface, your traffic is exposed.
Step 2: Fixing WireGuard (wg-quick)
WireGuard configurations (wg0.conf) need unambiguous link instructions. At 365Finds, we favor native D-Bus directives over fragile compatibility scripts.
Method A: Native resolvectl Hooks (Most Reliable)
Rather than trusting wg-quick to invoke the right resolvconf wrapper correctly, configure explicit PostUp and PostDown commands inside /etc/wireguard/wg0.conf:
[Interface]
Address = 10.2.0.2/32
PrivateKey = aaaaaaaa...
# Do not rely solely on 'DNS = ...' if your distro's resolvconf wrapper is inconsistent
PostUp = resolvectl dns %i 10.2.0.1; resolvectl domain %i '~.'; resolvectl default-route %i true
PostDown = resolvectl revert %i
[Peer]
PublicKey = bbbbbbbb...
Endpoint = 203.0.113.50:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25
What these commands do:
resolvectl dns %i 10.2.0.1: Assigns the VPN provider's DNS server to interface%i(which expands towg0).resolvectl domain %i '~.': Designates this interface as the catch-all root routing domain.resolvectl default-route %i true: Marks this link as the primary outbound path for unconstrained DNS queries.resolvectl revert %i: Cleans up all DNS configurations assigned to this link when the tunnel is torn down.
Method B: Using DNS = with the Proper Wrapper
If you prefer keeping clean DNS = 10.2.0.1 directives in your config, verify that the package bridging resolvconf to systemd-resolved is present on your distribution:
- Debian / Ubuntu: Ensure
systemd-resolvedis active (sudo systemctl enable --now systemd-resolved). - Arch Linux: Install
systemd-resolvconf(sudo pacman -S systemd-resolvconf), which points/usr/bin/resolvconfdirectly toresolvectl.
When systemd-resolvconf is installed, wg-quick runs:
resolvconf -a wg0 -m 0 -x -s 10.2.0.1
The -x flag signals systemd-resolved to set ~. on the interface automatically.
Step 3: Fixing OpenVPN
Upstream OpenVPN cannot communicate with systemd-resolved out of the box. You must provide a bridge script.
The standard and most robust solution in the Linux ecosystem is update-systemd-resolved.
1. Install the Bridge Script
- Arch Linux:
sudo pacman -S openvpn-update-systemd-resolved - Ubuntu / Debian:
sudo apt install openvpn-systemd-resolved
2. Configure Your Client Profile (client.ovpn)
Append the following directives to your OpenVPN client profile:
script-security 2
up /usr/libexec/openvpn/update-systemd-resolved
down /usr/libexec/openvpn/update-systemd-resolved
down-pre
# Ensure the root routing domain is attached to tun0
dhcp-option DOMAIN-ROUTE .
(Note: Verify the path on your system; older Debian packages put this script in /etc/openvpn/update-systemd-resolved, while modern packages place it in /usr/libexec/openvpn/ or /usr/bin/.)
When OpenVPN starts, update-systemd-resolved captures pushed DHCP options via the management interface and uses D-Bus to assign the DNS server and the root routing domain (~.) directly to tun0.
Step 4: Neutralizing Fallback and Global Leaks
Even with interface routing rules in place, systemd-resolved can leak requests under edge conditions if global fallback resolvers are defined.
Open /etc/systemd/resolved.conf:
sudo nano /etc/systemd/resolved.conf
Verify or adjust these settings under the [Resolve] stanza:
[Resolve]
# Leave DNS blank here so physical links do not inherit global resolvers
# DNS=
# Clear FallbackDNS to prevent silent queries to Google or Cloudflare
FallbackDNS=
# Optional: Enable DNS-over-TLS if your VPN resolver supports it
# DNSOverTLS=opportunistic
Restart the resolution daemon to commit changes:
sudo systemctl restart systemd-resolved
Clearing FallbackDNS= ensures that if the VPN resolver momentarily fails to answer, systemd-resolved will return a lookup error rather than quietly shooting plaintext queries out to hardcoded public resolvers.
Step 5: Verification
To prove that the leak is plugged, bring up your tunnel:
sudo wg-quick up wg0
# Or: sudo openvpn --config client.ovpn
Run resolvectl status and look at the VPN interface block:
Link 3 (wg0)
Current DNS Server: 10.2.0.1
DNS Servers: 10.2.0.1
DNS Domain: ~.
DefaultRoute: yes
The combination of DNS Domain: ~. and DefaultRoute: yes confirms that all general DNS traffic is bound to wg0.
Finally, run a real lookup test:
resolvectl query whoami.akamai.net
The output will display the exact IP address of the responding DNS server and the interface used (Data source: DNS, Link: wg0).