V2Ray DNS Configuration: Split DNS and DNS Spoofing Protection

Learn how V2Ray DNS servers, domains, and expectIPs work, how to route mainland China and overseas domains to different resolvers, and how to reduce DNS spoofing.

At a glance

For users who already have v2rayN running and need to troubleshoot DNS issues or configure split DNS. First check whether queries reach the core, then assign upstream resolvers by domain. Use logs to distinguish lookup failures, filtered addresses, and outbound connection failures.

DNS routing vs. traffic routing

DNS routing determines which resolver looks up a domain. Traffic routing determines which outbound handles the connection. A domain queried through a remote resolver does not necessarily use a proxy for its traffic. Likewise, proxying traffic does not prove that the browser's DNS queries pass through the core.

DNS queryRule matchingUpstream lookupResult filteringAddress returned

This flow applies only to queries handled by the core's built-in DNS. An app may use the operating system's resolver first, then pass the IP to the proxy; a browser may also use its own secure DNS. Enabling the system proxy does not route all device DNS through the core. If the core receives only a destination IP, it cannot apply domain-based DNS rules retroactively.

How to configure servers, domains, and expectIPs

servers lists the available resolvers. Object entries let you add domain-matching and address-filtering conditions. domains applies to query names, while expectIPs applies to lookup results. The latter neither modifies the answer nor verifies that it is genuine.

Local resolver entry

address
localhost
domains
geosite:cn
expectIPs
Omit for an initial setup

Uses the system resolver path; domain classification depends on the active rule data.

Remote resolver entry

address
https://1.1.1.1/dns-query
domains
Omit as a general-purpose fallback
expectIPs
Omit the region filter

An HTTPS upstream needs a working connection first; specifying its address does not select an outbound route.

The following is an example dns section, not a complete, standalone configuration. Unclassified domains may also use the general-purpose upstream, so remote resolver entries should not be treated as an exact list of “overseas domains.”

{
  "dns": {
    "servers": [
      {
        "address": "localhost",
        "domains": ["geosite:cn"]
      },
      {
        "address": "https://1.1.1.1/dns-query"
      }
    ]
  }
}

domains matching prioritizes an upstream; it does not isolate queries. Whether other servers are tried after a lookup fails or a result is rejected depends on the core version and fallback settings. For corporate intranet domains, verify explicit suffix rules and fallback behavior. Do not rely on list order alone to keep internal queries away from public resolvers.

To filter results, cores that support this field can use "expectIPs": ["geoip:cn"] in the relevant upstream object. This checks answers against IP classifications. Domains served by cross-region CDNs may return valid addresses outside that classification. First record normal results on the same network, then apply filtering only to queries with genuine address-range requirements. If errors start after adding the filter, remove it and test again.

DNS spoofing protection: Check encryption, outbound routing, and fallback

DoH sends queries over HTTPS, reducing the chance of forged responses being injected into unencrypted DNS traffic. It cannot guarantee that an upstream returns correct records, and it does not cover queries that bypass the core. If changing resolvers causes failures only when the core is enabled, check the DoH connection before adding more upstreams.

53
Default port for standard DNS
443
Default port for HTTPS upstreams

Bottom line: trace the connection on the port that is failing

If the logs show a timeout connecting to a DoH upstream on port 443, check the outbound route selected for that connection and whether it is reachable. Changing domain categories for regular traffic will not fix an unreachable upstream.

  1. First confirm that the remote upstream is reachable. For a DoH URL that uses a hostname, check how that hostname is resolved initially; avoid a setup that requires connecting to the upstream before its own hostname can be resolved. For an IP-based URL, confirm that the service supports certificate validation for that address.
  2. Check the actual outbound route used for remote queries. If a query depends on a proxy, but the proxy server itself needs that query to resolve, you have a startup dependency. Test node hostname resolution separately from business-domain lookups.
  3. Verify that fallback works as expected. If a failed remote lookup falls back to the local resolver, the page may load again, but that does not mean the query still used an encrypted connection. Check the logs to see which upstream returned the final response.
  4. Keep the original configuration. Test one local domain and one remote domain first, then expand the categories. Avoid changing nodes, system proxy mode, and DNS at the same time, or it will be difficult to identify what caused the change.

Verify split DNS and troubleshoot common issues

For the same domain, record the A and AAAA results, the upstream selected, and the status of the actual connection. System lookup tools usually test only the resolver path they use; they cannot directly confirm that the core's rules are working. If you still see an old answer after changing the configuration, clear the relevant app or system cache and test again through the same entry point. Different upstreams may return different CDN addresses; that alone does not indicate DNS spoofing.

Changed DNS settings, but why is the browser still using the old resolver?

Check the browser's Secure DNS settings to see whether it selected a different upstream. Then make a fresh, uncached query and check whether the core logs show the same domain. If not, check the app's proxy entry point instead of continuing to adjust domains.

Why do mainland China websites time out after I add expectIPs?

Without changing other settings, remove expectIPs from that upstream and query the same domain again. If it works, check whether the returned address was covered by the rule data and whether filtering triggered a fallback to another upstream.

The core returned an IP address, so why won't the page load?

Check which outbound route handled the connection, then determine whether it timed out or failed during the TLS handshake. If the problem occurs only with AAAA records, test IPv6 connectivity through the current outbound route separately. Not every connection failure is a DNS issue.

How can I confirm DNS settings are still active after updating a subscription?

First check which core the newly selected node uses, then review the configuration loaded at startup and the logs. Switching nodes may also change the core or configuration generation path, leaving the old snippet unused. Rerun the two tests you recorded earlier; do not rely only on the text saved in the settings screen.

Download v2rayN