V2Ray DNS Routing: Split DNS, DoH, and DNS Leak Prevention

Configure V2Ray DNS servers, domains, and queryStrategy for split DNS, DoH, and FakeDNS. Reduce DNS pollution and leaks with practical routing checks.

At a glance

For readers who can already connect to a proxy node and want to fine-tune DNS. First identify whether queries come from the app, client core, or proxy server. Then route domains to the right upstream and verify which outbound handles DoH. Once standard DNS is working reliably, test FakeDNS with a compatible core and traffic interception mode.

DNS Routing vs. Connection Routing

App queryCore interceptionDomain matchingUpstream lookupAddress returned

This is a typical path for queries handled by the core's DNS module, not a path used by every app. Enabling a system proxy does not mean system DNS is intercepted. An app may resolve a domain through the system before connecting, or pass the domain to the proxy. Browsers with their own secure DNS may also send HTTPS queries directly. Changing dns.servers affects only queries handled by that module.

servers, domains, and queryStrategy

Mainland China domain group

address
223.5.5.5
port
53
domains
domain:baidu.com

Test the group with a few known domains before expanding its coverage.

Domains outside mainland China and the default upstream

address
https://1.1.1.1/dns-query
domains
domain:wikipedia.org
Fallback settings
Keep this upstream as the default candidate

This example uses an endpoint with a certificate for its IP address, avoiding an extra lookup for the upstream hostname.

The following DNS snippet can be added to a complete configuration; it does not include inbound, outbound, or traffic interception rules. domains prioritizes matching upstreams. domain: matches a domain and its subdomains; it is not an access-control rule that prevents queries from crossing groups. The example uses skipFallback to exclude the mainland China upstream from general fallback candidates, so unmatched domains use the DoH candidate. If the preferred upstream fails, mainland China domains may still fall back to DoH. To prevent cross-group fallback after a match, check whether your core supports disableFallbackIfMatch and test what happens when an upstream fails. Disabling fallback means upstream failures will result in DNS resolution failures.

{
  "dns": {
    "queryStrategy": "UseIP",
    "servers": [
      {
        "address": "223.5.5.5",
        "port": 53,
        "domains": ["domain:baidu.com"],
        "skipFallback": true
      },
      {
        "address": "https://1.1.1.1/dns-query",
        "domains": ["domain:wikipedia.org"]
      }
    ]
  }
}

UseIP allows queries for both IPv4 and IPv6 addresses. UseIPv4 and UseIPv6 restrict queries to the corresponding address family. Temporarily switch to UseIPv4 for comparison only if you have confirmed an IPv6 outbound issue and need to isolate the cause. This field controls DNS queries made by the core; it does not disable IPv6 in the operating system and is not the routing module's domainStrategy. The latter controls whether domains are resolved to IP addresses during route matching.

DoH Outbound and DNS Pollution Troubleshooting

53
Default port for traditional DNS over UDP or TCP
443
Default HTTPS port, used by the example DoH endpoint

Check the query's outbound path before comparing answers

For this example configuration, first confirm that the DoH connection to 1.1.1.1:443 uses the expected outbound. A website loading successfully does not prove the query went through the proxy. Different IP addresses returned by two resolvers do not, by themselves, prove DNS pollution.

  1. Check the active configuration to confirm how DoH is set up. For standard https:// DoH traffic routed through the core, identify DNS traffic using a method supported by your core and place the corresponding rule before broader rules. Check the logs to see which outbound tag it matches. If your core supports a local DoH mode, do not mix it with DoH routed through the core.
  2. If you switch to a DoH URL that uses a hostname, check how that hostname is resolved for the initial connection. Do not rely on a DoH upstream to resolve its own hostname before the connection is established. If the proxy node address is also a domain, verify that it can be resolved independently before DoH is available.
  3. Visit one domain assigned to a group and one that is not. Clear the app's cache or restart the test app, then compare core logs, outbound tags, and system connection records over the same time period. If you expect DoH to be the only resolver but see the test domain queried in plaintext by the system to another address, check the interception boundary and fallback settings first.

DoH encrypts queries in transit to the selected resolver. It does not guarantee that the resolver always returns correct records or hide the queried domain from that resolver. CDN addresses can differ by region; caches may not have expired; and checking A records without AAAA records can also produce different results. When troubleshooting, keep the domain, record type, and observation time consistent, then check for unexpected private IP addresses or redirects.

When FakeDNS Can Work

FakeDNS returns synthetic addresses to apps and keeps a mapping between each address and its domain in the core. Subsequent connections must pass through the same core, which must recognize the mapping to restore the domain and continue route matching. FakeDNS is not a replacement for DoH: it controls the synthetic addresses apps see, while real addresses still need to be resolved by the relevant outbound or remote resolver when required.

  1. Turn off FakeDNS first and verify DNS groups and outbound paths with standard DNS. Confirm that the client is using a core that supports FakeDNS and can intercept both DNS requests and connections from the test app. Enabling the system proxy alone is not enough to verify this.
  2. Set up a synthetic address pool in the format required by your core, enable FakeDNS for queries that need synthetic responses, and configure the inbound that receives subsequent connections to sniff and restore domains as appropriate. For custom configurations, make sure the address pool does not overlap with your LAN, other virtual network adapters, or existing static routes.
  3. Test with a single app first. Check the logs for both synthetic DNS responses and subsequent connections with the original domain restored. Keep standard DNS for LAN services that need real addresses. After changing the configuration or restarting the core, clear the test app's cache in case it still holds old synthetic addresses, then test again.

For desktop v2rayN, check the selected core and the configuration it actually generates. Android v2rayNG uses Xray, while v2flyNG uses V2Fly. Similar-looking DNS options in the interface do not mean that configuration fields or FakeDNS settings can be copied unchanged between clients. Save a working configuration before adding custom fields, so they are not overwritten when the client generates a new configuration.

Troubleshooting Common Issues

Why doesn't the domain appear in the logs after I change DNS?

Trigger a request from a newly opened test window and check whether the app has cached an address or enabled its own secure DNS. If system queries still do not reach the core, check how the client intercepts traffic. Querying a specific server from a terminal only verifies that server's response; it does not prove the app follows the same path.

Why can't I connect after switching to DoH?

Check the logs first: is it a connection timeout, a certificate error, or a DNS resolution failure for the proxy node? For timeouts, verify the DoH target and outbound. For certificate errors, check the system clock and whether the endpoint supports the IP address or hostname in use. If the failure occurs only on a cold start, focus on startup dependencies between the node and the upstream.

Why do mainland China domains show up in remote upstream logs?

First check whether the actual request matches a suffix covered by your rule; a page may also query separate domains for its resources. If it does match, check for timeouts from the mainland China upstream, fallback settings, and browser-level DNS. Change one setting at a time, then retest the same domain and record type.

Download clientsChoose v2rayN or v2rayNG for your platform