Troubleshooting About 8 min read

Clash DNS Leak Test and Prevention: fake-ip Configuration Guide

Learn how to test for DNS leaks, compare redir-host and fake-ip modes, and configure nameserver and fallback groups in Mihomo.

How to Check for a DNS Leak: Start by Finding Out Where Queries Go

A DNS leak occurs when a browser, operating system, or app sends a domain lookup to an unintended resolver instead of routing it through Mihomo. Check the upstream route separately, too: Mihomo can handle a query while still connecting directly to its upstream resolver. If DNS traffic must also use the proxy, verify the route taken by the upstream connection.

DNS leak test sites typically trigger lookups for a set of temporary domains, then show which recursive resolvers queried the test provider’s authoritative DNS servers. This can point to the resolvers involved, but it can’t tell you by itself where your device sent the query, whether it was encrypted, or whether it went through a proxy. It’s common for the proxy server and recursive resolver to be in different regions; that alone is not evidence of a leak.

Establish a baseline, then change one setting at a time

  1. In a test environment where direct connections are allowed, pause the proxy and TUN, then run a test in the same browser. Note the resolvers and providers shown. The test uses temporary domains, so you don’t need to enter the address of a site you’re visiting.
  2. Enable your usual configuration and generate a fresh set of test domains. Keep the network unchanged, and note the client settings, browser encrypted DNS settings, and test results. Refreshing an old result does not count as a new test.
  3. Change one setting at a time and test again. For example, in Chrome, go to Settings → Privacy and security → Security and temporarily turn off Use secure DNS to see whether the browser’s own DNS path is responsible. On managed devices, keep the organization’s policies in place.
  4. If the test still shows an unexpected resolver, check the client logs and system DNS settings. In Windows PowerShell, Get-DnsClientServerAddress lists the resolvers configured for each network interface. This is a configuration clue, not proof of which address handled a particular query.

fake-ip vs. redir-host

fake-ip returns a virtual IP to the app, then uses the kernel’s mapping to resolve the domain. redir-host returns the real IP received from the upstream resolver. With either mode, the query must actually reach the kernel. Changing only enhanced-mode won’t affect encrypted DNS requests sent directly by the browser.

ModeAddress returned to the appConfiguration and troubleshooting
fake-ipUsually a virtual address; exceptions can return a real address.Connections the app sends to a virtual address must also pass through the kernel. Otherwise, DNS may appear to work while connections time out.
redir-hostThe real address returned by the upstream resolver.Useful for apps that need real addresses. Without domain context, don’t assume every connection can match a domain-based rule.

Mihomo DNS Configuration: Grouping nameserver and fallback

This is a Mihomo configuration snippet, not a complete subscription. Back up your configuration first, then merge these fields into the dns section the client actually passes to the kernel. Don’t add a second top-level key with the same name. If the client supports local overrides, save and reload them, then confirm the final effective configuration. Older Clash kernels may not support every field shown here.

dns:
  enable: true
  listen: 127.0.0.1:1053
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  default-nameserver:
    - https://1.1.1.1/dns-query
  proxy-server-nameserver:
    - https://1.1.1.1/dns-query
  nameserver:
    - https://1.1.1.1/dns-query
  fallback:
    - https://9.9.9.9/dns-query
  fallback-filter:
    geoip: false
    ipcidr:
      - 0.0.0.0/32
      - 127.0.0.0/8
  • listen restricts the test endpoint to the local loopback address on port 1053. Regular system lookups usually use port 53; they won’t be redirected just because the kernel is listening on 1053.
  • default-nameserver resolves hostnames for DNS upstreams that need a bootstrap lookup. The upstream URLs in this example use IP addresses, so their hostnames don’t need to be resolved first. proxy-server-nameserver resolves the server hostnames of proxy nodes specifically; that’s a separate path from regular website lookups.
  • nameserver is the primary upstream group for regular queries. This example uses DoH (DNS over HTTPS), which carries DNS queries over an HTTPS connection. It protects query contents between your device and the resolver, but doesn’t require that HTTPS connection to use a proxy.
  • fallback doesn’t necessarily mean a backup server used only after the primary group times out. The kernel can query both groups in parallel and select a result using fallback-filter. This example disables GeoIP filtering and shows the fallback group being used when the primary group returns 0.0.0.0 or an address in 127.0.0.0/8. The fallback resolver may receive the same domain, too. If queries must go to only one DNS provider, remove fallback and its related filter section.

If your subscription also includes nameserver-policy, check whether the test domain matches a separately specified upstream instead of looking only at the primary group. Handle internal domains separately, too: fake-ip-filter can make a domain return a real address, but it won’t automatically send that query to your internal DNS server. For company or home-network private domains, check the upstream policy as well to avoid sending internal names to a public resolver.

Route system queries through TUN, then test three paths

TUN is a virtual network interface created by the client to receive traffic routed by the operating system. With only the system proxy enabled, apps that honor proxy settings may send domain lookups to the proxy or resolve them first; apps that don’t use the system proxy have their own DNS paths. To check conventional DNS queries from the system, back up your configuration and merge the three fields below into Mihomo’s tun section. If the client manages TUN through its interface, check the running configuration after applying the settings to make sure they weren’t overridden.

tun:
  enable: true
  auto-route: true
  dns-hijack:
    - any:53
    - tcp://any:53

auto-route lets the kernel configure system routes. The two dns-hijack entries intercept UDP and TCP queries on port 53 that enter TUN. They can’t handle queries that never enter TUN, or convert encrypted DNS requests on HTTPS port 443 or TLS port 853 into kernel queries. Whether local loopback or LAN DNS can be intercepted also depends on system routing, excluded interfaces, and the client implementation. Before enabling this, make sure the virtual network interface has the required permissions, and check whether another VPN on the same device is using the relevant routes.

Test the listener, system DNS path, and upstream route separately

  1. Check the kernel listener. If dig is installed, run dig @127.0.0.1 -p 1053 example.com A. If you get a virtual address from the example range, the request reached the kernel and triggered fake-ip. If it times out, first check that the kernel is running, the port is available, and the override took effect.
  2. Check the system and browser paths. Next, run nslookup example.com without specifying the local listener address, then generate a fresh test in your browser. The server shown by nslookup is the address it tried to query; it may not be the resolver that ultimately handled the recursive lookup after interception. If the local listener works but the browser test still looks wrong, check encrypted DNS, browser cache, and TUN routing first.
  3. Check the upstream route. To verify the upstream path, don’t rely on a virtual A record: returning a fake IP may not trigger a real lookup. Temporarily switch the same configuration to redir-host, then use a fresh test domain to inspect the kernel logs and outbound connections from your device. Check whether it connects directly to the example addresses 1.1.1.1:443 or 9.9.9.9:443. If the upstream should use a proxy but the connection is direct, inspect the DNS upstream routing separately. Before enabling respect-rules to route DNS by rules, make sure the proxy node’s hostname has a working bootstrap resolution path; otherwise, you may require the node to resolve its own hostname before it has connected.

Keep the original configuration that works while testing. If a change leaves websites unreachable and proxy node hostnames unresolved, undo the latest override first. Then troubleshoot node hostname resolution, regular domain lookups, and connection routing separately. The goal is to confirm that each query follows its intended path—not just to see a single result on the test page.

Download Clash