How FakeDNS Works: Virtual IP Mapping, Traffic Sniffing, and When to Use It

Learn how FakeDNS uses reserved IP ranges to map domains, how the core restores domain names for routing, how it compares with traffic sniffing, and when to enable it.

At a Glance

If domain rules stop working after you enable TUN, first check whether the core sees a domain name or only an IP address. This guide explains FakeDNS through DNS replies and subsequent connections, covers when to use it, how to verify the mapping, and what to check when virtual IP conflicts or stale caches cause problems.

How a Virtual IP Maps Back to a Domain

When an app connects to a domain, it usually makes a DNS query first, then connects to the returned IP address. A standard DNS lookup returns the real address, but TUN sees only an IP when it intercepts the connection. Since multiple domains can share an IP, a reverse lookup cannot tell you which domain the app originally requested. FakeDNS changes the DNS reply: it assigns a virtual IP from a pool, associates that address with the domain, and returns the virtual IP to the app.

Domain lookupVirtual IP assignmentConnection interceptionDomain mapping lookupOutbound rule matching

A virtual IP is not the address of the remote server. The subsequent connection must pass through a path that can access the corresponding mapping so the core can resolve the destination IP back to its domain. The outbound connection still has to reach the real destination: a direct connection usually requires a real DNS lookup, while a proxy outbound may pass the domain to the remote peer for resolution. The details depend on the core, protocol, and outbound settings. Intercepting DNS without intercepting app connections makes the virtual IP ineffective.

198.18.0.0/15
IPv4 benchmarking range commonly used by FakeDNS
53
Standard DNS uses UDP/TCP port 53
443
Ports used by HTTPS and common DoH endpoints

These values help identify addresses and traffic; they do not indicate fixed client listening settings. A reply in a benchmarking range only suggests that the query may have received a virtual IP—it does not prove the connection was intercepted. Likewise, not seeing a query on port 53 does not mean the app skipped DNS: it may have used a cache or sent its DNS query over HTTPS.

FakeDNS vs. Traffic Sniffing

Standard traffic sniffing extracts domain names from recognizable protocol fields after a connection reaches the core. Examples include the Host header in unencrypted HTTP and TLS SNI that is not encrypted and can be read by the core. This does not require changing DNS replies. But sniffing cannot reliably identify the destination when a connection has no usable domain field, its protocol cannot be recognized, or its domain is hidden by encryption.

FakeDNS mapping

Domain source
Intercepted DNS query
App receives
Virtual IP from the address pool
Required for it to work
The subsequent connection is also intercepted, and the mapping is still valid
Common reasons it fails
The app uses a stale cache, its own resolver, or a literal IP address

Whether the domain can be recovered depends on the mapping, not on whether the app data contains a Host header or SNI.

Standard protocol sniffing

Domain source
Protocol fields visible in the connection
App receives
Address returned by the existing resolution path
Required for it to work
Sniffing is enabled on the inbound, and the protocol fields can be recognized
Common reasons it fails
The traffic has no domain field, or the field is not visible

Whether the detected domain is used only for routing or also affects the destination address depends on the core and its configuration.

First check whether the inbound already receives a domain name

If an app sends the domain directly to the inbound through an explicit proxy, check rule order and outbound selection first. Test FakeDNS only if the inbound consistently receives IP addresses and the same setup can intercept both DNS lookups and connections.

When to Use FakeDNS—and What Can Conflict

FakeDNS is most useful when TUN intercepts the target app, domain rules express your routing needs better than IP rules, and the app retains only the resolved address when it connects. If the client intercepts only some apps, or DNS and connections take different paths, first verify that each app meets both interception requirements. For v2rayNG, check whether per-app proxying includes the target app and confirm which resolution path it uses; the VPN icon alone is not enough.

Verify Routing with a Side-by-Side Test

On desktop, start by checking your current setup in v2rayN under Settings → Parameter Settings, then confirm which core, TUN, and DNS configuration are in use. Option locations, field names, and implementations vary by version and core; if you cannot find an option with the same name, do not paste in configuration fields from another core. The steps below use a single Windows device as an example. Keep the node, routing rules, and app unchanged, and switch only the DNS behavior you want to test.

  1. Establish a baseline. Turn off FakeDNS, choose a domain you own or are authorized to test, and start a new connection in the target app. Note the destination address and outbound shown in the connection log, and confirm which outbound the current rules should select.
  2. Check system DNS resolution. After enabling FakeDNS, use Resolve-DnsName in PowerShell to query both A and AAAA records for the same domain. Compare the results with the address pool in use rather than looking for a specific fixed prefix. If the result is still a real IP, first check whether the query went through FakeDNS and whether the domain is covered by an exception.
  3. Verify the app's actual connection path. Quit and reopen the app, then start another connection. Check whether the log shows the expected domain or outbound label. System commands and apps may use different resolvers, so a virtual IP returned by the command does not replace this check.
  4. Handle caches and rules separately. If the app still uses an old address, close it, then run ipconfig /flushdns to clear the Windows DNS client cache and try again. This command does not clear the app's own cache. If the log shows the correct domain but the wrong outbound, check the earlier rules and fallback rules instead.

Common Problems and How to Roll Back

Why can’t I connect from an existing app window after restarting the core?

The app may still have a virtual IP cached, while the restarted core no longer has the corresponding mapping. Quit the affected app, clear the system DNS cache, then reopen the app to trigger a new lookup. If a new window works but the existing one does not, check the app cache or connection reuse first.

Why does the browser miss the rule even though the system gets a virtual IP?

Compare the system lookup result with the browser's actual connection log. Check whether the browser uses its own secure DNS and whether the connection enters TUN. Change only one setting at a time and retry, so you can identify the cause without changing the resolver and routing together.

Why does my office domain still resolve to a virtual IP after I turn off FakeDNS?

Restore the original DNS and TUN settings, clear system and app-side caches, then query the domain again. If the result is still unexpected, check which resolver sent the reply and whether another network component is intercepting DNS or routing on the device.

Consider rollback complete when a new lookup returns the expected address and the target app can establish a new connection. FakeDNS solves the association between domains and connections; it does not guarantee that every DNS request goes through a particular resolver, nor does it determine whether queries are encrypted. To troubleshoot DNS leaks, check where the queries actually go.

Download v2rayNChoose a platform and installer