What Is FakeDNS? How V2Ray Virtual DNS Works and When to Use It

Learn how FakeDNS assigns virtual IPs and restores domain names, how it works with TUN mode, and when to leave it off.

At a Glance

FakeDNS uses virtual IPs to preserve domain information, making it useful for transparent proxying when routing by domain. This guide explains DNS responses, connection handling, and domain restoration, then covers kernel configuration, TUN checks, and rollback steps. The key is not finding a universal toggle, but confirming DNS queries and subsequent connections pass through the same path so domains can be restored.

What Is FakeDNS? Linking Domains to Virtual IPs

A standard DNS lookup converts a domain name into a real, reachable IP address. FakeDNS instead assigns the application a virtual IP from a designated pool and records the domain-to-IP mapping. The application connects as usual, but the address does not belong to the actual web server, so the local proxy must intercept the connection and handle it.

For example, when an app looks up example.com, local FakeDNS might assign 198.18.0.1. When the app connects to port 443 at that address, the proxy looks up the mapping and restores the destination as example.com:443, then applies domain-based routing rules and selects an outbound. This is an example only; a lookup is not guaranteed to return the same address.

Look up a domain Assign a virtual IP Intercept the connection Restore the original domain Apply outbound rules

FakeDNS addresses a specific problem: by the time a connection reaches the proxy, only the IP may remain and the domain name may be lost. It does not provide proxy servers, replace VMess, VLESS, or Trojan, or change REALITY handshake settings. A subscription supplies connection settings; FakeDNS preserves the link between local connections and domains. They operate at different layers.

198.18.0.0/15
IPv4 address pool used in the example below
53
Common port for traditional DNS
4096
Mapping pool capacity used in the example below

How Domain Restoration Differs from Regular Sniffing

Protocol sniffing inspects application-layer data in a connection, such as the HTTP Host header or the server name visible in a TLS ClientHello. FakeDNS restoration instead relies on a mapping saved earlier, so it does not have to wait for the application to expose a domain in its payload. The two methods can work together, but enabling HTTP/TLS sniffing does not by itself configure FakeDNS.

This is why enabling FakeDNS does not eliminate real DNS entirely. The application may avoid waiting for a real DNS lookup, but direct connections and resolving proxy server hostnames may still require real DNS. With a remote proxy, the destination domain may also be resolved remotely.

FakeDNS and TUN: Two Paths That Must Connect

TUN provides a virtual network interface that receives IP traffic matching the routing rules. FakeDNS provides virtual DNS responses and mappings. They are often used together because TUN can send connections to virtual IPs back to the proxy, but TUN alone does not guarantee that all DNS queries are intercepted or that a particular FakeDNS implementation is in use.

DNS Processing Path

Input
Domain lookup from an app
Processing
A designated DNS module assigns a virtual IP
Check
System DNS, app-level encrypted DNS, and IPv6 lookups

If a query does not pass through this path, no mapping will be available for later restoration.

Connection Processing Path

Input
App connection to a virtual IP
Processing
TUN receives it and passes it to the corresponding mapping restoration logic
Check
Routing for the virtual IP range, mapping lifetime, and outbound destination

Do not send a virtual IP directly to another core that does not know about its mapping.

In v2rayN, the TUN path and the regular proxy path may use different configuration generators or processing modules. Do not paste one core's fakedns JSON into another TUN configuration format. First check the selected core, the active configuration, and the logs; then determine which layer handles DNS.

  1. Turn off TUN and test the node through the existing system proxy to rule out subscription and server issues.
  2. In v2rayN, open “Settings” → “Parameter Settings” and check the available cores and related options for your version. Page names may vary between versions, so use the labels shown in your app.
  3. With TUN enabled, check the system routes to confirm that traffic for the virtual IP range enters the interception path instead of going to the physical gateway.
  4. Also check DNS interception and each app's encrypted DNS settings. Otherwise, connections may be intercepted without creating the domain mappings they need.

V2Ray / Xray Configuration: Assignment and Restoration Must Work Together

The following configuration snippets are for V2Ray / Xray cores that support the relevant fields. They illustrate how the fields relate; they are not a complete v2rayN import configuration. They do not include inbound listeners, node outbounds, or complete routing rules. GUI clients usually generate these settings, and manual edits to generated files may be overwritten the next time they are saved.

{
  "dns": {
    "servers": ["fakedns"]
  },
  "fakedns": [
    {
      "ipPool": "198.18.0.0/15",
      "poolSize": 4096
    }
  ]
}

