For readers who can already connect to a node and are ready to adjust core settings. First identify whether DNS queries come from the app, the OS, or the core. Then configure an upstream for domains in mainland China and a default DoH resolver for other domains. Finally, compare A and AAAA lookups for the same domain with core logs to distinguish fallback behavior, DNS issues, and outbound connection failures.
1. Core DNS vs. Routing
The top-level dns section configures the core's resolver: which upstream it queries and how it matches domains when the core needs an address. routing determines which outbound handles a connection. Resolving a domain with a DNS server in mainland China does not mean the connection will go direct. Likewise, using DoH does not automatically route the connection to the destination through a proxy.
This flow applies only to requests handled by the core resolver that do not hit the cache. If an app first uses the system resolver and then passes an IP to the proxy, the core usually never sees the original domain, so domain matching in dns.servers does not apply to that query. Conversely, an app sending a domain to a SOCKS proxy only means the domain reached the inbound. If the core passes it straight to a remote outbound, there may still be no local DNS query to log.
- At the app level: Check whether the browser has its own Secure DNS setting enabled, and whether proxy requests pass a domain or an IP. Change one setting at a time during testing; avoid changing both the app and the core simultaneously.
- At the core level: For a custom setup, check the complete configuration in use at runtime. In v2rayN, first confirm which core is selected, then open Settings → Parameter Settings from the main window and check the local listener settings. Use the port specified by the active configuration.
- What gets intercepted: Enabling the system proxy does not mean system DNS is intercepted. If you use TUN, check whether the client is configured to intercept DNS and whether those queries follow the intended processing path.
2. Prioritize Domains in Mainland China and Use DoH by Default
dns.servers is the list of upstream resolvers. With object syntax, domains specifies which domains an upstream should match first; queries without a dedicated match use the default candidates. These groups define query priority, not a privacy boundary: depending on the core configuration, it may try other candidates if the matched upstream returns no usable result.
Mainland China domain group
- Match criteria
geosite:cn- Upstream address
192.168.50.53- Traditional DNS port
53- Default fallback candidate
skipFallback: true, exclude this upstream
The example uses a LAN recursive resolver. Use an address appropriate for your network.
Other domains
- Match criteria
- No domain list specified
- Upstream type
- HTTPS-based DoH
- Connection port
- Default
443 - Endpoint path
- Use the path specified by the provider
Choose a trusted, reachable upstream, and verify how its endpoint hostname is resolved initially.
The snippet below uses the legacy top-level JSON format for V2Ray v5; it is not a complete client configuration. geosite:cn requires the domain rule data to be installed, and its categories depend on the data actually available. For an initial test, you can replace it with an explicit suffix such as domain:example.cn, using a real domain whose classification you have verified. resolver.example is a reserved example domain; replace it with an actual DoH endpoint. Replace the LAN resolver address as well. When merging the snippet, keep your existing inbounds, outbounds, and routing rules. Do not use it to overwrite the entire configuration.
{
"dns": {
"servers": [
{
"address": "192.168.50.53",
"port": 53,
"domains": ["geosite:cn"],
"skipFallback": true
},
"https://resolver.example/dns-query"
]
}
}
Bottom line: Verify both matching and fallback
skipFallback: true prevents the mainland China upstream from becoming a general candidate for other queries, but it does not stop domains in that group from falling back to the default DoH resolver. If an internal suffix must never be sent to a public resolver, test what happens when the primary upstream is unavailable in a controlled environment before migrating that suffix. One successful lookup is not proof of isolation.
3. Choosing routing.domainStrategy
routing.domainStrategy controls when routing tries to resolve a domain to an IP address for rule matching. It does not select a DNS server in mainland China or elsewhere, nor does it choose between A and AAAA queries. Check domain and IP conditions in the order the rules are actually evaluated. If the inbound already supplies an IP, the core can match IP rules directly without first resolving a domain.
| Strategy | When resolution occurs | When to use it |
|---|---|---|
AsIs | Routing does not resolve domains just to match rules. | When routing relies mainly on domain rules, or you want to pass domains to the outbound for handling. |
IPIfNonMatch | If no rule matches on the first pass, the core tries resolving the domain and matching by IP. | Explicit domain rules take priority; unmatched requests are then evaluated against IP rules. |
IPOnDemand | The current target domain may be resolved when a rule requiring an IP is evaluated. | When rules need the destination IP early and you have confirmed the DNS path works. |
A common oversight is a fallback rule that matches on the first pass. For example, with IPIfNonMatch, a general rule that always matches the current inbound already produces a result, so the core will not resolve the domain for an earlier geoip rule. When troubleshooting, check the matched outbound tag first, then decide whether to change the strategy or narrow the general rule's match conditions.
4. DoH Endpoints, Bootstrap DNS, and Outbound Routing
DoH carries DNS messages in HTTPS requests. Proper TLS verification helps prevent responses from being injected or altered in transit, but it does not verify that the upstream's records are what you expect. Use the full hostname and path provided for the endpoint. Replacing the hostname with an arbitrary IP may cause certificate name verification to fail. And just because a browser can open the endpoint's website does not mean that path accepts DNS messages.
- First, check how the endpoint hostname is resolved. The endpoint's address must be known before a DoH connection can be made. If resolving it depends on the same DoH service that is not yet reachable, you can create a loop. Give the endpoint an independent, verifiable bootstrap resolution path. If you use a static mapping, use an address confirmed by the provider, keep the original hostname in the HTTPS URL, and account for possible address changes.
- Next, check how DoH requests are routed. In the relevant V2Ray configuration, regular
https://DoH requests go through core routing;https+local://connects directly from the local machine—it does not use a proxy outbound. If your client generates the configuration, follow the syntax supported by the selected core and verify the active configuration. - Finally, identify where the failure occurs. Endpoint hostname resolution failures, connection timeouts, certificate verification errors, and incorrect HTTP paths are different problems. Fix the first observable failure rather than disabling certificate verification and turning a connection problem into a trust problem.
5. Troubleshooting Unexpected DNS Results: Groups, Caches, and Connections
- Start by testing each upstream directly. On the same network, test the mainland China upstream with a public domain confirmed to belong to that rule group, then test the default DoH resolver with a domain from another group. If
digis installed, use@to specify a traditional DNS server and query A and AAAA records separately. This bypasses the app's proxy path and tests only the specified upstream's response. The addresses and domains below are examples; replace them for your environment before running the commands. - Then check the active core path. Reload the configuration and check for invalid fields or failed rule-data loading. Retest with an app that sends the domain to the proxy. At an appropriate log level, compare the queried domain, upstream query records, and final outbound tag. Seeing only the destination IP does not prove domain grouping is broken; first check whether the app resolved the domain before sending it.
- Distinguish the response types.
NXDOMAINmeans the resolver considers the domain nonexistent.NOERRORwith no record of the requested type may simply mean the site has no AAAA record. A timeout means no response arrived in time. If a public domain returns an unexpected private IP, check static mappings, LAN overrides, and upstream policy first, then verify through a trusted resolver. Different CDN addresses in different regions do not, by themselves, indicate DNS pollution. - Change one layer at a time. Even after reloading the core, the OS and browser may retain cached results. Clear caches layer by layer or wait for the record's TTL to expire, then retest the same domain and record type. If the resolved address is as expected but the browser still cannot connect, check the address family used for the connection, outbound routing, and TLS logs. Don't keep switching DNS providers blindly.
dig @192.168.50.53 example.cn A
dig @192.168.50.53 example.cn AAAA
Bottom line: Check DNS query records alongside connection logs
Keep a test record with the domain, record type, upstream actually queried, returned address, and outbound used for the connection. If problems appear only after switching networks, retest endpoint reachability and the upstream baseline before comparing outbounds. This helps separate changes to the DNS path from changes to the application connection.