What is a DNS leak, and how do you fix it?
A DNS leak lets a resolver outside your VPN see every site you visit. How to find one, what a country-based leak test misses, and how to fix each cause.
3 min read
On this page
Before your browser can open a site, it asks a resolver for the site's address. If you use a VPN or proxy, you expect that question to go through it. When it goes somewhere else, usually to your internet provider, that's a DNS leak. Pages still load through the VPN, so nothing looks wrong.
- 1You open a siteThe browser needs its address
- 2The lookup goes outIt should go through the tunnel
- 3The wrong resolver answersYour provider’s, outside the tunnel
- 4The page loads through the tunnelNothing looks wrong
The site sees the VPN. Your provider sees the name of every site.
Check for one
Turn the VPN or proxy on and run the test in the browser you use:
It makes your browser look up names that have never been looked up before, so that no cache can answer, and records which resolvers come to ask for them. Then it compares each resolver's country with the country of your web exit. Standard test is quick. Extended test runs several rounds and finds more resolvers, because large providers use many.
What the result does and doesn't mean
The check compares countries. That makes its answer clear, and it has limits you should know:
- A leak inside one country isn't visible. If your VPN exit is in the country you live in, your provider's resolver is in the right country too, and the check says Correct.
- A different country isn't always a problem. If you chose a public resolver yourself, its servers may be in another country.
- It covers this browser. Other apps can use a different resolver.
So look at the names in the list, not only the verdict. With a VPN on, you expect to see the VPN provider, or a resolver that you or it chose. If you see the company you pay for internet access, that's a leak, whatever the country.
We asked two home connections which network answers with different settings:
Look from the command line
Google runs a name whose answer is the address of the resolver that asked:
dig +short TXT o-o.myaddr.l.google.com"198.51.100.53"On Windows:
nslookup -type=TXT o-o.myaddr.l.google.comThe address is replaced with a documentation one here. Look yours up on the home page to see whose it is. If there's a second line starting with edns0-client-subnet, the resolver is also passing on part of your own address to the site's DNS servers. Both 8.8.8.8 measurements above included it.
The command line uses the system's setting. Browsers can use their own encrypted DNS, so the two can differ, and the browser test is the one that counts for browsing.
Why it happens, and what to do
The VPN doesn't set DNS. Look for "DNS leak protection" or "use the VPN's DNS" in the client and turn it on.
The system asks several resolvers. Windows can send a lookup through more than one network connection and use whichever answers first. Clients with leak protection block this. Check what's configured:
scutil --dns | grep nameserver | sort -u nameserver[0] : 192.0.2.53 nameserver[1] : 198.51.100.53Get-DnsClientServerAddress | Where-Object ServerAddressesThe first is for macOS and the second for Windows; the output shown is the macOS format with documentation addresses.
A DNS server is set by hand on the network adapter or in the router, and takes priority. Set it back to automatic, or to the VPN's.
The browser has its own. In Chrome's and Firefox's privacy settings, "Use secure DNS" or "DNS over HTTPS" sends lookups to a provider chosen there. The network can't read them, but that provider sees them instead of your VPN's.
The proxy covers only the pages. With an HTTP proxy, or a SOCKS5 proxy set to resolve names locally, lookups go out directly. In a SOCKS client, choose to resolve names at the proxy (in curl, socks5h instead of socks5).
IPv6 isn't covered. A resolver reached over IPv6 bypasses an IPv4-only tunnel. Why proxies can leak IPv6 has the fix.
Split tunneling sends some names outside on purpose. See which exit a site sees.
After a change, clear the cache, close the browser completely and test again:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderipconfig /flushdnsIs it serious?
It depends on why you use the VPN. If it's only to reach a company system, it matters little. If you don't want your provider to know which sites you visit, a leak defeats the purpose.
Fixing it doesn't hide everything. Networks along the way can still read the site's name from the start of the connection, unless that's inside the tunnel too. And DNS is one of three things to test: how to test a VPN or proxy for leaks covers the rest.