Home/Blog/The Complete DNS Guide

The Complete Clash DNS Guide: Fake-IP, DNS Tampering & Self-Hosted Resolution

No matter how precise your rules are, if the IP a domain resolves to is simply wrong, routing never had a chance. This article breaks down how DNS tampering works, the difference between Clash's two resolution modes, encrypted DNS, and per-domain resolution strategy โ€” so you can debug "the rule is clearly right, but traffic still goes the wrong way" problems from the root cause.

๐Ÿ—“๏ธ July 10, 2026 โฑ๏ธ About 9 min read ๐Ÿ”— Related: Advanced Configuration ยท DNS & Fake-IP

Why DNS Is the Usual Culprit Behind Broken Routing

Plenty of people spend ages tweaking rules only to find a site still goes through the wrong line, and their first instinct is "the rule must be wrong" โ€” but the real cause is often a step earlier: DNS resolution.

Rule-based routing depends on first knowing whether a domain/IP should go through the proxy, and that decision has two possible inputs: the domain itself (DOMAIN, DOMAIN-SUFFIX, etc. rules) and the resolved IP (IP-CIDR, GEOIP, etc. rules). If DNS resolution goes wrong at this step, every IP-based decision downstream gets it wrong too:

  • DNS tampering / hijacking: some networks return incorrect or unreachable IPs for specific domains โ€” most often seen with domains that are blocked or restricted on that network.
  • ISP DNS returning the "nearest" result: an IP returned for CDN acceleration purposes may not be the endpoint you actually meant to connect to, which can throw off GEOIP-based decisions.
  • Local hosts file / cache poisoning: a stale or incorrect record cached at the OS or router level โ€” restarting your client won't help here, since the problem isn't in Clash at all.
๐Ÿ’ก

When debugging "this rule isn't working," DNS should be the first thing you check after the rule syntax itself โ€” not the last.

Fake-IP vs. Redir-Host: Weighing the Two Modes

Clash's dns.enhanced-mode setting determines the underlying resolution behavior, and each mode has its own trade-offs:

Fake-IP Mode

  • Assigns each domain a fake, locally-scoped IP; real resolution is deferred until a connection is actually made
  • Rules can match on the domain name directly, giving the best compatibility โ€” the default recommendation under TUN mode
  • Downside: some programs that rely on getting the real IP for validation (certain games, corporate VPN clients) may not work correctly

Redir-Host Mode

  • Returns the genuine resolved result directly, closer to how a traditional network behaves
  • IP-CIDR / GEOIP rule matching is more accurate; more commonly used on routers/gateways
  • Downside: needs an actual DNS round trip before it can decide which proxy to use, adding one extra hop of latency

Neither is universally "better." A common rule of thumb: prefer fake-ip for desktop clients running in TUN mode; if a specific app misbehaves, exclude just its domain in fake-ip-filter rather than switching the whole mode.

Fighting Tampering With Encrypted DNS: DoH and DoT

A traditional DNS query is plaintext UDP traffic on port 53, which is easy for network equipment in the middle to inspect and tamper with โ€” one of the most common causes of DNS tampering. The fix is to wrap the DNS query inside an encrypted channel:

MethodFull NameCharacteristics
DoHDNS over HTTPSDisguised as normal HTTPS traffic, hard to fingerprint and block. Written like https://1.1.1.1/dns-query
DoTDNS over TLSEncrypted over its own dedicated port 853, somewhat easier to fingerprint than DoH. Written like tls://8.8.8.8
UDP (traditional)DNS over UDPPlaintext, fastest, but fully exposed to the network path โ€” fine to use for your ISP's own DNS, since you already trust that network
config.yamlyaml
dns:
  enable: true
  enhanced-mode: fake-ip
  nameserver:
    - 9.9.9.9
    - 208.67.222.222
  fallback:
    - https://1.1.1.1/dns-query
    - tls://8.8.8.8
  fallback-filter:
    geoip: true
    geoip-code: US

The idea, same as in the Advanced Configuration guide: use a fast plain DNS in nameserver for speed on everyday resolution, and an encrypted DNS in fallback for accuracy; fallback-filter decides when it's time to fall back. Set geoip-code to your own country/region code โ€” fallback-filter uses it to spot results that don't look right for your location and switch to the encrypted resolver instead.

Per-Domain Resolution: nameserver-policy

Sometimes a blanket "primary vs. fallback" split isn't granular enough โ€” you want to point specific domains at a dedicated DNS server, like a corporate domain that only resolves correctly through the internal company DNS. That's exactly what nameserver-policy is for:

config.yamlyaml
dns:
  nameserver-policy:
    'geosite:private': '9.9.9.9'
    '+.internal.company.com': '10.0.0.1'
    '+.google.com': 'https://1.1.1.1/dns-query'

nameserver-policy takes priority over the global nameserver / fallback settings โ€” think of it as an "exception list" for specific domains, which is exactly what you want for corporate intranets, self-hosted services, or anything else with its own resolution requirements.

โš ๏ธ

If an internal domain gets taken over by Fake-IP without being routed to the correct internal DNS, that internal service will "look connected" but time out endlessly. If you hit this, check whether nameserver-policy and fake-ip-filter actually exclude your internal domains.

How to Verify Resolution Is Correct

"It feels slow / won't connect" isn't enough to tell whether the problem is DNS or something else โ€” the more reliable approach is to check the actual resolved address directly:

  • The Dashboard: almost every Clash client's dashboard shows the actual destination IP for each connection โ€” the most direct way to check, no extra tools needed.
  • Command-line tools: use nslookup domain on Windows, or dig domain / nslookup domain on macOS/Linux, and compare the resolved IP for the same domain with Clash on versus off.
  • A quirk of Fake-IP mode: under this mode, an OS-level nslookup will return a fake IP (usually in the 198.18.0.0/16 range) โ€” that's expected and doesn't mean resolution failed; the core only does the real resolution once a connection is actually made.
โœ…

The simplest way to confirm DNS tampering: temporarily switch your system DNS or Clash's nameserver to an encrypted DNS (like DoH). If the same domain suddenly works after switching, that's a strong sign the original DNS was tampered with or hijacked.

Should You Self-Host a DNS Server?

For most people, a public encrypted DNS (like 1.1.1.1 or 8.8.8.8) is already enough to solve tampering issues โ€” there's no need to run your own. But if you're managing a home gateway or router that needs to serve resolution to multiple devices consistently, a self-hosted DNS (paired with something like AdGuard Home or dnsmasq) makes more sense:

  • Ad-filtering and split resolution can be centralized at the gateway level instead of configured per device
  • You can define custom local hostnames (friendly names for devices on your LAN), and point Clash's nameserver-policy at your self-hosted DNS for them
  • You get request logs and stats, making it easier to spot which device or domain is behaving oddly

If you're just using this on a single machine day-to-day, configuring Clash's built-in DNS module with nameserver / fallback is already plenty โ€” self-hosting is really an advanced option for gateway-level setups.

A 3-Step DNS Troubleshooting Checklist

  1. Open the connection details in the Dashboard to confirm which IP the problematic connection actually resolved to โ€” is it "resolved wrong" or "resolved fine but the rule didn't match"?
  2. Temporarily flip enhanced-mode from fake-ip to redir-host (or vice versa) as a comparison test to narrow down the cause.
  3. Double-check whether fallback-filter.geoip is enabled and whether geoip-code is actually set to your own region โ€” this is the detail people miss most often.

If you've checked all of the above and still can't pin it down, take a look at the connection troubleshooting checklist in the FAQ, or go through the full config again against the DNS section of the Advanced Configuration guide.