What Is a DNS Leak? Separate Website Connections from DNS Queries

When you open a website, your browser usually looks up its domain name to get an IP address before connecting. Those two steps can take different routes: the website connection may go through a proxy while the DNS query still goes through your system to your router or ISP. The reverse can also happen: your browser may use encrypted DNS directly, bypassing your system's DNS settings entirely. The IP address shown for your website connection doesn't tell you where the DNS query went.

A leak means a DNS query went to a resolver or over a network path you didn't intend to use. For example, you might expect mihomo to send public-domain queries to a specified encrypted upstream, but see plaintext DNS requests to your router on the physical network adapter when visiting those sites. If your company’s internal domains are supposed to use its resolver, queries to that resolver over the local network aren't leaks under this policy.

First, write down two expectations: Who should resolve DNS for regular websites? Who should resolve internal company or home domains? A difference between the resolver's country or region and the proxy exit location isn't enough on its own to prove a leak.

How to Check for DNS Leaks: Compare Test Results with Network Traffic

Establish a Baseline in the Same Browser

  1. On a network where comparison testing is permitted, turn off the client's TUN mode and system proxy, then run a DNS leak test in the same browser. Note the resolver IPs and networks shown by the test, along with the public IP used by the browser. Record the browser's Secure DNS status, and avoid changing several settings during the test.
  2. Enable the configuration you want to verify and run another test that generates fresh test domains. Check whether the original resolvers still appear; don't focus only on the location labels. If the test page reuses old results, start a new test. Simply refreshing a site you've already tested may hit the browser or system cache.
  3. To check whether TUN is capturing system DNS, you can temporarily turn off the browser's own Secure DNS. In Chrome, open chrome://settings/security and find “Use secure DNS.” Restore the original setting after the test, then run another test to confirm the path used during normal browsing. Don't change this setting yourself on a device managed by your organization.

DNS leak test sites typically show the recursive resolver that queried their authoritative server for a test domain. Its IP may differ from the upstream address in your configuration, and the test can't cover other apps. If an unexpected resolver appears in only one browser, check that browser's Secure DNS settings before changing the system-wide configuration.

Check for Outgoing DNS Queries on the Physical Network Adapter

To inspect the actual path, select the active Wi-Fi or Ethernet interface in Wireshark—not just mihomo's virtual adapter. Apply the display filter below, trigger a fresh test query, and check the destination address, domain name, and timestamp of the query packet:

udp.dstport == 53 || tcp.dstport == 53

For example, if public domains should use the configured HTTPS upstream but you see a test-domain query going from the physical adapter to 192.168.1.1:53, investigate that traffic. If the packet contains a printer or internal service domain, check your local exceptions first. This filter only matches traffic to destination port 53. No matching packets doesn't rule out a browser using DNS over HTTPS on port 443 or an app using DNS over TLS on port 853.

mihomo DNS Configuration: fake-IP and Upstream Groups

The examples below use mihomo, the successor to the Clash Meta core. First, check which core the client is running, then confirm that the active configuration supports overrides or merging. Older versions of Clash may not support these fields. If your provider generates the subscription, use the client's override feature where possible so a subscription update won't overwrite your local changes.

dns:
  enable: true
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  fake-ip-filter:
    - '+.lan'
  default-nameserver:
    - 'https://1.1.1.1/dns-query'
  nameserver:
    - 'https://1.1.1.1/dns-query'
  proxy-server-nameserver:
    - 'https://1.0.0.1/dns-query'
  • enhanced-mode: fake-ip lets the core return a synthetic address to an app first. For example, when a regular domain returns an address such as 198.18.0.2, the core can use its mapping to recover the domain and apply the connection rules when it handles the subsequent connection. A synthetic address isn't the website's real address, nor does it prove that DNS is encrypted. The app must also hand the connection back to the same core, or it may fail to connect using the synthetic address.
  • nameserver is the default upstream for regular domain queries. This example uses DNS over HTTPS (DoH). Routing a site's connection through a proxy doesn't automatically send the DoH request through the same exit. If DNS upstream traffic must also use the proxy, verify the core's configuration and actual egress separately.
  • default-nameserver is used for bootstrap lookups, such as resolving the address of a DNS upstream specified by hostname. This example uses an IP-based DoH URL to avoid relying on another domain lookup before reaching the upstream. If you switch to an upstream with a hostname, make sure bootstrap resolution still works.
  • proxy-server-nameserver handles the server hostnames used by proxy nodes. These lookups may be needed before a node connects, so the upstream must be reachable while the node is still offline. The two IP addresses in this example are access points for the same service, not two independent DNS providers.

