A "DNS leak" means: when you visit a website, the DNS server that translates the domain name into an IP address is still your local ISP's. That means your local network can see which domains you visit, and the location the platform sees for your DNS resolution doesn't match your exit location.
First, three terms you'll see throughout:
- Exit IP: the "you" that websites see — your address after going out through the proxy.
- DNS: the service that translates a domain like "www.google.com" into an IP address; by default it's provided by your broadband ISP.
- TUN mode: a switch in the client. Once on, all traffic on your computer (including DNS queries) goes through the client first.
The idea behind a clash dns leak fix is to hand DNS to the client as well. The short version: there are two routes here, and you should try the simple one first.
- Route one (try this first): turn on TUN mode in the client, turn off the browser's "Secure DNS", then re-test. Three steps, all switches, no config files touched. Most people are done here.
- Route two (only if route one fails): go into the client and change the DNS config, using fake-ip so nothing is resolved for real locally. This means pasting YAML — the advanced route.
This test has nothing to do with whether your exit IP is any good — changing settings fixes it. If what you mainly want is to tell whether the browser and the terminal each leak separately, start with How to check for Claude Code DNS leaks.
First, check which client you're using
All the steps below are written for "Clash Verge Rev", since it's the most common one on desktop. If that's not what you installed, match it up first:
| What you see | What you're using | What to do |
|---|---|---|
| Vertical menu on the left with Settings / Profiles / Connections / Logs | Clash Verge Rev | Follow the steps in this article as written |
| Dark UI with Proxies / Rules / Global at the top | Clash for Windows (no longer maintained) | The switch is under Settings → TUN Mode |
| Very plain UI, just a node list and a switch | v2rayN | No TUN switch; see "Tried all three steps and it still leaks" at the end |
| A rocket icon on your phone | Shadowrocket | See the "How to do it on a phone" section |
Can't tell? No problem: open the client and look for a switch labelled something like "TUN", "virtual adapter" or "enhanced mode". If it's there, do route one; if not, skip to the fallback at the end.
What is this test actually checking? (skip if you don't care about the theory)
The test page has the browser resolve a randomly generated subdomain, then checks which DNS server made the query and where it is. If the query comes from your local ISP's DNS while your exit IP is overseas, it's flagged as a leak. You can see the full resolver list at DNS leak test. For how DNS recursion works, see Cloudflare's DNS explainer.
Three common causes:
- Only the system proxy is on: the browser first resolves the domain using the system DNS (usually the ISP's), then hands the connection to the proxy.
- The client's DNS isn't configured properly: the DNS module is off, or the nameserver is set to the ISP's DNS.
- The browser has its own "Secure DNS" on: the browser connects straight to some DoH server, bypassing the client entirely. The DoH spec is RFC 8484.
Of these three, causes 1 and 3 can both be fixed without touching the config — that's exactly what route one below does.
Route one: the clash dns leak fix in three simple steps (no config needed)
Step 1: turn on TUN mode in the client
Where the switch is: in Clash Verge Rev, click "Settings" in the left menu, scroll down to "Virtual network adapter mode" (some versions just call it TUN mode), and turn it on.
Why this fixes a DNS leak: the system proxy only controls "who the browser hands the connection to", not "who resolves the domain". TUN mode takes over traffic at the network layer, so DNS queries get picked up too and are no longer sent straight to the ISP. There's a comparison table in System proxy vs. TUN mode.
Two places where people get stuck:
- Windows: the first time you turn on TUN, the client asks to install a background service (called "Service Mode" in the client). You have to agree and grant admin rights. If that service doesn't install, the TUN switch flips itself back off — it looks like it's on when it isn't.
- macOS: the system shows an "allow adding network configuration" prompt. Click allow. If you clicked deny by accident, re-authorize under System Settings → Privacy & Security, then come back and turn it on again.
How to confirm it's really on: turn off "System proxy" in the client. If the browser can still load web pages, traffic is going through the virtual adapter.
Step 2: turn off the browser's "Secure DNS"
This is the most commonly overlooked step, and the most common reason for "TUN is on but it still leaks". If the browser has secure DNS enabled, it goes straight to some DoH server without going through the client, and TUN can't stop it.
- Chrome / Edge: Settings → Privacy and security → Security → "Use secure DNS". If a domestic provider is specified there, turn the switch off, or set it to "Use your current service provider" so queries go through TUN.
- Firefox: Settings → Privacy & Security → scroll to the bottom to "DNS over HTTPS". Again, don't specify a domestic provider — choose "Off" or "Default protection".
Step 3: test again
Go back to the DNS leak test and look at the resolver list. As long as the resolver is no longer your local ISP and the location matches your exit, it's fixed. Then go back to the scenario test page, click "Fixed it, re-test" under the result, and see whether the DNS item now passes.
You're done at this point. What follows is for people who want to go further — read on only if route one didn't pass.
Route two: the advanced approach (optional)
Route one solves "who picks up the query"; route two solves "is anything actually being resolved locally at all". If this part doesn't make sense, skip it — route one is enough. If route one fails and you don't want to touch config, go straight to the fallback at the end.
fake-ip works like this: domains that go through the proxy aren't really resolved locally. The client just returns a fake address, and the real resolution happens on the proxy server's side, so your local network can't see what you looked up.
Here's a config snippet you can use as a reference (mihomo / Clash Meta core):
dns:
enable: true
ipv6: false
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16
nameserver:
- https://1.1.1.1/dns-query
- https://8.8.8.8/dns-query
proxy-server-nameserver:
- https://223.5.5.5/dns-query
tun:
enable: true
stack: mixed
auto-route: true
auto-detect-interface: true
dns-hijack:
- any:53Where exactly do you paste this config?
Two ways to do it; pick one.
Option A: use the client's "DNS Override" (recommended)
On the "Settings" page in Clash Verge Rev there's a "DNS Override" block (in some versions it sits under the "Clash settings" group). Paste the whole block starting at dns: into that box, save, then restart the core or the whole client.
Why this is recommended: the override is stored separately, so it won't get wiped when your subscription updates, and you won't have to redo it when you switch subscriptions later.
Option B: edit the live config file directly
In the "Profiles" or "Config" list, right-click the one you're using → "Edit file", paste the dns: block at the top of the file (before sections like proxies: and rules:; keep dns: flush left and indent the entries under it by two spaces), save, then restart the client.
The cost: this file was downloaded with your subscription, so the next subscription update overwrites the whole thing and you'll have to do it again. For long-term use, go with Option A.
You usually don't need to write the tun: block by hand: when you turn on the TUN switch, the client writes the tun section into the running config itself. It's listed above so you can see what the dns-hijack: any:53 line does — that's the key to "intercept every query on port 53". If you edit the file by hand per Option B, be careful not to delete or duplicate an existing tun: section.
What the fields mean:
enhanced-mode: fake-ip: enables fake-ip, the switch that stops real local resolution.nameserver: the DNS used when something really does need resolving; here it's encrypted DoH.proxy-server-nameserver: used only to resolve the proxy node's own domain. The node's domain has to be resolved before it can connect, so this uses a domestic DoH to avoid the node failing to connect.dns-hijack: any:53: hands every DNS query sent to port 53 on the system to the client.ipv6: false: if your exit doesn't support IPv6, turn it off first so IPv6 queries don't leak out.
If your subscription already includes a dns section, whatever the client shows after the override is what counts. Restart the client after changing anything.
How do you confirm fake-ip is actually working?
No logs, no commands — just run the DNS leak test again: if the resolver list no longer shows your local ISP and the location matches your exit, it's working.
If you want to be more certain, check the client's "Logs" page for fake-ip entries. If there are none at all, the config probably wasn't loaded — go back and check whether you pasted into the override box or edited the wrong file.
How to do it on a phone
Mobile clients usually run in VPN mode, which takes over all traffic by itself, so DNS leaks are less common than on desktop. If it still leaks, check the following.
iPhone (Shadowrocket)
- Make sure it's really taking over everything: on the home screen, set "Global routing" to "Config" or "Proxy", and turn on enhanced mode. "Direct" means no proxy at all. For what the four options mean, see Shadowrocket global routing: config or proxy?.
- Make DNS follow the exit: set DNS in the config file (the
dns-serverentry in the[General]section). Don't leave it blank and let it use the ISP's DNS. - Turn off IPv6: if the mobile network has IPv6 and the proxy only handles IPv4, IPv6 queries go out directly. If you're not sure, turn IPv6 off in settings.
- Browser: Safari on iOS has no "Secure DNS" switch, so nothing to do there; if you installed Chrome on your iPhone, its secure DNS switch needs turning off just like on desktop.
Android
- Make sure VPN mode is on: clients like Clash for Android and Clash Meta for Android need VPN / TUN mode enabled in settings, otherwise only apps that support the system proxy will go through the proxy.
- DNS settings: in the client's DNS settings, confirm the ISP's DNS isn't filled in; clients that support overrides can take the
dns:block above straight into the override box. - Turn off IPv6: same as above — keep IPv6 queries from leaking out.
- Browser: in Android Chrome, "Settings → Privacy and security → Use secure DNS" also needs turning off.
Menu names on phones vary a lot between versions. If you can't find the matching item, go by what your current client version shows rather than copying paths from older guides.
How to verify after the change
Don't skip this step. Plenty of configs look right but are still leaking — not testing is the same as not changing anything.
- Quit the browser completely and reopen it (on macOS use Command + Q to quit, not just closing the window), and restart the proxy client too. DNS caches linger for a while after a config change, so testing without restarting easily leads to the wrong conclusion that "the change did nothing".
- Go to the DNS leak test and look at the resolver list: if the resolver is no longer your local ISP and the location matches your exit, it's fixed.
- Go back to the scenario test page, click "Fixed it, re-test" under the result, and see whether the DNS item now passes.
No command line, no logs — the resolver list on the test page is the final answer.
Tried all three steps and it still leaks?
Do these three things in order instead of tweaking the same setup over and over:
- Try a different client. With the same node, switch to Clash Verge Rev or v2rayN and turn on TUN again — that rules out "this client's service didn't install properly on your system".
- Check your router and network adapter. If the ISP's DNS is manually filled in on the router or the adapter, queries bypass the client and go straight out. Set those back to "automatic".
- Still stuck? Leave a request on the test page. Leave an email under the scenario test result with your exit IP, the client you're using and which step you're stuck on, and we'll help you work out where the chain breaks.
FAQ
What if it still doesn't pass?
If DNS is fine but the test still fails, look at the other items: timezone/IP mismatch and WebRTC leaks can also be fixed by changing settings; datacenter IPs, blacklists and proxy flags are problems with the exit IP itself, and no setting will fix those.
With TUN mode on, do I still need to check DNS?
Yes. TUN takes over traffic, but if the browser has secure DNS on, it may resolve on its own and bypass the system resolver — and still leak.
What do I need to restart after the change?
Both the proxy client and the browser. DNS caches and existing connections linger for a while after a config change.
Will fake-ip break some sites?
Domains are no longer resolved for real locally, so a few LAN devices or apps that depend on the real IP may misbehave. If that happens, exclude those domains with fake-ip-filter in the config.
Is a DNS leak related to the exit IP?
No. It's about the resolution location not matching the exit location, and changing settings fixes it. An exit IP that's flagged is a separate matter.



