How Fake-IP Works: Return a Virtual IP, Then Recover the Domain
Fake-IP is a DNS response mode in the core—not a rule mode, global mode, or another name for TUN. It solves a specific problem: after an app resolves a domain, it may connect using only the destination IP. How can the core determine which domain that IP originally belonged to?
- Receive the DNS query. The app requests an A record for a domain. The query must reach the core’s DNS module first; setting
enhanced-mode: fake-ipalone does not automatically intercept every system or browser query. - Assign a virtual IP. For queries eligible for Fake-IP, the core can return an address from its pool, such as
198.18.0.23, and keep a mapping between that address and the domain. This is just an example, not a fixed result for any particular domain. - Match rules using the domain. When the app connects to this address, the core can recover the domain if the connection also reaches a core that has access to the mapping. In rule mode, rules such as
DOMAINandDOMAIN-SUFFIXcan then select an outbound policy. The virtual IP returned to the app is not the destination server’s real address. - Establish the actual connection. A direct outbound connection needs to resolve a reachable real address. When using a proxy, whether the domain can be passed to the proxy for resolution depends on the protocol and outbound configuration. Fake-IP does not eliminate real DNS resolution; it separates that resolution from the DNS response received by the app.
What Is 198.18.0.0/16? Virtual IP Pools and Address Conflicts
198.18.0.0/16 spans 198.18.0.0 to 198.18.255.255. It is part of the 198.18.0.0/15 block reserved for network benchmarking, not a range for ordinary public services. A common mihomo configuration is fake-ip-range: 198.18.0.1/16. Its mask still corresponds to 198.18.0.0/16; these two notations do not represent separate subnets.
If a DNS result starts with 198.18, matches the pool configured on your system, and the app can reach its destination, Fake-IP is usually working as expected. If a corporate VPN, lab network, or another proxy also uses an overlapping range, check which interface actually handles traffic to that address. A routing conflict or virtual IP being sent to another core cannot be fixed simply by changing the upstream DNS server.
One easily missed detail in multi-device setups: sharing a subscription does not mean sharing mappings. If a phone gets a virtual IP from the router but sends the subsequent connection to a separate core running on the phone, that core may not be able to recover the domain. Keep the DNS response and connection on the same instance, or configure DNS to match that device’s traffic path.
Fake-IP vs. redir-host: Which Address Does the App Receive?
| What to check | Fake-IP | redir-host |
|---|---|---|
| A record response | Eligible domains receive an address from the virtual IP pool; domains matching a filter can receive the real DNS result. | Usually returns the real DNS result directly, without assigning a Fake-IP. |
| Domain information available when connecting | The core can look up the domain from the virtual IP. | There is no virtual IP mapping. Domain identification depends on whether the inbound connection includes the domain, the DNS association saved by the core, or sniffing results. |
| Best suited for | DNS queries and connections handled by the same core, especially when transparent proxying relies mainly on domain rules. | Setups where several services need real IPs, or the network topology makes it difficult to route virtual IPs back to the same core reliably. |
Choose based on the scope of the issue. If only one LAN service is affected, add an exception for that domain first. If several services that rely on real IPs are affected, compare with redir-host. Keep the network, policy group, and test destination the same; change only the DNS mode and clear the cache. If you also switch nodes, you won’t know which change made the difference.
Using fake-ip-filter: Add Specific Domains, Not App Names
fake-ip-filter matches DNS query domains, not app names, process names, or package names. Typical candidates include a printer’s management domain, an internal NAS domain, and apps that need a real IP to determine whether a destination is on the local subnet. Don’t add entire categories like voice apps, games, or device setup tools. First reproduce the issue and identify the domain the app actually queries.
Example: Return Real IPs for LAN Device Domains
dns:
enable: true
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16
fake-ip-filter-mode: blacklist
fake-ip-filter:
- "printer.home.arpa"
- "nas.home.arpa"
This is a mihomo configuration snippet, not a complete config. The two domains are examples using home.arpa; replace them with records provided by your LAN DNS server. In blacklist mode, matching entries are not assigned Fake-IPs. If you already have a dns: section or filter list, merge the fields and check the effective configuration after the client applies its overrides. For older cores, check the config validation result to see whether an explicit fake-ip-filter-mode is supported.
- Filtering does not mean direct access. A filter changes the DNS response. Whether the subsequent connection uses
DIRECTor a proxy still depends on the active mode and outbound rules. - Filtering does not provide internal DNS resolution. LAN domains still need to be sent to a DNS server that knows those records. If filtering results in
NXDOMAIN, check the internal resolver and applicablenameserver-policyfirst. - Filtering does not fix device discovery. If you can open a printer by IP but it does not appear in the discovery list, the issue may involve mDNS or another LAN discovery protocol.
.localcommonly uses mDNS; adding a regular DNS filter entry does not replace multicast discovery.
Troubleshooting TUN and DNS: Compare Responses, Connection Logs, and Routes
TUN receives IP traffic routed through a virtual interface; Fake-IP generates specific DNS responses. Enabling TUN does not guarantee that every query passes through the core’s DNS module. An app’s built-in encrypted DNS may use HTTPS and bypass interception settings that target only standard DNS on port 53. Troubleshoot the actual traffic path instead of relying on toggle states.
First, Verify the Core’s DNS Response
If the client is configured with dns.listen: 127.0.0.1:1053, use the commands below to query that listener directly. 1053 is an example port, not a fixed default. The first command checks a regular domain; the second checks the filtered domain from the example above. If your LAN has no matching record, use one of your own internal domains.
dig @127.0.0.1 -p 1053 example.com A +noall +answer
dig @127.0.0.1 -p 1053 printer.home.arpa A +noall +answer
Next, Check Whether the App Uses the Same Path
- The command returns a virtual IP, but the app uses a real IP: Querying the listener directly only confirms how the core’s DNS behaves. Check the app’s secure DNS settings, system DNS, and cache. A domain may also have both A and AAAA records, so don’t assume the app uses the same address family as an A record query.
- The app uses a virtual IP, but the core has no connection log: Check whether the app bypasses TUN, whether the system routes that subnet to another VPN, and whether the device that answered the DNS query is also the entry point for the actual traffic. Check routing first; don’t start by adding domain rules.
- The log shows the domain, but the wrong policy is selected: The mapping is working. Check the matched rule, rule order, and current policy group selection. If the correct rule matches but the connection still fails, check the outbound connection error.
- You still get the old address after adding a filter: Make sure you edited the active configuration, reload it, then query the listener again. If the listener now returns the real address but the app still connects to the old one, clear the system or app DNS cache and establish a new connection to avoid reusing an old session.