FakeDNS Explained: How It Works, Use Cases, and What to Check Before Enabling It

Learn how FakeDNS uses a virtual IP pool for domain-based routing, how it works with TUN mode, when to use it, and what compatibility issues to watch for.

At a Glance

FakeDNS is useful when you need domain-based routing in TUN mode, but the inbound connection only exposes the destination IP. It gives the app a virtual IP first, then restores the domain when the connection reaches the proxy core. Before enabling it, make sure both DNS queries and subsequent connections are intercepted, and keep a real DNS resolution path for LAN domains. To verify the setup, check the DNS response, routing logs, and actual connectivity separately.

How FakeDNS Works: Restoring Domains from Virtual IPs

When an app asks the system resolver for a domain, regular DNS returns an address it can connect to. If the query matches a FakeDNS policy, the core assigns an address from its virtual IP pool and saves the address-to-domain mapping locally. The app then connects to that address. If the connection reaches an inbound that can access the mapping, the core restores the original domain and selects an outbound based on domain rules.

Domain queryVirtual IP assignedApp connectsInbound intercepts connectionDomain restoredOutbound matched

For example, two domains may share the same real IP on a CDN. Routing by destination IP alone makes it difficult to send one domain direct and proxy the other; once the domains are restored, each can follow its own rules. For FakeDNS-matched queries, routing decisions can also be made without waiting for real DNS resolution to finish. A reachable address is still required to establish the connection, and whether resolution happens locally or remotely depends on the selected outbound and its settings. So a virtual IP response does not mean a page will load faster, nor does it tell you whether the DNS query went through the proxy.

FakeDNS and TUN: When to Use Them Together

TUN is a virtual network interface that receives IP packets; it cannot infer a domain from a packet's destination IP. FakeDNS provides the missing domain mapping: a module that assigns virtual IPs must handle the DNS query, the app's connection to the virtual IP must be intercepted, and the same mapping must be available when routing takes place. Enabling TUN alone, changing only the DNS upstream, or merely adding a virtual IP pool to the configuration does not prove that this path is working.

Domain-Based Routing with TUN

DNS query
FakeDNS responds for the requested domain
Connection entry
TUN intercepts the connection to the virtual IP
Routing criteria
Restored domain and matching rule
What to verify
Check the domain rule and actual outbound

Useful when an app resolves an address before connecting, but the inbound would otherwise see only an IP.

Domain-Based Routing with a System Proxy

Connection entry
App uses an HTTP or SOCKS proxy
Where the domain comes from
App includes the domain in its proxy request
Routing criteria
Domain received directly by the proxy inbound
DNS policy
Handled according to the existing outbound and DNS settings

If the proxy request already includes the domain and routing works correctly, there is no need to add a virtual IP pool just to preserve the domain.

If an app connects directly to a hard-coded IP, it never makes a query that FakeDNS can use to create a mapping. Route that traffic by IP or another known criterion instead. Another common exception is an app's own encrypted DNS: even if TUN intercepts the connection to the resolver, the DNS payload remains encrypted and does not automatically reach the core's FakeDNS module. If only one app fails to route as expected, check how it resolves domains before changing global rules.

Before Enabling FakeDNS: Check the IP Pool, LAN, and DNS Dependencies

In a v2rayN setup using the Xray core, first note the current DNS policy and rule order under Settings → DNS Settings and Settings → Routing Settings. Menus vary by client version and platform. If your interface has no separate FakeDNS toggle, check the active runtime configuration rather than assuming that Enable TUN controls the same setting. v2rayNG on Android also uses the Xray core, but you still need to check which configuration is active in the app; desktop menu paths do not apply directly to Android.

198.18.0.0/15
Example of a Common IPv4 Virtual Pool
53
Common Ports for Traditional DNS (UDP/TCP)
2 types
Check A and AAAA queries separately for dual-stack setups

Deciding Whether to Enable It: Verify One Domain End to End First

Choose a public domain that should use the proxy for testing, and keep an internal domain as a control. Expand the FakeDNS match scope only after the public domain's virtual-IP connection uses the expected outbound and the internal domain still resolves to a real address through internal DNS.

Testing: Check DNS First, Then Connections and Routing

Keep the same node, network, and routing rules; change only the FakeDNS-related settings. Record the baseline with FakeDNS disabled, then enable it and retest with new connections. In Windows PowerShell, run the commands below to check a regular DNS query and HTTPS port connectivity. If your current rules do not match example.com to the test policy, use a public domain you have confirmed will match. Do not specify an external DNS server, as that may bypass the default resolution path and test a different route from the one the app uses.

Resolve-DnsName -Name example.com -Type A -DnsOnly
Resolve-DnsName -Name example.com -Type AAAA -DnsOnly
Test-NetConnection -ComputerName example.com -Port 443
  1. First, check whether the A query returns an address within the configured IPv4 pool. For a dual-stack setup, check the AAAA response separately; expect an address from the IPv6 pool only if IPv6 virtual responses are configured. If you see a real IP, first confirm that the domain matches the policy, then rule out caching or another DNS resolution path.
  2. While testing the connection, check the client core logs and match the domain, rule, and outbound identifier to the connection by timestamp; the exact output depends on the core in use. A true TcpTestSucceeded only confirms that TCP connectivity works. It does not show which rule matched and cannot replace testing an HTTPS page in the original app.
  3. Open the internal site or service you noted earlier, then retry in the target app. If the command-line test works but the app does not, check whether the app uses its own secure DNS, is reusing an existing connection, or prefers IPv4 over IPv6 (or vice versa).

Common Problems and How to Roll Back

Why Won't a Page Load Even Though DNS Returns a Virtual IP?

First check whether the test connection appears in the core logs. If it does not, verify the route for the virtual IP and whether TUN is intercepting traffic from the app. If there is a log entry but the domain cannot be identified, check whether the inbound has the relevant FakeDNS domain restoration enabled. If both the domain and outbound are correct, check the outbound's actual DNS resolution and connection errors.

Only Internal Company Domains Fail. What Should I Change?

First check whether the domain received a virtual IP. If so, exclude the confirmed internal domain suffixes from the FakeDNS policy so internal DNS can return real addresses, then verify which interface carries the internal traffic. After the change, test both an internal domain and a public test domain.

Why Does an App Still Time Out After I Switch Configurations?

The app may have cached an old virtual IP or kept an existing connection open after the core's mapping changed. Close and reopen the app. On Windows, run ipconfig /flushdns to clear the system DNS cache; the app's own cache may need to be cleared separately.

If I Turn Off FakeDNS, Should I Turn Off TUN Too?

If you were already using TUN, leave it enabled for now. Restore the previously recorded DNS policy, relevant inbounds, and routing settings, then clear caches and test new connections. This helps isolate whether the problem comes from virtual IP mapping or from TUN's interception scope.

Download v2rayNChoose a platform and installer