October 15, 2026 · Configuration · About 10 min read

V2Ray DNS Configuration: Split DNS by Domain and Prevent DNS Spoofing

Learn how V2Ray DNS servers, domains, and queryStrategy work, route local and international domains to different resolvers, and troubleshoot common DNS issues.

At a glance

DNS split routing involves two separate decisions: which resolver handles a domain, and which outbound connection carries the query. This guide is for users who can connect to a proxy but are seeing DNS timeouts or unexpected domain routing. It explains the relevant fields, how to merge the settings, and how to verify them using V2Ray-style JSON. The examples are configuration snippets, not complete, runnable client configurations. If you use the Xray core, check which fields your version supports.

1. DNS Routing Is Not the Same as Connection Routing

First, adding a remote DNS server to your client does not mean every app will use it. Browsers can enable encrypted DNS independently, operating systems maintain their own caches, and proxy protocols may pass domain names to the server for resolution. The servers rules below only apply when a request actually reaches the built-in DNS module.

Domain reaches the core A DNS lookup is triggered A resolver is selected Query route is selected Address is returned

This sequence describes what happens when the built-in DNS module is called. It does not mean every proxy connection is resolved locally. After receiving a domain, the client can usually pass it to the server if routing selects a proxy outbound. A local lookup may be triggered if routing needs an IP address to make a decision, or if a direct connection needs the destination IP. The exact behavior depends on the routing policy and outbound configuration.

A system proxy generally handles requests from apps that honor the proxy settings; it does not automatically route all device DNS traffic. TUN can capture more traffic, but DNS hijacking, routing, and exclusions still need to be configured. The toggle state alone does not tell you whether queries reach the core.

2. What servers, domains, and queryStrategy Control

servers is a list of candidate resolvers. The domains property on a server object specifies which domains should prefer that resolver. queryStrategy controls whether to query for IPv4, IPv6, or both. These fields work at different levels; none can replace another.

FieldExample valueWhat it does
serversIP address or DoH URLDefines available resolvers and the conditions for matching each one.
domainsgeosite:cnMatches a set of domains and prioritizes the associated resolver.
queryStrategyUseIPAllows A and AAAA lookups; it does not guarantee that either address type is reachable.
queryStrategyUseIPv4Queries IPv4 addresses only; useful for isolating IPv6 connectivity issues.
skipFallbacktrueExcludes this resolver from the usual fallback candidates for domains that do not match.

Do not treat domains as a strict access whitelist. Whether another server is tried after a lookup fails also depends on fallback settings. The example below uses skipFallback to keep the local resolver from serving as the usual fallback for unmatched domains. It does not mean that a failed lookup for a matched domain will never be retried with another resolver.

Local resolver

Address
223.5.5.5
Port
UDP 53
Matching scope
geosite:cn
Fallback role
skipFallback: true

Used here for a set of domains in mainland China; this is not a dedicated DNS server for a corporate intranet.

Default remote resolver

Address
https://1.1.1.1/dns-query
Port
TCP 443
Matching scope
Domains outside the local set
Query route
Explicitly points to an existing proxy outbound

DoH encrypts query contents; connectivity depends on the network and proxy outbound.

geosite:cn relies on domain rule data in the runtime directory; the core does not identify locations on its own. If the startup log reports a missing rule file, fix the resource files first. For corporate intranet domains, use an appropriate domain: match and send queries to the company’s internal resolver. Public DNS servers cannot be expected to return internal IP addresses.

3. DNS Configuration for Split Routing by Domain

This example uses a local resolver and a default DoH resolver. The goal is to query domains in mainland China locally and use the remote resolver for other domains. Back up your configuration, then merge the top-level dns object into the existing JSON. If an object with the same name already exists, edit it instead of adding a second dns key.

{
  "dns": {
    "queryStrategy": "UseIP",
    "servers": [
      {
        "address": "223.5.5.5",
        "port": 53,
        "domains": [
          "geosite:cn"
        ],
        "skipFallback": true
      },
      "https://1.1.1.1/dns-query"
    ]
  }
}

The DoH endpoint uses an IP address to avoid a bootstrap dependency on resolving the DNS server’s hostname. If you use a DoH URL with a hostname instead, check which resolver handles that hostname and whether the lookup depends on the DoH service that is not yet reachable.

  1. Check the core: v2rayN is a client interface, not a V2Ray core. Check the core startup log to see whether V2Ray or Xray is running, then verify which fields it supports.
  2. Check the rule files: Startup must not report a failure to load geosite:cn; otherwise, the matching rules cannot work as intended.
  3. Check the generated configuration: Restarting the client may overwrite manual edits if it generates the configuration through its interface. Save changes through the client’s supported custom configuration option, then inspect the configuration actually passed to the core.
  4. Check the address family: Keep UseIP as the normal dual-stack setting. Temporarily switch to UseIPv4 only to investigate an IPv6 issue, and record the results for comparison.

This snippet has no inbound, proxy server, or outbound definitions, so it cannot run on its own. On Android, v2rayNG uses the Xray core and v2flyNG uses the v2fly core. Even if both interfaces have a DNS section, check their configuration overrides and operating modes separately.

