Clash DNS Leak Check: Where DNS Queries Go in fake-ip and TUN Mode
A Clash DNS leak means you assumed domain lookups would go to your proxy client or a resolver you picked, but some of them were actually sent by the operating system or an app to your local ISP's DNS. You can't confirm this from the config file alone. You have to check it in practice: look at the client log to see who is resolving, use nslookup to see what the system resolver returns, use an online test to see which resolver actually performs the lookups for you, and then compare all three against what you expected.
This article covers one thing: making DNS queries go where you intend. It is not about bypassing any platform's regional restrictions or risk controls. Follow local laws and the terms of the services you use when running proxy tools.
What does a DNS leak actually leak?
A DNS query is plaintext (unless you use DoH/DoT), and its content is the domain you want to visit. Who sends the query, and which resolver receives it, determines who can see the domains you visit. Common "not what you expected" cases:
- You wanted every query to use encrypted DNS, but the system is still using the ISP DNS handed out by DHCP.
- You wanted overseas domains to be resolved on the proxy exit side, but they were resolved locally first.
- You wanted domestic (China mainland) domains resolved by a domestic resolver so you get a nearby CDN node, but the queries went to an overseas resolver and access got slower.
Strictly speaking the last one is not a privacy problem, but the way to check is the same, so you can investigate them together. DNS pollution and hijacking are a different class of problem; see DNS pollution vs. DNS hijacking: how to tell the difference. For the concept of a leak and a comparison with WebRTC leaks, see /en/learn/dns-leak-webrtc-leak.
fake-ip vs. redir-host: who sends the domain query?
For Clash-family clients (including the mihomo core), dns.enhanced-mode is usually set to one of the two values below. The difference is what IP the application gets back.
fake-ip mode
When an application asks Clash's DNS for example.com, Clash does not actually resolve it. It allocates a fake address from fake-ip-range (default 198.18.0.1/16), returns that, and records in memory that this fake address maps to example.com. The application then connects to the fake address, the traffic enters Clash, Clash maps the fake address back to the domain, and the rules decide whether to go direct or through a proxy.
When traffic goes through a proxy, the domain is passed as-is to the proxy node, which resolves it on its side. So in the ideal case, no real local DNS query is sent for that domain.
There is one easily missed catch: if your rules contain IP-based rules such as GEOIP or IP-CIDR without no-resolve, Clash needs the real IP of the domain when it reaches that rule, and it resolves the domain once using the servers in nameserver. This is one of the most common reasons you still see local queries with fake-ip enabled.
redir-host mode
When an application asks for a domain, Clash resolves it for real using nameserver (and optionally fallback) and returns the real IP to the application. In other words, every domain an application queries goes through your configured upstream resolver, whether it ends up going direct or through the proxy. Whoever runs the upstream sees the queries.
The two modes side by side
| Item | fake-ip | redir-host |
|---|---|---|
| Address the app gets | Fake 198.18.x.x address | Real IP |
| Are proxied domains resolved locally? | Not by default; left to the node | Yes, resolved with nameserver |
| When local resolution still happens | IP rules without no-resolve; domains matching fake-ip-filter | All queries |
| Common side effects | Programs that depend on real IPs (LAN discovery, some games, NTP) need to be added to fake-ip-filter | Results depend on the upstream and may return polluted addresses |
Why do some programs still use local DNS when the system proxy is on?
The "system proxy" just registers an HTTP/SOCKS proxy address in the operating system. Whether a program uses it, and how, is up to the program:
- Programs that ignore the system proxy: many command-line tools, games and some desktop clients connect directly and resolve domains with the system resolver. The queries go to the system DNS and Clash never sees them. For the typical command-line case, see the environment-variable troubleshooting in Claude Code proxy settings not working.
- Programs using an HTTP proxy: a browser hands the domain to the proxy via
CONNECT example.com:443, so it generally doesn't resolve locally. - Programs using a SOCKS5 proxy: it depends on whether the program passes the domain to the proxy (remote resolution) or resolves it to an IP locally first and then passes the IP to the proxy. The latter produces local queries.
- The browser's built-in secure DNS (DoH): the browser sends HTTPS requests straight to its DoH server, bypassing both the system resolver and Clash's DNS. For where to configure DoH, see DNS over HTTPS setup guide.
So in system proxy mode, whether there is a leak often varies by program. A clean result in the browser doesn't mean the tools in your terminal are clean too.
What do TUN mode and dns-hijack solve?
TUN mode creates a virtual network adapter and points routes at it, so traffic from programs that don't read proxy settings also enters Clash. But even when the traffic comes in, DNS queries are not necessarily taken over. If the system DNS is still 192.168.1.1 or an ISP address, queries sent to port 53 need to be intercepted and handed to Clash's DNS module. That is what dns-hijack does.
Below is a mihomo config snippet meant only to illustrate what the fields mean (it is not a recommended config; replace the addresses with the resolver you choose):
dns:
enable: true
listen: 0.0.0.0:1053
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16
fake-ip-filter:
- "*.lan"
- "+.local"
# Only used to resolve the domain of the DoH server in nameserver; must be an IP
default-nameserver:
- 223.5.5.5
nameserver:
- https://dns.example-resolver.com/dns-query
# Server used to resolve proxy node domains
proxy-server-nameserver:
- https://dns.example-resolver.com/dns-query
# Make DNS queries themselves follow the rules (requires proxy-server-nameserver)
respect-rules: true
tun:
enable: true
stack: mixed
auto-route: true
auto-detect-interface: true
dns-hijack:
- any:53
- tcp://any:53
Key points:
dns-hijackcan only intercept plaintext queries on port 53. DoH (port 443) and DoT (port 853) sent by programs themselves can't be intercepted.default-nameserveris only used to resolve the upstream DoH server's own domain. It produces a few local queries, which is expected.- For IP-based entries in the rules, add
no-resolveif you don't want them to trigger local resolution, for exampleGEOIP,CN,DIRECT,no-resolve. The trade-off is that the rule only takes effect when the connection target is already an IP. - Look at IPv6 separately: if TUN doesn't take over IPv6 and the system gets an ISP DNS over IPv6, queries will go out on the IPv6 side. For exit mismatches on dual-stack networks, see IPv6 proxy not working.
Exact field names and defaults depend on the official documentation for the core version you use; they differ between branches.
What does it mean when nslookup returns 198.18.x.x?
On a machine with fake-ip enabled, run:
nslookup example.com
- Returns 198.18.x.x: the system resolver's query was caught by Clash (the system DNS points at Clash, or it was intercepted by
dns-hijack). This is fake-ip working normally and is not a problem in itself. - Returns a real IP: this query did not go through Clash's fake-ip. Possible reasons are that the system DNS wasn't taken over, the domain is in
fake-ip-filter, or you are in redir-host mode. - Query a specific server, for example
nslookup example.com 1.1.1.1: with TUN anddns-hijackon, this should also return 198.18.x.x, which means plaintext queries sent to external port 53 were intercepted. If it returns a real IP, queries sent directly to the outside are not being taken over.
Note that fake-ip addresses only mean something on the local machine. Don't put them in hosts files or any other configuration.
Self-check procedure: confirm where DNS actually goes, step by step
Work through the checklist below in order, write down the result of each step, and compare with your expectation at the end.
Step 1: Write down your expectation. For example: "Domestic domains use a domestic resolver, all other domains are resolved on the proxy node side, and no plaintext queries appear locally." Without an expectation, you can't tell whether anything is leaking.
Step 2: Confirm the current mode. In the client UI or config, confirm: system proxy or TUN; whether enhanced-mode is fake-ip or redir-host; whether dns-hijack is enabled; and whether IP-based entries in the rules have no-resolve.
Step 3: Read the client log. Temporarily set the log level to debug and visit a few websites. mihomo's debug log shows DNS query records and which upstream server was used. Look in particular for domains that should go through the proxy but show up in local resolution records. Set the log level back when you're done.
Step 4: Test the system resolver with nslookup. Test both the default resolver and a specified external server (see the previous section) to confirm whether system queries and port 53 queries are being taken over.
Step 5: Run an online test in the browser. Open cdnping's IP and environment check and look at two items:
- DNS leak test: the general approach of this kind of test is to have the browser resolve a batch of random subdomains, then see which resolvers actually query the authoritative server. If you expected resolution on the proxy side but see your local ISP's resolver, some queries were sent locally.
- Mainland split-routing check: it reads the client IP and latency reported back by mainland China CDNs (NetEase, Tencent, Douyin, Weibo, Youku, Xiaohongshu and others) to decide whether you are currently in "mainland split routing", "global proxy" or "direct domestic connection". This helps you confirm whether the path of domestic-domain traffic matches your configuration. For the principle and what the three results mean, see How Chinese websites see your real IP; for the concept of split routing itself, see /en/learn/split-tunneling.
While you're on the same page, also take a look at the WebRTC leak test. It is a separate path from DNS; for how to turn it off, see How to disable WebRTC leaks.
Step 6: Test again with a program that doesn't read proxy settings. A browser result only describes the browser. In a terminal, use curl to access a domain while watching the client log to confirm where command-line tool queries go.
Step 7: Compare the results.
| What you see | Likely cause | What to change first |
|---|---|---|
| nslookup returns a real IP, and the test shows an ISP resolver | System DNS is not taken over | Enable TUN and dns-hijack, or point the system DNS at Clash's listen address |
| With fake-ip, the log still shows local resolution for proxied domains | IP rules trigger resolution | Add no-resolve to GEOIP and IP-CIDR rules, or enable respect-rules |
| Browser test result differs from nslookup | The browser is using its own DoH | Check the browser's secure DNS setting and make it consistent with your expectation |
| IPv4 looks fine, but an ISP resolver appears on the IPv6 side | TUN does not take over IPv6 | Check the core's IPv6 settings, or unify the IPv6 policy in the system |
| Domestic sites are slow, and the split-routing check shows "global proxy" | Domestic domains are resolved overseas or sent through the proxy | Check nameserver-policy and the split-routing rules |
How do I confirm after making changes?
After each config change, restart the client, flush the system DNS cache (ipconfig /flushdns on Windows, sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder on macOS), reopen the browser, and then redo the process from Step 3. DNS is cached, and if you don't flush it you'll often be looking at old results.
If you want to go through items beyond DNS as well, such as exit IP type, IPv6 and AI API connectivity, follow the order in the Developer network self-check list (2026 edition). Finally, use cdnping online speed test to look at the first-connection time for each API. First-connection time includes DNS resolution, so when resolution takes a detour this number is usually higher.