A detailed guide to V2Ray DNS split routing: configure local and remote DNS to reduce DNS poisoning

First, choose an upstream resolver for each domain in dns.servers. Then use routing rules to decide which outbound connection sends each query. Check both settings to confirm that split routing works as intended.

At a glance

This guide is for readers who can edit V2Fly core JSON and already have working outbounds. The example sends mainland China domains to a LAN DNS resolver and all other domains to remote DoH. It also covers fallback behavior, outbounds, and application-level DNS resolution. If you manage your config with v2rayN, first confirm which core is running and which config it has loaded, then apply the settings.

DNS Split Routing vs. Traffic Routing

dns.servers determines which resolver handles a domain; routing.rules determines which outbound handles traffic. Routing rules can match both DNS queries from the core and application traffic. These are separate decisions: sending a domain to local DNS does not mean the resulting web connection will use a direct outbound.

Domain inputUpstream selectionQuery outboundAddress returned

This flow applies only to queries initiated by the core. If an application resolves a domain through the system first, the core may receive only the destination IP. A browser with secure DNS enabled may also choose its own upstream. Enabling the system proxy alone does not automatically route DNS requests from the system and every application through the core.

53
Example local DNS UDP port
443
Example remote DoH HTTPS port

Identify which query path you're seeing

If you see traffic on port 53, first check whether the destination is your LAN resolver. This guide uses unencrypted local DNS, so that traffic is expected. The key question is whether queries for domains that don't match the local rule are taking the same path.

Configure dns.servers: Local DNS and Remote DoH

Merge this dns object into the top level of your existing config; don't use the snippet to replace the entire file. The example uses 192.168.1.1 as the LAN resolver. If your gateway doesn't provide DNS, replace this address and the routing address below with the address of your actual resolver.

{
  "dns": {
    "tag": "dns-query",
    "disableFallbackIfMatch": true,
    "servers": [
      {
        "address": "192.168.1.1",
        "port": 53,
        "domains": ["geosite:cn"],
        "skipFallback": true
      },
      {
        "address": "https://1.1.1.1/dns-query"
      }
    ]
  }
}

Local resolver

Address
192.168.1.1
Match scope
geosite:cn
General fallback
skipFallback: true

Used when a domain rule matches; not used as a general fallback for other domains.

Remote resolver

Address
https://1.1.1.1/dns-query
Match scope
Domains without a matching dedicated resolver rule
Query transport
HTTPS through core routing

Only queries sent to this upstream are encrypted, not all application connections.

geosite:cn checks the domain rule data loaded by the core. It doesn't match domain suffixes or look up which region a server is in. If the startup log says the rule set couldn't be loaded, first check that the core's resource directory contains geosite.dat, then confirm that the data file includes the cn category. To test a few domains you control, you can also use full: followed by the complete domain for an exact match.

disableFallbackIfMatch disables the general fallback when a dedicated rule matches. In this example, if a domain matches the local rule but resolution fails, the query won't be sent on to the remote upstream, which has no domain rule. This makes it easier to distinguish an upstream failure from a rule that didn't match, but it also means a local resolver outage will affect those domains. Avoid adding several public resolvers while troubleshooting, or it will be difficult to tell which one returned the result.

Set the DNS query outbound and domainStrategy

Use dns.tag to tag queries sent by the core, then match that tag with inboundTag. Add the following rules, in order, to your existing routing.rules, ahead of any general rules that could match these queries first. Replace direct and proxy with outbound tags that already exist in your config. These rules don't select an outbound for regular web traffic.

[
  {
    "type": "field",
    "inboundTag": ["dns-query"],
    "ip": ["192.168.1.1/32"],
    "port": "53",
    "outboundTag": "direct"
  },
  {
    "type": "field",
    "inboundTag": ["dns-query"],
    "outboundTag": "proxy"
  }
]

The first rule requires the tag, destination address, and port to match. The second catches other queries with the same tag—in this example, remote DoH. Using https:// sends the query through core routing; don't change it to https+local:// and expect routing to send it through the specified outbound. Using an IP address for the DoH endpoint avoids bootstrap resolution for that upstream hostname. However, if your proxy server is addressed by hostname, it still needs a separate working resolution path so it doesn't have to query through the proxy before connecting to it.

StrategyWhen the core resolves a domain for routingWhen to use it
AsIsRouting does not proactively resolve domains to IP addressesPrimarily routes by domain; IP rules can still match destinations that are already IP addresses
IPIfNonMatchTries to resolve and match the domain only if no rule matches on the first passPrioritizes domain rules, then uses IP rules if none match
IPOnDemandResolves the domain when a rule requires the destination IP during matchingWhen you need to match by IP early and can accept extra DNS queries

Test split routing: check the upstream first, then the core logs

  1. Test the local resolver on its own. Replace the address in the command below with your actual LAN DNS address. If the query times out, check that your device is still on that LAN, that the gateway provides DNS, and that UDP port 53 is reachable. A successful response only confirms that the upstream can answer; it doesn't prove that your application uses it.
  2. Confirm the core loaded your updated config. Back up your config, restart the core, and check the startup log. If it reports a config parse error, missing rule resources, or an unknown outbound, fix the startup issue first. If a client manages the config, check the active file for the dns object, query tag, and rule order.
  3. Choose one domain for each rule and compare. For example, check whether the current rule set matches www.baidu.com and doesn't match example.org, then send a request through a path that triggers core resolution. To test IPIfNonMatch, first make sure the traffic won't match a domain rule or catch-all on the first pass. Use the core logs to confirm the actual upstream and outbound; whether a web page opens is not enough to tell.
  4. Distinguish caching, resolution, and connection issues. For repeat tests, create a new application connection and, if needed, clear the relevant application or system DNS cache. If resolution succeeds but the page still times out, check the traffic outbound and connection errors. Different upstreams returning different IP addresses doesn't necessarily indicate DNS poisoning; CDN routing and cached records can also lead to different results.
nslookup -type=A www.baidu.com 192.168.1.1

An encrypted upstream can reduce the chance of queries being modified in transit, but only if TLS validation works correctly and the upstream is trustworthy. If you get a certificate error, check the system clock, the DoH URL, and whether the upstream certificate matches. Don't disable certificate validation just to get a connection.

FAQ: Why is the old DNS still in use after saving the config?

Why did my changes disappear after restarting v2rayN?

From the main screen, open Settings, then Parameter Settings, and check the active core and related options. Also confirm whether the selected profile is a regular node or a custom config. For regular nodes, the client may regenerate the runtime config, so don't rely on editing a temporary JSON file as a permanent change. For a custom config, edit the file you actually imported, reload it, and check the startup log.

Why don't I see any queries in the core logs even though the browser opens websites?

Check the browser's Secure DNS setting and whether it is reusing an existing connection. For a comparison test, temporarily turn off the browser's built-in secure DNS and start a new connection. Also confirm that the inbound receives a domain rather than an IP the application has already resolved. Even when it receives a domain, the core may not need to resolve it if routing has already matched and the outbound accepts domains.

Only remote resolution times out. Should I change the geolocation rules?

Leave the geolocation rules alone for now. Confirm that unmatched domains are actually selecting DoH, then check the outbound tag on the second query rule, whether that outbound is available, and whether an earlier rule is intercepting the request. If connecting to the proxy server itself requires a DNS lookup, first check whether that bootstrap query is being sent back through the same outbound before it has connected.

Download v2rayNView platforms and packages