How Fake-IP Maps Addresses: From DNS Replies to Rule-Based Routing

Fake-IP is a DNS enhancement mode in Clash and mihomo. When an app looks up a domain’s IPv4 address, the core can assign an address from a virtual IP pool and return it immediately. This address is a lookup key the core uses to recover the domain; it is not the IP used by the website’s server.

  1. The query reaches the core’s DNS resolver. Suppose a browser requests the A record for example.org. If the domain doesn’t match a filter rule, mihomo can assign an address from the configured 198.18.0.1/16 pool, such as 198.18.0.23, and record that it maps to example.org.
  2. The same core must handle the connection. The browser then tries to connect to 198.18.0.23:443. If an entry point such as TUN routes this connection to the core that returned the DNS reply, the core can look up the original domain. If the connection takes another path, the virtual IP alone can’t identify the website.
  3. Match rules against the domain, then choose an outbound route. In rule mode, the core can use the recovered domain to match rules such as DOMAIN or DOMAIN-SUFFIX. A direct connection typically still needs the destination’s real IP. If the selected proxy supports forwarding the domain, the proxy may resolve it instead. Rules that evaluate the destination IP may also trigger a real DNS lookup.

Fake-IP vs. redir-host: Which Should You Use?

Start with the DNS reply the app receives. Fake-IP can respond with a local mapping first and resolve the real destination later, when needed for rule matching. redir-host returns the actual resolved address, so upstream lookup time usually adds to the app’s wait—unless the answer is cached. Fake-IP can reduce wait time for some DNS queries, but overall page load time also depends on outbound resolution, connection setup, and server response time.

ComparisonFake-IPredir-host
Address returned to the appMatching queries receive a virtual IP; queries that match a filter rule use real DNS resolution.Receives the actual resolved address, from upstream DNS or the cache.
Domain-based routingOnce the core handles the connection, it can recover the original domain from the virtual IP.If the app provides only a real IP, the original domain may not be recoverable; multiple domains may also share one IP.
Best forWhen TUN can handle both the relevant DNS queries and subsequent connections, and you want reliable domain-based routing.When many apps rely on real IP addresses, or DNS queries and connections can’t reliably go through the same core.

With system proxy alone, some apps send the destination domain straight to the proxy instead of looking up its IP locally first. In that case, changing the DNS mode may have little effect. Conversely, if an app uses the core’s DNS but bypasses TUN or the proxy when connecting to the virtual IP, you may see “DNS resolves, but the connection times out.” redir-host and Fake-IP are DNS modes; switching between them won’t enable TUN or change your system proxy settings.

fake-ip-filter: Exclude Only Domains That Need Real IPs

Add the domain the app actually queries to the filter—not the app name, a URL path, or an IP address. Check the client’s DNS or app logs to identify the domain queried when the failure occurs, then add an exception for that domain. If only one service is affected, a precise exception is easier to verify than switching the global DNS mode.

  • Local network services: If an app needs a real LAN address to connect to a NAS, printer, or home service, start by excluding the specific hostname, such as nas.home.arpa. Expand the rule to +.home.arpa only if you also need access to multiple devices in that local domain.
  • Games and voice apps: Some apps validate addresses, pass resolved IPs to another device, or use connections the core doesn’t handle. Add a filter entry only when you encounter one of these cases and have confirmed the affected domain. UDP traffic alone doesn’t mean a domain needs to be excluded.
  • Local discovery and static IPs: If devices use .local multicast DNS for discovery, first check your system’s multicast and LAN access settings; regular DNS filter entries won’t fix multicast discovery. If an app connects directly to a static IP, there’s no corresponding domain lookup to filter.

mihomo Example: Resolve a NAS Hostname to Its Real LAN Address

This example explicitly sets blacklist, so domains on the list use real DNS resolution. Merge the required fields into your existing dns: section, preserving its upstream servers, listener settings, and filters. Don’t create a second top-level section with the same name. If your client generates its config from a subscription, use a supported override option to avoid losing changes on the next refresh.

dns:
  enable: true
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  fake-ip-filter-mode: blacklist
  fake-ip-filter:
    - 'nas.home.arpa'
  nameserver-policy:
    'nas.home.arpa': '192.168.1.1'

This example assumes 192.168.1.1 is a LAN DNS server that can resolve the NAS hostname; replace it with your resolver’s address. nameserver-policy specifies where to look up the real record, while fake-ip-filter controls whether to return a virtual IP first. They handle separate steps. Filtering also doesn’t automatically route the connection through DIRECT. If the real address resolves but the connection still fails, check the matched rule and outbound policy. This configuration is for mihomo. If your client uses an older core, check which fields it supports, especially fake-ip-filter-mode.

Fake-IP Connection Issues: Check DNS, Traffic Capture, and Routing Separately

  1. First, verify which configuration is running. On the client’s subscription or configuration page, confirm that the profile you’re testing is selected, then check its merged DNS settings. Page names vary by client; use the active configuration’s dns.enhanced-mode, dns.listen, and filter list as the source of truth. Reload the config after making changes, then restart the app or clear its DNS cache so it doesn’t reuse an old address.
  2. Query the core’s DNS directly. If the active config listens on 127.0.0.1:1053, use the command below to test an IPv4 response, changing the port to match your setup. With this example, a regular domain should return a virtual IP, while an excluded NAS hostname should return the real address provided by your LAN DNS. If the NAS lookup returns NXDOMAIN, query your LAN resolver first and confirm the record exists.
  3. Next, check whether the app uses this path. If a direct lookup works but the app gets a different result, check the browser’s secure DNS, system cache, and the client’s TUN DNS handling. Rules that intercept regular DNS on port 53 won’t automatically turn the app’s encrypted HTTPS queries into queries handled by the core. If the app gets a virtual IP but times out, open the client’s Connections page and check for the destination. If it appears, inspect the matched rule and outbound route; if it doesn’t, check the traffic capture scope and routing first.
dig @127.0.0.1 -p 1053 example.org A +short
dig @127.0.0.1 -p 1053 nas.home.arpa A +short

Change one setting at a time, then retry with the same app. If one domain fails, add a precise filter entry. If the LAN address still won’t resolve, fix the resolver it uses. If several apps get virtual IPs but can’t connect, fix connection handling before considering redir-host. This helps distinguish an incorrect DNS reply from a correct address reached over the wrong route.