How Clash Fake-IP Mode Works: DNS Mapping and Use Cases

Learn how Clash Fake-IP maps DNS queries to virtual IPs, how it differs from redir-host, how to configure fake-ip-filter, and what to consider for LAN devices and gaming.

Fake-IP Mapping: From DNS Query to Rule Match

Fake-IP is an enhanced DNS mode. In a typical flow, the core returns a virtual IP from its address pool to the app, then uses the corresponding mapping to recover the domain for subsequent connections. This addresses a specific problem: after an app queries system DNS, its connections often contain only an IP address, while the core needs the domain to match DOMAIN or DOMAIN-SUFFIX rules.

  1. The query reaches the core. The app requests an A record for example.com. The core can return a Fake-IP only if the query reaches its DNS listener or is intercepted by a TUN DNS hijacking rule.
  2. A virtual IP is assigned. If the domain is not filtered, the core can assign an address from the pool configured at 198.18.0.1/16, such as 198.18.0.23, and record the mapping. This address is only an example, not a guaranteed query result.
  3. The connection is intercepted and mapped back. The app connects to 198.18.0.23:443. If that connection also reaches the same core, it can look up the original domain and evaluate rules in order. If DOMAIN-SUFFIX,example.com,DIRECT matches, the connection goes direct, but the core still needs to resolve the real address for the connection.

Both DNS and the connection must pass through the core. If DNS points to Clash but the app's connection bypasses it, the app may try to reach the virtual IP directly. DNS can succeed while the page still times out.

The mapping also depends on the record still being available. An app may keep using a cached virtual IP after the core restarts or the configuration changes. If only old tabs or background apps break after a restart, restart the affected app first, then check the logs for new connections. Change one thing at a time so a cache issue isn't mistaken for a rule error.

Fake-IP vs. redir-host: The Difference Is the DNS Response

ComparisonFake-IPredir-host
Address returned to the appA standard A query can return a virtual IP; filtered exceptions resolve to a real address.The app receives the resolved real address.
How domain rules are matchedIf a virtual IP has a mapping, the core can look up its domain directly.The domain may come from the proxy request itself, a DNS record known to the core, or protocol sniffing when enabled. A shared IP alone cannot reliably distinguish multiple domains.
When to try it firstConnections are handled by TUN, and routing relies mainly on domain rules.Apps need real IP addresses, and there are too many exception domains to maintain individually.

Explicit proxies provide another way in. When a browser uses the system HTTP proxy, HTTPS requests usually pass the target hostname to the proxy through CONNECT. The core already knows the domain, so it doesn't need Fake-IP to recover it. With TUN, however, the core often receives packets addressed to an IP, making Fake-IP mapping more useful. To compare the modes fairly, test the same app, interception method, and rule so differences in the connection path aren't mistaken for differences between modes.

Fake-IP can defer looking up the real address upstream until it is needed, but that doesn't mean pages will load faster. Outbound performance also depends on DNS resolution time, the proxy route, and the server's response. When troubleshooting speed, measure DNS response time separately from app connection time.

How to Configure fake-ip-filter: Start with a Few Exceptions

Here is an example of a mihomo dns section. fake-ip-filter-mode: blacklist means domains on the list won't receive Fake-IPs. nas.home.arpa matches one exact domain, while +.home.arpa covers the suffix itself and its subdomains. Start with exact domains; broaden the match only when the entire suffix needs real addresses.

dns:
  enable: true
  listen: 127.0.0.1:1053
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  fake-ip-filter-mode: blacklist
  fake-ip-filter:
    - 'nas.home.arpa'
  nameserver:
    - 223.5.5.5
  nameserver-policy:
    '+.home.arpa': 192.168.1.1
  • Listener address: 127.0.0.1:1053 is for targeted tests on the local machine. Setting this does not change system DNS or allow other devices on the LAN to access the listener.
  • LAN resolver: 192.168.1.1 is an example address. Replace it with a DNS server that can resolve your local home.arpa zone. If your router doesn't provide that service, don't use this address as-is.
  • Merge with your existing config: Add these fields to the existing dns section; don't create a second top-level dns: block. After saving, check which config the client has enabled and review the core logs to make sure subscription overrides haven't overwritten your changes. Older cores may not recognize every field in the example.

Filtering, resolution, and routing are three separate things. fake-ip-filter controls whether a virtual IP is returned; nameserver-policy selects the upstream resolver when a real address is needed; and rules decide whether traffic goes direct or through a proxy. Filtering a NAS domain doesn't guarantee a direct connection, nor can it make a public DNS server resolve a private host.

LAN Devices and Gaming: Choose a Mode Based on the Failure Point

NAS, Printers, and Local Domains

First, use the device's real address as a baseline—for example, open the NAS's current admin address in a browser. Then use your LAN resolver to look up its hostname and confirm both point to the same device. If the real address works but the hostname doesn't, check local DNS and Fake-IP filtering first. If both fail, confirm the devices are on a reachable subnet and check whether TUN routing has changed the path to the device.

For device names such as printer.local discovered through mDNS, check the multicast discovery path. fake-ip-filter affects only DNS queries handled by the core; it doesn't turn ordinary unicast DNS into mDNS. If the discovery list is empty, don't broaden the filter or switch DNS modes based on symptoms alone.

Game Login, Matchmaking, and Voice Chat

Note whether the failure happens during login, matchmaking, or voice chat, then check the connection logs for the domain, port, TCP or UDP protocol, and matched rule. If login works but matches fail, first check whether match traffic reaches the core and whether the selected outbound supports UDP. Adding the login domain to the filter list won't fix an outbound UDP issue during matches.

If a feature fails only when the client receives a virtual IP, first add an exact exception for the service domain confirmed in the logs, then restart the game and test again. If several required domains change often and are hard to maintain, compare the behavior with redir-host. After switching, retest your existing domain rules to make sure the compatibility fix hasn't disrupted routing for other apps.

Testing Workflow: Check DNS First, Then Connection Logs

  1. Test the listener port. After applying the example config, send an A query from the same machine using dig. The first query should return a virtual IP from the pool; the second should return the real address provided by your local resolver. If a query times out, first confirm the core is running and listening on port 1053.
  2. Test the app's connection path. A targeted query proves only that the core can respond—not that the app is using it. Make a request from the affected app and check the core's connection logs for the target domain and matched rule. If the app uses its own encrypted DNS, such as browser DoH, intercepting traditional DNS ports won't route those queries through the core. Also check whether the failing connection uses IPv4 or IPv6; an A-record test covers IPv4 only.
  3. Narrow down the cause based on the results. If the app receives a virtual IP but no connection appears in the logs, investigate the connection interception path. If the correct domain appears but the wrong policy matches, check earlier rules. If the correct policy matches but the connection still fails, check real-address resolution and outbound reachability.
dig @127.0.0.1 -p 1053 example.com A +short
dig @127.0.0.1 -p 1053 nas.home.arpa A +short

Keep a working config before switching modes. Change one variable per test: start with the original config, add one exception, and only then compare with redir-host. Each time, make the app establish a fresh connection and record the matched rule. This helps identify whether the change affected the DNS response, connection interception, or outbound selection.

Download Clash