4. Route DNS Queries Through the Right Outbound

A resolver address alone does not define the query route, so a “remote DNS” request may still go direct. Standard https:// DoH requests can go through core routing. Some cores support https+local://, which uses local access semantics; it is not an interchangeable version of the same URL.

{
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "ip": [
          "223.5.5.5/32"
        ],
        "port": "53",
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "ip": [
          "1.1.1.1/32"
        ],
        "port": "443",
        "outboundTag": "proxy"
      }
    ]
  }
}

This is a separate merge example. It assumes the existing outbound tags are actually named direct and proxy. Tags are references in the configuration, not objects created automatically by the core. Replace the example names with your actual tags, and place both query rules before any broad rules that could match them first. Do not use these rules to override existing application routing.

53
UDP port for regular DNS in this example
443
TCP port for DoH in this example
2 rules
Rules that explicitly control the query route

Bottom line: verify the query outbound before comparing resolver speeds

If the logs show a DoH connection using the direct outbound, fix the rule order and tag references first. Changing DNS server addresses will not fix an incorrect query route.

AsIs means the routing stage will not resolve domain names just to evaluate IP-based rules. It does not mean application connections never need DNS resolution. With IPIfNonMatch, a request that does not match a domain rule may be resolved before IP rules are checked. With IPOnDemand, a rule that requires an IP may trigger a lookup. Before changing these values, confirm that you actually need IP-based routing.

Also check how the proxy server’s own hostname is resolved. If connecting to the proxy requires a DoH lookup through that same proxy, you have a circular dependency. Use a clearly defined bootstrap resolution path or an address confirmed by the provider; do not change server details from your subscription arbitrarily.

5. Prevent DNS Spoofing: Check Encryption, Routing, and Caches

DoH protects queries in transit between the client and resolver, but it cannot guarantee the results will meet your expectations. Resolver location policies, website CDN routing, device caches, and IPv6 connectivity can all lead to different addresses or successful lookups followed by failed connections. Different IPs from two resolvers are not, by themselves, proof of DNS spoofing.

The local resolver in this example uses regular UDP queries, so that part is not encrypted. If plaintext queries are unsuitable for your network, choose a reachable encrypted local resolver and design the corresponding routing rules. Do not just replace the address with a DoH URL without checking connectivity, certificate validation, and outbound policy.

Bottom line: Verify DNS resolution and application connectivity separately

Getting an A or AAAA record only confirms that the lookup returned a result. Next, check the address actually used by the application connection, its outbound route, and the error type. Then determine whether the issue is DNS resolution, IPv6 connectivity, or a failed proxy connection.

6. DNS Troubleshooting Steps and FAQs

Save a working configuration first, then check in this order: core startup, outgoing queries, returned results, and application connections. Temporarily increase log verbosity and reproduce the issue with a single target so concurrent requests do not obscure the relevant entries. Restore your normal log level afterward, and remove subscription URLs and connection credentials before sharing logs.

nslookup -type=A example.com 223.5.5.5
nslookup -type=AAAA example.com 223.5.5.5
ipconfig /flushdns

example.com is a reserved example domain used for illustration. The first two commands query the specified regular DNS server directly to check whether that route works. They do not automatically use V2Ray’s built-in DNS or prove that DoH is going through the proxy. To verify core DNS routing, make a request from a real application and check the core logs and active configuration.

Why does my browser still show the old result after I change DNS?

First check whether the browser has its own secure DNS enabled. Then clear the system cache and restart the browser. Next, verify that the new address appears in the configuration actually running in the core; editing a JSON file that is not loaded will not affect current connections.

Regular DNS works, but DoH keeps timing out. Why?

First check whether the TCP connection to the DoH endpoint on port 443 uses the expected outbound. Then confirm the node is working and the system clock is correct. If the log shows a certificate error, do not disable certificate validation; check the clock, endpoint, and network interference instead.

What does it mean if switching to UseIPv4 makes the site load?

This usually points to an IPv6 connectivity issue, not proof that the original DNS was spoofed. Compare the A and AAAA results, check the device’s default route, the node’s IPv6 outbound support, and the destination connection error before deciding whether to restrict the address family permanently.

Why can’t public DNS resolve my company’s intranet domains?

Match the company domain suffix separately and send it to the company’s internal DNS server over the intranet’s direct connection. If TUN captures the relevant traffic, also check LAN routes and exclusions. Public resolvers generally do not have records for private internal zones.

My settings disappeared after updating the subscription. Should I edit the generated file again?

First check whether custom DNS settings belong in the client’s global configuration, a configuration template, or an individual profile. Save the changes through a persistent option supported by the client, then restart the core and check the generated configuration. Avoid repeatedly editing temporary runtime files.

The final check is not how many DNS servers you have entered. All three of these must be true: local domains use the intended resolver, remote queries use the intended outbound, and application connections follow the planned routing. For more on client settings and configuration structure, see the client configuration guide and technical reference.

Download V2Ray Clients