DNS Leak Test: Compare Your IP and DNS Resolvers
If you want DNS queries for proxied traffic to go through the proxy too, seeing your proxy IP on a web page is only the first check. Your browser may load the page through the proxy while sending domain lookups to your local network or a resolver you configured. DNS leak test sites typically generate temporary subdomains and report which recursive resolvers queried their test servers. They show the resolvers’ egress IPs, not the full path your device took to reach those resolvers.
- Establish a baseline. Turn off the client and run a test on the same device, browser, and network. Note the web page’s egress IP and the resolver provider and IP addresses. A standard test page is enough; there’s no need to visit a page containing personal information.
- Pin the proxy endpoint. Start the client and select a specific proxy node in the policy group used for testing, rather than allowing automatic switching. Run the same test again. First confirm that the web connection is actually using the proxy; if it still goes direct, this test can’t tell you how proxied traffic’s DNS is routed.
- Check the DNS path. If a resolver from your baseline still appears, inspect the client logs for the corresponding queries and upstream connections. If the client doesn’t show DNS details, use system network-monitoring tools to verify the path. Even if the page shows only the expected public resolver, distinguish between connecting to that resolver directly and reaching it through the proxy.
fake-ip and nameserver-policy: Configure DNS and Upstream Routing
enhanced-mode: fake-ip makes the built-in DNS server return a virtual address that it maps to the original domain. When the connection then passes through the same core, the core can recover the domain and use it for rule matching. In the configuration below, apps seeing test addresses in the 198.18.0.0/16 range is expected; these aren’t the website’s real addresses. fake-ip doesn’t determine whether DNS queries go direct or through the proxy, and it can’t intercept queries that never reach the core.
This example uses mihomo’s DNS upstream policy-group suffix syntax. First, make sure the active configuration has a usable proxy policy group. Replace both instances of DNS-Egress with its exact name, then select a proxy node for that group during testing—not DIRECT. Merge the example into your existing top-level dns section; don’t add a second dns: key. If your subscription manages the configuration, use the client’s override feature to save the changes and check that they remain in effect after the subscription refreshes.
dns:
enable: true
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16
nameserver:
- 'https://1.1.1.1/dns-query#DNS-Egress'
nameserver-policy:
'+.example.org':
- 'https://1.0.0.1/dns-query#DNS-Egress'
proxy-server-nameserver:
- 'https://9.9.9.9/dns-query'
nameserveris the default upstream for regular domain lookups. The example connects to the DNS service over HTTPS (TCP 443 by default) and explicitly specifies a proxy group. Changing onlyudp://tohttps://changes the transport, but does not automatically route the upstream connection through the proxy.nameserver-policyselects an upstream by domain; it isn’t a traffic-routing rule like those inrules.+.example.orgmatches the apex domain and its subdomains and is only an example you can replace. If you don’t need to assign resolvers by domain, remove the entire policy block. Temporary domains used by leak test sites typically won’t match it.proxy-server-nameserverresolves the hostnames of proxy servers. The example sends these lookups directly to a separate DoH upstream, so proxy nodes can still be resolved before the proxy is available. This is an intentional startup exception, not the route for regular domain lookups. If you bind it to a policy group that depends on the same node, resolving the node’s hostname can create a loop.
Older Clash for Android cores may not support the mihomo fields or upstream suffix syntax shown here. Being able to import a YAML file doesn’t mean every field will be applied. If the logs report unknown fields or the actual egress doesn’t change, first check which core is running and what configuration the client generated. Don’t treat this as a universal fix for older cores.
fallback-filter: Filter DNS Responses, Not Query Routing
This example doesn’t include fallback by default. For queries that use regular upstream selection and aren’t assigned separately by nameserver-policy, enabling fallback may send requests to the primary and fallback upstreams in parallel. fallback-filter affects which response is used; it doesn’t wait for the primary to fail before allowing the fallback server to see the query. If your subscription includes a direct fallback resolver, routing only the primary upstream through a proxy group may still leave queries going direct.
If you need to filter responses by IP—for example, if you’ve confirmed that the primary upstream returns unusable addresses in 240.0.0.0/4 for public domains—you can merge the block below into the preceding dns section. This is an example for a known response, not a general-purpose list of poisoned IP ranges. The fallback upstream uses the same proxy group to keep the primary and fallback routes consistent.
fallback:
- 'https://8.8.8.8/dns-query#DNS-Egress'
fallback-filter:
geoip: false
ipcidr:
- 240.0.0.0/4
geoip: false means this example doesn’t filter primary upstream responses by the country associated with their IP addresses. Even with a GeoIP condition enabled, an IP’s location isn’t evidence of a DNS leak: a CDN server address, a DNS resolver’s egress IP, and the proxy egress IP used to access a website are three different things.
TUN and dns-hijack: Intercept Port 53 Queries Entering the Virtual Interface
System proxy settings usually affect only connections that honor them, and an app’s DNS queries don’t necessarily pass through the client. For mihomo clients that support these fields, allow custom TUN settings, and have the required permissions, merge the configuration below into the top-level tun section. It forwards standard UDP and TCP DNS queries that pass through TUN to the built-in DNS server, which then handles them using the upstream settings above.
tun:
enable: true
auto-route: true
dns-hijack:
- 'any:53'
- 'tcp://any:53'
- Android VPN: Clash for Android usually captures traffic through Android’s VPN service; the app may not read the desktop
tunsection. First, make sure the VPN is running and check that app-based split tunneling hasn’t excluded the browser you’re testing. On recent versions of stock Android, go to “Settings → Network & internet → Private DNS.” On manufacturer-customized Android, search Settings for “Private DNS.” - Encrypted DNS: These two
dns-hijackrules only handle port 53 traffic entering TUN. Private DNS typically uses DoT over TCP 853, while browser-based DoH usually uses port 443; neither is redirected to the built-in resolver by these rules. In desktop Chrome, check “Settings → Privacy and security → Security → Use secure DNS” to see whether a different resolver is selected. For a controlled comparison, change one setting at a time. After testing, restore the original settings or explicitly keep the new DNS route. - LAN and dual-stack: Route exclusions, app-level bypasses, and platform limitations can all prevent queries from entering TUN. If your network supports IPv6, check both IPv4 and IPv6 paths when you retest.
dns.ipv6: falseaffects how the built-in DNS server handles AAAA queries; it doesn’t take over IPv6 routing.
If internal domain names stop working after the change, first check whether they require a private resolver provided by your organization or router. For domains that must return real IP addresses, you can add narrowly scoped exceptions with fake-ip-filter, if supported by your core, and separately specify an upstream that can resolve those domains. Excluding a domain from fake-IP alone won’t make public DNS recognize internal names.
Retest After the Fix: Rule Out Bypasses One by One
| Result | Next step |
|---|---|
| Web egress changes, but the ISP resolver still appears | First check the browser’s Secure DNS and the system’s Private DNS settings, then look for a direct fallback in the active configuration. |
| VPN is on, but the proxy node hasn’t connected | Check whether proxy-server-nameserver can resolve the node’s hostname and whether that upstream was mistakenly routed through a group that depends on the same node. |
| Browser works, but other apps behave differently | Check whether the app is covered by the VPN and whether it uses its own resolver. A browser test can’t represent how other apps handle DNS. |
Use the fresh queries generated by the test site for each run so cached results aren’t mistaken for new network activity. When you’re done, turn off detailed diagnostic logging, restart the client, and run one more test with your everyday configuration. A successful result means the web connection uses the expected proxy, regular DNS upstream connections use the specified proxy group, and direct DNS is limited to startup or internal-network exceptions you’ve verified and accepted.