Local Network Domains: Returning Real IPs and Choosing a Resolver Are Separate

In the example above, fake-ip-filter prevents requests matching +.lan from receiving synthetic addresses, but it doesn't automatically select your router's DNS. If your home router at 192.168.1.1 resolves that suffix, add the following entries to your existing dns section. Replace the examples with your confirmed internal suffix and resolver address. Don't send company domains to a public upstream to see if they resolve.

  nameserver-policy:
    '+.lan': '192.168.1.1'

Here, fake-ip-filter makes sure apps get real addresses, while nameserver-policy sends queries to a resolver that knows the answers. If a service still won't open after the router returns an address, check whether your connection rules allow access to the corresponding private IP. Changing the DNS upstream doesn't change connection routing.

TUN DNS Hijacking: Capture Port 53 Traffic Entering the Virtual Adapter

A system proxy usually covers only apps that respect proxy settings. TUN mode receives IP traffic routed through a virtual network adapter, so it can cover more apps. The DNS hijack rules below send matching standard DNS requests to the core's DNS module instead of letting them reach their original resolver. This only works if the requests actually enter TUN.

tun:
  enable: true
  stack: mixed
  auto-route: true
  auto-detect-interface: true
  dns-hijack:
    - 'any:53'
    - 'tcp://any:53'

The first rule handles UDP port 53; the second adds TCP port 53. auto-route configures the system routes needed to capture traffic, while auto-detect-interface automatically identifies the outbound interface. Merge the example fields into the existing sections with the same names—don't add a second tun or dns section. If the client UI generates TUN settings, check the final applied configuration after making changes, not just the original subscription.

These rules can't rewrite browser-based DoH, DoT traffic from apps, or local DNS traffic that never enters TUN. On dual-stack networks, inspect IPv4 and IPv6 traffic separately. Even disabling AAAA responses in the core's DNS module won't change system routing for queries an app sends to an IPv6 resolver address.

Retest After Configuration: Narrow Down Issues by Symptom

Common DNS Configuration Symptoms and What to Check
Symptom What to Check First
Browser results look normal, but other apps still send plaintext DNS queries Compare a packet capture from the physical adapter with the app's logs. Check whether routing exclusions or interface binding are letting the app bypass TUN. Don't treat a browser test as a verdict on the whole device.
An app gets a synthetic address, but the connection times out First, confirm that the core that created the mapping is handling the subsequent connection, then check which egress the rules selected. A synthetic address alone doesn't tell you whether the upstream is reachable.
Proxy node hostname won't resolve Check the client logs for the node hostname and DNS timeouts. Make sure proxy-server-nameserver doesn't depend on a proxy that isn't connected yet and isn't blocked by the current network.
Public sites work, but internal services don't First, check that queries go to the internal resolver and return real private IP addresses. Then check that connections to those IPs use the correct route.

Change one setting at a time, then repeat the test with a new domain. To verify the setup, cover at least three paths: browser queries go only to the expected resolver; public-domain queries from regular apps are no longer sent in plaintext from the physical adapter to the router; and explicitly defined internal domains are still resolved by the internal resolver. Retest after switching to a mobile hotspot, company network, or another VPN, since interfaces, routes, and system-provided resolvers may change.