FakeDNS addresses a common routing problem: how to preserve a domain name when traffic reaches the proxy with only a destination IP. This guide is for users configuring TUN and DNS. It explains virtual IP mapping, then walks through DNS interception, connection handling, and real DNS resolution, with steps to verify the setup. FakeDNS does not speed up a node, and TUN does not require it.
How FakeDNS Works: Virtual IPs Preserve Domain Names
A standard DNS lookup translates a domain name into the real address of a server. FakeDNS instead assigns the queried domain a virtual IP and keeps a local domain-to-IP mapping. For example, when an app queries example.com, it may receive an address from a virtual IP pool. When the app connects to that address, the proxy core uses the mapping to recover the original domain. This is not the website's real server address and cannot be used for a direct connection over the public internet.
This flow depends on two conditions: the DNS query must be handled by the component that maintains the mapping, and the subsequent connection must pass through a handler that can look it up. If only the first condition is met, the app gets a virtual IP but cannot connect. If only the second is met, the query returns a real IP, so there is no FakeDNS mapping to use.
Once the domain is restored, the proxy can use domain rules to choose a direct or proxied connection. A direct connection usually still needs the real destination address. Whether a proxy outbound can pass the domain to a remote resolver depends on the outbound protocol and configuration. FakeDNS changes local resolution and target identification; it does not replace the final destination lookup or change VMess or VLESS protocol parameters.
What FakeDNS, TUN, and Traffic Sniffing Each Do
TUN provides the traffic entry point, FakeDNS handles address mapping, and sniffing identifies targets. They are separate mechanisms, not one switch. TUN typically receives IP packets; if an app has already resolved a domain elsewhere, the packet may not retain the domain name, so another way to identify it is needed.
| Mechanism | What it does | What it cannot guarantee on its own |
|---|---|---|
| TUN | Routes matching IP traffic into the processing chain | That every connection includes domain information |
| FakeDNS | Assigns virtual IPs and maintains domain mappings | That all DNS queries and connections are intercepted automatically |
| HTTP/TLS sniffing | Attempts to identify hostnames from protocol data | That domains can be recovered from all encrypted traffic |
| Domain-based routing rules | Selects an outbound based on domain criteria | That missing domain information can be filled in |
Decision: Check whether connections are losing their domain names before using FakeDNS
If an app sends the domain directly through SOCKS and your domain rules already match as expected, you can keep your current setup. Add virtual IP mapping only if transparent interception often leaves you with just the destination IP and this is preventing domain-based routing from working.
FakeDNS restores domains using its own mapping; it does not require apps to send a readable HTTP host header or TLS hostname. However, an app's built-in encrypted DNS, fixed-IP connections, or local DNS cache may bypass this mapping. Enabling sniffing does not mean every connection will match a domain rule.
Before You Enable It: Check Your Core and DNS Interception
v2rayN is a desktop client; its configuration options depend on the core and operating mode in use. v2rayNG is for Android and uses the Xray core, while v2flyNG is for Android and uses the V2Fly core. Don't assume configuration fields are interchangeable just because the clients have similar names. In particular, TUN traffic handling and the proxy core for a node may be provided by different components. Xray's FakeDNS fields cannot simply be copied into another component's configuration.
Check the DNS Path
- Standard DNS
- Check where UDP 53 and TCP 53 traffic actually goes
- App-level resolution
- Check whether the browser uses its own Secure DNS
- IPv6 queries
- Confirm that AAAA responses and IPv6 routing are intercepted consistently
- Real DNS resolution
- Keep a resolution path for node domains and direct-connection targets
Intercepting port 53 does not mean all encrypted DNS is intercepted.
Check the Connection Path
- Virtual IP pool
- Example: 198.18.0.0/15
- Local entry point
- Confirm that connections to virtual targets enter the same mapping handler
- Domain restoration
- Check that the entry point supports the relevant FakeDNS restoration
- Network conflicts
- Check whether a corporate network or another tunnel uses the same subnet
198.18.0.0/15 is reserved for benchmarking; it is not a real website address.
Check IPv4 and IPv6 separately. If you configure an IPv4 virtual pool but an app can still obtain a real IPv6 address, it may connect through a different path. This is not necessarily a fault, but routing may behave differently than expected. Don't disable IPv6 blindly just to make test results look consistent; first confirm that your client supports the corresponding IPv6 interception.
Xray Configuration Example: Address Pool, DNS, and Entry-Point Restoration
The Xray JSON snippet below illustrates how the fields relate; it is not a complete TUN configuration. It shows the top-level fakedns address pool, a DNS fakedns server, and domain restoration on a SOCKS inbound. Before merging it, confirm that your Xray version supports these fields and integrate them with the existing dns and inbounds settings. Do not overwrite existing inbounds or outbounds.
{
"fakedns": [
{
"ipPool": "198.18.0.0/15",
"poolSize": 65535
}
],
"dns": {
"servers": [
"fakedns"
]
},
"inbounds": [
{
"tag": "local-socks",
"listen": "127.0.0.1",
"port": 10808,
"protocol": "socks",
"settings": {
"udp": true
},
"sniffing": {
"enabled": true,
"destOverride": [
"fakedns"
]
}
}
]
}
poolSize: 65535sets the mapping pool capacity. It is not the number of nodes and says nothing about speed. For long-running use, coordinating mapping lifetimes with app caches matters more.127.0.0.1:10808is the SOCKS inbound used in this example, not a DNS listening address. Setting it as the system DNS server will not create a DNS service.- Here,
dns.serversshows only FakeDNS. A real deployment also needs real DNS resolution rules supported by the core; queries that require real IPs must not all be sent to the virtual pool. fakednsindestOverriderestores the destination domain from the mapping. It does not create a TUN interface or route system DNS into the core.
When a client generates its configuration automatically, editing a temporary generated file may stop working after a restart or node change. Use the custom configuration option provided by your version, or adjust DNS and inbound settings where supported. To understand the routing fields, start with the configuration guide. Don't combine examples for different cores in one configuration.
Verification: Trace a DNS Response Through to the Routing Result
Change one type of setting at a time, keep a recoverable configuration, and test in the order below. The goal is to verify the entire flow, not just see a virtual IP. A single latency test cannot confirm that domain-based routing works.
- Record a baseline. Choose a test domain and note its current DNS response, whether the connection succeeds, and which outbound the routing rules select. Don't change nodes, subscriptions, and rule sets all at once.
- Clear old caches. On Windows, run
Clear-DnsClientCachein PowerShell, then restart the test app. This system command does not clear every browser's internal cache or the proxy core's own mappings. - Check the response address. If the query goes through the configured IPv4 virtual pool, the response should fall within
198.18.0.0/15. If it still returns a real address, check where DNS is going before changing your routing rules. - Make a real connection. Check the client logs to see whether the target is restored to the expected domain, then confirm which rule or outbound is selected. Log fields vary by core, and not every log level shows mapping details.
- Test direct and proxied connections separately. Both types of target should connect successfully. If only direct connections fail, check real DNS resolution and the direct outbound. If all virtual IPs time out, check the connection handling path first.
- Check what happens when you turn it off. Disable the mode, clear system and app caches again, and confirm that new queries no longer reuse old virtual IPs. Otherwise, a failure after disabling it may be mistaken for a network problem.
Bottom Line: Getting a Virtual IP Is Only the First Step
Verification is complete only when all of these work: a virtual IP is returned, the connection enters the processing chain, the domain is restored, the correct outbound is selected, and the connection succeeds. If any step fails, troubleshoot that part of the flow instead of broadening interception and hoping for the best.
When to Use FakeDNS—and When to Hold Off
FakeDNS is a good fit for setups that need transparent interception, rely on domain rules, and can manage DNS centrally. It can reduce reliance on protocol sniffing, but it also requires mapping state and caches to stay in sync. Enable it to address a specific problem, not by default.
- Worth evaluating: After TUN interception, logs often show only IPs, domain rules fail to match, and you can control system and app DNS paths.
- Keep your current setup: The browser sends domain names through an explicitly configured proxy, domain-based routing is stable, and you don't need transparent interception.
- Troubleshoot first: Your corporate network uses split DNS, internal domains, or routes that conflict with the virtual pool. Separate internal and public DNS queries before proceeding.
- Test with care: An app stores DNS results on disk for long periods, passes IPs between processes, or keeps using old connections after the proxy exits.
- Don't expect it to help with: Unreachable nodes, incorrect server authentication parameters, or a congested transport path. Domain mapping does not solve these problems.
LAN printers, network storage, and internal service domains usually need DNS resolution that meets local network requirements. Replacing all responses with virtual IPs may disrupt discovery, access controls, or diagnostic workflows that depend on real addresses. Test a limited scope first, then expand; it's easier to troubleshoot than enabling every related option at once.
FakeDNS FAQ and Troubleshooting
Why won't a website load even though DNS returns an address starting with 198.18?
First check whether the connection enters the same mapping handler, then check the inbound's domain restoration settings. If one component assigns the address but another component that doesn't share the mapping handles the connection, it will fail. Don't add virtual IPs to direct-connection rules as a workaround; they are not real website addresses.
Why does my browser still get a real IP when TUN is enabled?
Check the browser's Secure DNS setting, any encrypted DNS service configured by the system, and existing caches. In a controlled test, temporarily use system DNS and restart the browser, then check the response. TUN intercepts IP traffic; that does not mean it can identify and rewrite all encrypted DNS.
Which setting should I change first if websites stop loading after I close the client?
First restore the system proxy and DNS settings, then run Clear-DnsClientCache and restart the app that's still failing. If it continues to use an old virtual IP, clear the app's own DNS cache or restart it. Never configure a virtual pool address as the system DNS server.
Do I still need geosite and geoip rules with FakeDNS enabled?
Keep the rules needed for your routing goals. FakeDNS provides domain information; it does not create routing policies. Domain rules match names, while IP rules can still handle real IP conditions. Don't treat the virtual IP pool as belonging to a geographic region or try to fix a missing mapping by changing domainStrategy.
A practical setup order is: get a standard proxy and real DNS working first, verify TUN interception next, then introduce FakeDNS. Keep logs and a way to revert each change so you can tell whether a problem is in resolution, routing, or the outbound connection.