In dns.servers, fakedns enables virtual DNS responses. The top-level fakedns setting defines the address pool and its capacity. The 4096 value here is an example capacity, not a default for every core or a performance metric. DNS queries must also be routed to this DNS module; adding these fields alone will not intercept system queries.

The inbound receiving connections to virtual IPs also needs its corresponding restoration mechanism enabled. Merge the sniffing object below into the relevant inbound object; it is not a separate top-level setting. Check the documentation for your core to confirm which fields it supports.

{
  "sniffing": {
    "enabled": true,
    "destOverride": ["fakedns"],
    "routeOnly": false
  }
}

When to Enable FakeDNS: Choose Based on How Connections Are Made

If an app already connects through an HTTP proxy or sends domain names in SOCKS requests, the proxy may already know the domain, so FakeDNS often adds little. It is more useful for transparent proxying where only the destination IP is visible and domain-based rules are needed.

Use caseRecommendationCheck first
TUN interception with routing primarily by domainConsider enabling itCan DNS and connections share the same mapping?
Browser using an explicit proxyKeep the current setup if possibleDoes the proxy already receive the domain?
Corporate intranet or local network service discoverySet up exceptions for real DNS resolution firstInternal domains, printers, and local devices
App requires its own encrypted DNSResolve query bypass firstDoes the query pass through the local DNS module?
A tool needs to show the real destination IPKeep real DNS resolution for these queriesIs the diagnostic result being replaced with a virtual IP?

Bottom line: Confirm the domain is being lost before enabling FakeDNS

If the logs already show the destination domain and domain-based rules work, keep your current DNS settings. Try FakeDNS only when a transparent interception path is actually losing domains and you can intercept both DNS queries and connections.

198.18.0.0/15 is a special-purpose address range reserved for network benchmarking. It is not a public website address or a typical private network range. If your lab network or corporate environment already uses it, check for routing conflicts first. Any alternative address pool also needs to be supported by the core and accounted for in your routing plan; do not substitute an arbitrary public address range.

How to Verify FakeDNS: Don't Check DNS Results Alone

Verification needs to cover the entire path. Seeing an address starting with 198.18 or 198.19 shows only that a query returned a virtual response; it does not prove the connection restored the domain or followed the right route. Conversely, a tool may return a real address because it bypassed the expected DNS path.

  1. Record a baseline. Save the current configuration, choose a domain that already works, and note the active node and routing mode. Do not change protocols while testing.
  2. Trigger a fresh lookup. After enabling the configuration, restart the test app. On Windows, run ipconfig /flushdns to clear the system DNS cache. The browser's own DNS and connection caches may need to be cleared separately.
  3. Check the DNS path. Use nslookup example.com to help inspect system name resolution, but it may not reproduce a browser's encrypted DNS behavior and is not sufficient on its own to confirm the setup.
  4. Check connection logs. Confirm that the virtual destination is restored to the original domain and check which outbound is ultimately selected. If you temporarily increase log verbosity, revert it after testing to avoid keeping a long-term record of visited domains.
  5. Test different cases. Check a proxied site, a direct site, an internal domain, and an IPv6 scenario. Testing just one page can miss a direct-resolution loop or an AAAA query that bypasses the intended path.

Common Issues and Rollback Steps

After enabling FakeDNS, no websites load. What should I change first?

Restore the previous DNS mode and restart the test app to confirm basic connectivity. Then check that connections to the virtual IP range reach the correct inbound and that mapping restoration is enabled there. Do not start by changing your subscription or transport protocol.

Websites load, but internal domains fail to resolve. What should I do?

Add exceptions so internal domains use the local network's DNS for real resolution, and keep the corresponding direct routes. Internal resolvers often depend on the current network environment; sending all internal domains to an external resolver will not produce the same results.

Why do some apps never get virtual IPs?

Check whether those apps use built-in encrypted DNS, have cached results, or connect directly to fixed IP addresses. First reproduce the full path with a test app that uses system DNS, then investigate app-specific differences. A connection made directly to an IP has no DNS mapping to restore.

Can v2rayNG and v2flyNG use the desktop configuration as-is?

No. v2rayNG uses the Xray core, while v2flyNG uses the v2fly core. Their configuration paths for Android VPN interception also differ from desktop TUN. Check whether the app exposes the feature, whether its current core supports the relevant fields, and what the configuration generated by the app actually contains.

To roll back, restore DNS settings, restore the original routes, restart the interception service, and clear app caches—in that order. Keeping a known-good baseline configuration makes troubleshooting easier than changing FakeDNS, IPv6, sniffing, and routing policies all at once. When trying again, change one part at a time to identify whether the issue is query bypass, a missing mapping, or an outbound rule.

Download v2rayNChoose a client for your platform