At a glance

For users who can already connect to a server with v2rayN and want to review their DNS routing. Using V2Ray core JSON as an example, this guide distinguishes application DNS, built-in DNS, and proxy egress. It provides a configuration snippet that prioritizes local resolution for domains in mainland China and uses DoH for other domains, then explains how to check fallback behavior, routing, and DNS results. This is not a complete client configuration and cannot be pasted into DNS editors for other cores as-is.

1. First, identify what handles DNS requests

When DNS settings appear to have no effect, the problem often isn't an incorrect server address—the query may never reach the resolver you expect. The Windows system resolver, a browser's Secure DNS, V2Ray's built-in DNS, and the resolver on the proxy server are separate parts of the process. Changing one doesn't automatically change the others.

Application sends a domain Inbound receives it Routing decision Resolve if needed Outbound connection

This diagram shows a common flow, but not every connection uses built-in DNS. For example, a browser using an HTTP proxy may submit the domain for the remote proxy to resolve. If the application resolves it locally first and passes the IP to the proxy, the core may receive only an IP address. Enabling “System proxy → Automatically configure system proxy” alone does not take over all Windows DNS requests.

2. What do servers, domains, and expectIPs control?

servers defines the available upstream resolvers. A server object's domains sets query priority for specified domains, while expectIPs defines the expected address ranges in that server's responses. They answer three different questions: “which resolver?”, “which domains should prefer it?”, and “which results are acceptable?” Don't treat them all as traffic-routing rules.

FieldExampleWhat it does—and its limits
servers223.5.5.5、DoH URLConfigures an upstream resolver; it does not determine which outbound route a website connection uses.
domainsgeosite:cnWhen matched, this server is queried first; the corresponding domain-rule data must be available.
expectIPsgeoip:cnChecks whether returned addresses fall within the expected range; this does not prove they are trustworthy or block all DNS poisoning.
skipFallbacktrueThis server is excluded from general fallback when no domain rule matches, but can still resolve domains that match its own rules.
queryStrategyUseIPv4Sets the address-family policy for built-in DNS; it does not disable IPv6 in the operating system.

domains is not an exclusive access-control rule. If a query to a matching server fails, or its response does not satisfy expectIPs, the query may still enter the fallback process. To restrict a mainland China resolver to specified domains, set skipFallback: true for it and keep an unrestricted remote resolver as the default candidate.

Bottom line: Limit the domains handled by local resolvers

Putting the mainland China resolver in a server object with domains and skipFallback makes its scope clearer than simply placing it first in the list. Otherwise, it may receive queries intended for a remote resolver during fallback.

3. Split DNS example: Prefer a local resolver for mainland China; use DoH for other domains

This example uses 223.5.5.5 as the preferred resolver for domains in mainland China and https://1.1.1.1/dns-query as the default DoH upstream. “Local resolution” here means connecting directly from your device to the specified resolver—not using DNS automatically supplied by your router or ISP. These addresses are examples; verify that they are reachable and return suitable results on your network.

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

Preferred resolver for domains in mainland China

Upstream address
223.5.5.5
Transport port
UDP 53
Domain scope
geosite:cn
Expected results
geoip:cn

Set skipFallback to true so this server isn't used as a general fallback for other domains.

Default DoH resolver

Upstream address
https://1.1.1.1/dns-query
Transport port
HTTPS 443
Domain scope
No domain restrictions; used as the default candidate
Outbound requirement
Specify the proxy outbound in routing rules

After configuring a DoH URL, check which outbound route its connection actually uses.

For domains matching geosite:cn, the mainland China resolver is queried first. Other domains use the unrestricted DoH candidate. If the mainland China resolver returns an address outside the expected range, the query may move on to another candidate. Avoid casually adding an unrestricted localhost: that would bring the system resolver back into the fallback path and undermine the boundary you're trying to establish.

expectIPs: ["geoip:cn"] is a relatively strict policy. Some websites in mainland China use overseas CDNs, so legitimate responses may be rejected and take longer to resolve. For those sites, check the specific domain and returned IP first, then adjust the domain group or that server's expected range. Don't assume an overseas IP means DNS poisoning.

4. Route DoH through your proxy: Add routing rules

DoH encrypts traffic to the resolver; it doesn't guarantee that requests automatically go through the proxy. In V2Ray, regular https:// DoH requests can be handled by routing, while local-mode https+local:// requests do not go through routing in the same way. If you want remote DoH to use your proxy server's egress, don't mix up these two formats.

These snippets still need to be merged into an existing configuration. They assume outbounds already contains a direct outbound tagged direct and a working proxy outbound tagged proxy. If your actual tags differ, replace them with the correct ones. Put these two rules for the upstream addresses before any broad rules that might match first.

{
  "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"
      }
    ]
  }
}

By default, connections that don't match a rule use the default outbound, which is typically determined by outbound order. Don't skip checking DoH's outbound route and assume that receiving a response means the query went through the proxy. If your server address is a domain, it also needs an independent, working bootstrap resolution path; otherwise, you'll have a circular dependency where you need to connect to the server before you can resolve its address.

5. Before applying settings in v2rayN, keep a known-good baseline

