V2Ray DNS Leak Test & Prevention: v2rayN DNS Settings

Learn what causes DNS leaks and how to test for them. Configure remote DNS, domain routing, and TUN mode in v2rayN and v2rayNG to prevent DNS queries from bypassing the proxy.

At a glance

For users whose nodes connect successfully but who aren't sure which resolver handles domain lookups. First, record the recursive resolvers used by the same app with and without the proxy, then review how traffic is routed on desktop and Android. When testing, distinguish the browser's encrypted DNS, direct LAN traffic, and node address lookups.

How to identify a DNS leak

Your proxy exit and DNS exit are separate paths to check. A browser may ask the system resolver for an IP address, then send the connection through the proxy. The site will show the proxy's exit IP, while DNS queries may still be handled by your router or ISP's recursive resolver. This is a leak only if your rules require proxied domains to use a designated remote resolver. Local domains intentionally routed directly are a separate case.

53
Traditional DNS default port (UDP or TCP)
853
DNS over TLS default port (TCP)
443
HTTPS default port, commonly used by DoH

Bottom line: check the query path, not just the port

No outbound traffic on port 53 means only that no traditional DNS traffic was detected; it doesn't prove DNS queries went through the tunnel. A browser may connect directly to a DoH service over port 443. Conversely, a connection on port 443 alone doesn't prove it's DoH.

Compare results to identify the DNS egress

  1. Record a direct-connection baseline. On a test network where direct access is allowed, open a DNS leak test site in the browser you use and note the site's exit IP, the recursive resolver IP and its organization, and the browser's current Secure DNS setting. The test reveals your exit information to the testing service. Use a test domain generated by the site; don't submit internal domains.
  2. Retest with the proxy enabled. Keep the network, browser, and node unchanged. Run one test with only the system proxy enabled, then turn it off and run another with only TUN enabled. Start a fresh test each time so the site generates a new query name; refreshing old results may use cached data. If Secure DNS is enabled, compare results with it on and off as a separate test.
  3. Understand what the results show. A test site usually reports the recursive resolvers that queried its authoritative DNS server, not the full path between your device and those resolvers. Multiple IPs may belong to the same DNS service, and a different geographic location doesn't by itself indicate a leak. If both direct and proxied tests use the same public DNS service, identical results don't prove they used the same route.
  4. Use logs to fill in the gaps. Check client logs for DNS, outbound connection, and timeout entries around the test time. If you can monitor your device's physical network adapter, check for connections to unexpected resolvers during the test. The command nslookup shows only the lookup path used by that command; it can't replace testing in a browser or a specific Android app.

v2rayN: Remote DNS, domain routing, and TUN

On desktop, first check the active core and existing routing configuration. The Chinese menu names below are common in the v2rayN desktop app; fields may vary by release, core, and configuration mode. The remote DNS address, the outbound route for DNS queries, and whether app traffic is intercepted are separate settings. Changing one doesn't replace the others.

  1. Note your current settings

    In the main window, go to Settings → Parameter Settings to check the core and local listener settings. Then open Settings → Routing Settings and note the active profile and rule order. If you're using a custom core configuration, check the configuration actually loaded; don't assume the app's general options override it.

  2. Set up remote DNS

    Go to Settings → DNS Settings and enter the full DoH URL, including its path, in the configuration for the active core. If the configuration has separate remote and direct resolvers, send queries that should use the proxy to the remote resolver, and check that connections to it use the proxy outbound. An HTTPS URL encrypts the connection but doesn't guarantee that it goes through the proxy.

  3. Check the domain routing strategy

    In Settings → Routing Settings, review the domain rules and routing strategy. For Xray routing, AsIs doesn't resolve domains just to check IP rules; IPIfNonMatch can resolve a domain and then check IP rules if no domain rule matches. If you only need to route by domain, try AsIs for comparison. If your routing depends on IP rules, don't change the current strategy without testing. This setting can't prevent an app from resolving domains on its own.

  4. Route traffic through TUN and retest

    Turn on Enable TUN in the main window and grant any permissions required by your platform. If your version has a TUN DNS interception option, make sure it captures traditional DNS from the target apps, and check IPv4, IPv6, and network adapter exclusions. Test TUN on its own first, then restore your usual proxy setup. Also verify that LAN devices remain accessible.

v2rayNG: Android VPN and per-app routing

Core logs and common questions

lookup example.com: no such host

Cause: This log means the lookup didn't return a usable result; use the domain shown in the actual log. Fix: First determine whether the name in the log belongs to the node, the resolver, or the destination. Then check its spelling and DNS resolution path.

context deadline exceeded

Cause: The operation exceeded its time limit. Treat it as a DNS timeout only if it appears in logs related to DNS queries. Fix: Keep the node unchanged, restore the previous working DNS settings for comparison, and check the new resolver's outbound route and bootstrap DNS.

Why does the test still show my ISP's DNS after my exit IP changes?

Compare results from the same browser with the system proxy and TUN. If the resolver from your direct-connection baseline appears only with the system proxy, check whether the app resolves domains through the system before handing connections to the proxy. Then verify that TUN covers the app and both IP address families.

Can't access internal company domains after enabling TUN?

Check whether the issue affects only domain suffixes that require internal DNS. If your core supports choosing resolvers by domain, send only approved internal suffixes to the internal resolver and keep direct routes to internal services. After making changes, test one internal domain and one external domain. Don't restore intranet access by disabling interception globally.

The test lists multiple resolver IPs. Do I need to replace them all?

Don't judge by the number of addresses. Compare their organizations, the browser's Secure DNS settings, and results from repeated tests. Investigate the route only for unexpected resolvers. If the IPs change but all belong to the expected service, use logs to confirm that connections take the intended outbound route.

Download v2rayNChoose a platform and package