v2rayN is a configuration management client, not a DNS protocol. Settings saved in its interface are converted into the core's runtime configuration. Direct edits to a temporary generated file may be overwritten when you switch servers or restart the core. Pasting V2Ray JSON into the configuration area for a different core may also prevent startup.

  1. Record the current state. Save your existing DNS settings, current server, and routing mode. Make sure the current configuration can open the sites you use before changing the DNS strategy.
  2. Choose the right configuration area. Under “Settings → DNS settings,” select the section for your current core. If your version provides a full DNS JSON editor, enter only the DNS object structure it expects—not the entire example file.
  3. Manage full configurations separately. To maintain routing and outbounds yourself, use “Servers → Add custom configuration server” to import a complete core configuration. The two snippets in this guide omit inbounds, proxy outbounds, and other required elements, so they won't run as standalone configurations.
  4. Restart the core and check the logs. Check JSON syntax, rule resources, and outbound tag errors before testing the network. A successful save doesn't guarantee a successful start.
  5. Add features one at a time. First verify the default DoH resolver, then add the mainland China domain preference, and finally check TUN or browser-specific DNS settings. Change one layer at a time to make regressions easier to track down.
53
UDP port for the example mainland China upstream
443
HTTPS port for the example DoH service
10808
Common local mixed-listener port; use the value shown in your settings

A local mixed-listener port is not a DNS port. Pointing an app's HTTP or SOCKS proxy to this port is entirely different from entering it as a DNS server. Check “Local mixed listener port” under “Settings → Parameter settings,” and don't substitute the example ports 53, 443, and 10808 for one another.

6. Verify split DNS and DNS leak protection: Check queries, outbound routes, and results separately

The goal isn't to find one “always correct” DNS address. It's to confirm that queries reach the expected upstream, connections use the expected outbound, and the returned addresses fit the website's actual deployment. CDNs return different addresses based on resolver location, proxy egress, and timing. Different results from two resolvers don't, by themselves, prove DNS poisoning.

What to checkWhat to doWhat this does not prove
System resolver baselineRun nslookup www.baidu.com 223.5.5.5 and note the response or any errors.This does not prove that V2Ray's built-in DNS queried that upstream.
Proxy connectivityUse an explicit proxy to request an HTTPS website and confirm that the server is reachable.A website loading doesn't mean DNS is intercepted for every app.
Upstream outbound routeCheck the core's debug logs and routing records to confirm which outbound handles the connection to 1.1.1.1:443.An encrypted connection alone does not reveal or prove the contents of a specific query.
Domain-based routingTest domains that match the mainland China rules and domains that don't; note which upstream is selected for each.One successful domain test doesn't prove that all domain rules loaded correctly.
nslookup www.baidu.com 223.5.5.5
ipconfig /flushdns
curl.exe --proxy http://127.0.0.1:10808 --head https://www.microsoft.com/

These are three separate checks: the first tests a specified resolver, the second clears the Windows DNS cache, and the third tests the local HTTP proxy connection. Before running the third, replace the port with the value shown in your settings. These commands are not an automated test for built-in DNS. In particular, an nslookup result does not prove that “DoH split routing is working.”

Clearing the system cache does not also clear every browser and core cache. To retest, restart the core and the test app. If you temporarily increase the log level, restore the usual level when you're done. Debug logs may contain visited domains, so don't post them publicly in full.

Bottom line: DoH protects DNS traffic in transit, but doesn't address every DNS risk

To determine whether this configuration meets its goals, confirm that the upstream is reachable, TLS validation succeeds, the outbound route is correct, and app queries follow the controlled path. The resolver name shown on a test page isn't enough.

7. Common split DNS questions

Why does the connection time out even though I entered a DoH address?

First check whether the server can reach HTTPS, then verify the route to the DoH address. In this example, 1.1.1.1:443 should use a working proxy outbound. Also check the system clock and TLS errors. If you switch to a hostname-based DoH URL, check that the upstream hostname can be resolved during bootstrap.

Why are websites in mainland China slower after I set expectIPs?

Check whether the domain's actual response includes an IP from an overseas CDN. A result outside geoip:cn may be rejected or trigger fallback. Adjust the domain group or expected range for that domain first; don't keep adding resolvers to mask a misclassified domain.

Why can the system still look up IPv6 addresses after I set UseIPv4?

UseIPv4 applies to the current built-in DNS, not to Windows system-wide settings. Check whether the test uses a browser's own DoH, the system resolver, or another app. To centralize resolution, first route the app through the same controlled path, then assess the address-family policy.

Do I still need to check DNS settings when TUN is enabled?

Yes. TUN expands traffic capture; it doesn't automatically ensure the right upstream or outbound route. Check which core is actually running, then verify DNS interception, LAN resolution, and routing to remote upstreams. If you change cores, repeat the checks using the configuration format for the new core.

Wouldn't it be simpler to send every domain to remote DoH?

It means less configuration, but CDN routing for sites in mainland China may not work well with direct local connections, and LAN domains may stop resolving. Keep any necessary local-domain rules, then decide whether to send regular public domains to a remote upstream. Don't send internal domains to an unrelated public resolver.