Advanced v2rayN Configuration Guide

Subscription groups, routing, DNS, TUN and custom outbounds

For your first install, subscription import or connection test, start with the quick start guide. Once connected, use this page to look up settings by topic or symptom. This guide focuses on desktop v2rayN, with Android notes only where the settings or behavior can be meaningfully compared. If you haven't installed the client yet, visit the client downloads page and choose a package for your operating system and architecture.

Subscription Groups and Server Filtering

Group by source, filter by name

Open the subscription group settings in v2rayN. Create a separate group for each subscription source, using a short name that makes its purpose and source clear, such as “Daily,” “Backup” or “Test.” Group names are local labels; they don't determine which server handles a request or affect domain-based routing. A group won't automatically rotate among its entries, even if the subscription contains many servers. To see which server is in use, check the active selection in the main list.

After adding a group, update it once without a filter. Check the actual server remarks, naming patterns and protocol types in that group. Providers may identify the same region with country or region codes, Chinese place names or symbols, and may add usage notes before or after the name. Inspect the actual names before choosing what to match. For a quick, temporary lookup, use the main list's search instead. Search usually changes only what's shown, while group filters may affect which entries are added during an update, so they aren't interchangeable verification methods.

Write a regex you can verify

In the group editor, find the filtering field or toggle; its name and available options vary by client build. If the interface says matching entries are kept, use a pattern like the one below to match names in server remarks. Enter the expression itself in the regex field—don't add slash delimiters used by other languages. Update only this group, then check one known match and one known non-match. If the interface says matching entries are removed, don't reuse the same pattern as a keep rule.

(?i)(Hong Kong|Singapore|\bHK\b|\bSG\b)

This pattern matches Latin-letter names regardless of case and uses word boundaries for region codes to avoid matching the same letters inside longer words. Underscores are word characters in many regex engines, so HK_01 may not match \bHK\b. Don't remove the boundaries and hope for the best. Check the separators used in actual remarks before adding alternatives for underscores or hyphens. A remark containing “Hong Kong transit” will also match; that confirms only the name match, not the server's egress location.

SettingWhat it affectsHow to verify
Group nameHow entries are organized locallySwitch groups and check the source
List searchWhat appears in the current listClear the search and confirm entries reappear
Subscription filterSubscription entries processed by the client's filtering logicUpdate one group and check known matches and non-matches

Tell an empty list from an import failure or a dead server

If the list is empty after an update, clear the search and switch to the target group first, then check the update log. If the client recognized the subscription but entries disappeared after you added a filter, clear the expression and update that group again. If the entries return, the issue is likely the match condition or filter direction. If the log still reports a read failure, unrecognized response or login page, fix the subscription URL or access path instead of changing the regex. Entries shown before and after an update may also come from old data and the new response, respectively.

Leave room for filter maintenance. If a provider changes remarks from Chinese names to abbreviations, adds a prefix or renames a batch of entries, an overly specific expression may exclude them all. If you rely on this source day to day, keep a working configuration before changing its filter. Test unverified conditions in a test group; don't apply them to every group at once. To share diagnostic details, provide a few redacted remark examples—never include the subscription URL.

Finally, select a server that remains in the list and confirm the client can connect. Being parsed from a subscription only means an entry is available to select; it doesn't guarantee that its protocol, transport settings or your current network are compatible. If entries have identical names, check their source groups and actual protocols, not just their remarks. With v2rayNG or v2flyNG, check the subscription manager in each app for equivalent filtering options. If there's no dedicated filter field, use list search or manage sources separately; don't import desktop settings files into Android.

Routing Rules in Practice

Decide which rule should match first

In v2rayN's routing settings, make sure you're editing the profile that's currently active. Start with three testable goals: send a specific exception through the intended outbound, keep local network addresses reachable, and send everything else through the default outbound. The core checks rules in order; the first match determines the outbound. If a broad rule comes first, later, more specific rules may never apply. Saving a rule doesn't switch the active profile. After applying the changes, check the logs or runtime configuration to confirm the new order is in effect.

For domains, full: matches an exact domain; domain: matches a domain and its subdomains; geosite: references a domain dataset. Address rules can use a specific CIDR range or geoip: to reference an IP dataset. Explicit ranges are useful when you need to understand each boundary; datasets are useful for general ranges maintained with updated data. Domain and address datasets aren't interchangeable: different domains for the same site may resolve to different IP ranges, and one shared IP address may serve several sites.

Keep domain, IP and fallback rules separate

This is the routing section from an Xray configuration, not a complete client config file. Add the rules individually in the GUI, or replace the corresponding fields in your custom configuration. Before using it, confirm the actual config has outbounds tagged direct and proxy. If the interface offers other filters, such as protocol or port, leave them unset unless you need them. Multiple conditions in one field must all match; to match either a domain or an address, create two separate rules.

{
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "type": "field",
        "domain": ["full:example.com"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "ip": ["192.168.0.0/16"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "network": "tcp,udp",
        "outboundTag": "proxy"
      }
    ]
  }
}

The final rule explicitly matches common transport traffic. If a request already carries a domain, this broad rule may match before IPIfNonMatch performs its supplemental lookup. The private-network rule in this example is for requests whose destination is already a private IP. To send internal sites that are specified only by domain directly, list those domains explicitly in an earlier direct rule. Alternatively, adjust the domain strategy and default outbound to allow unmatched domains to be checked by IP. Don't change the strategy and several rules at once, or it will be hard to tell what changed the result.

AsIs doesn't resolve domains to IP addresses specifically for routing decisions, so it suits setups that route mainly by name; it doesn't mean no resolution happens during a connection. IPIfNonMatch considers resolving a domain only if it doesn't match a domain rule; IPOnDemand may resolve it when address-based matching requires an IP. The right strategy depends on what information a request carries and on rule order. If an app resolves a name locally and passes the resulting IP to the proxy, the core may not know the original domain. Whether the domain can be recovered from traffic also depends on inbound sniffing and the protocol in use.

Test rule boundaries with matching and non-matching cases

Add or change one rule at a time, then test one request that should match and one that shouldn't. For LAN testing, use an internal service you can actually reach; a public example domain isn't a LAN test. If logs show connections but not rule names, check the outbound tag and the result from a destination you control. Note the test time, close apps that may retry continuously, then make a fresh request. Existing long-lived connections and browser caches can delay visible changes; refreshing a page doesn't necessarily create a new connection.

If the rule looks right but traffic uses the wrong outbound, check in order whether the request passes through the client, whether the target is a domain or an IP, which rule matches first, and whether its tag points to the intended outbound. When changing geodata files, verify the data change separately from rule edits. Don't use speed test results as proof of routing behavior. How latency tests work explains what different tests measure; use them to investigate after confirming the outbound.

DNS Configuration

First identify which resolver is handling the query

When troubleshooting DNS, distinguish the system resolver, an app's own resolver and the core's built-in resolver. An app may query the system and pass the resolved IP to the local client, or pass the domain directly to a proxy for resolution. A browser using its own encrypted DNS may get a different result from a system command. Pinpoint which path is failing before changing system settings, app settings or DNS in the v2rayN profile.

If the desktop client offers remote DNS and direct DNS fields, first confirm how they work with the current core and mode, then enter server addresses. Direct DNS is generally for local reachability and local names; remote DNS is often used to reach an upstream over a specified path. Field names describe their intended use, but don't guarantee which outbound carries the DNS requests. With a custom configuration, check DNS traffic routing, upstream reachability and whether the client rebuilds the active settings from a template.

Set a clear scope for upstream queries

This Xray snippet shows how to direct internal names to a resolver based on their domain suffix. 192.168.1.53 is an example private IP; replace it with the resolver responsible for your internal zone. If you don't have one, don't add this server entry. The public upstream uses an HTTPS URL. This snippet configures core DNS only; it doesn't take over system queries or automatically determine which outbound carries regular traffic. In the GUI, use equivalent fields supported by your current build. Don't paste the entire object into a field that accepts only a server address.

{
  "dns": {
    "servers": [
      {
        "address": "192.168.1.53",
        "domains": ["domain:corp.example"],
        "skipFallback": true
      },
      "https://1.1.1.1/dns-query"
    ],
    "disableFallbackIfMatch": true
  }
}

skipFallback keeps this internal resolver out of ordinary fallback; disableFallbackIfMatch prevents unmatched upstreams from being used as a fallback once a domain match exists. The trade-off is that names handled by this resolver may fail outright if it becomes unavailable. Restore access to the internal network or use a backup server responsible for the same zone—don't send those names to a public resolver and hope it knows the answer. Confirm that your core supports these fields; don't copy an Xray DNS object unchanged into another core's configuration.

An HTTPS query still needs a connection. If the server address is a hostname, determine how that name is resolved before connecting to the server. If it depends on the same unresolved path, you can create a loop. If all pages start timing out after changing upstreams, check the system clock, certificate errors, whether the current outbound can reach the upstream and how the proxy server's own hostname is resolved. Don't disable certificate verification just to make one request work, and don't reuse a private DNS address from your home network on a mobile network.

Use the response to narrow down the problem

Check these cases separately: no result, an unexpected IP, and an IP returned but the connection still fails. nslookup example.com shows which resolver that command uses and its response; it can't prove that a browser or proxy core uses the same upstream. To test a resolver you are authorized to use, specify its address explicitly and compare the result with app logs. For timeouts, check reachability first. If the response says the name doesn't exist, check the query name and zone. If an IP is returned but the page won't load, investigate the app's connection stage next.

Test public domains separately from names that require internal DNS, and check whether IPv4 and IPv6 support differs across networks. A name returning both address types doesn't mean both paths work. If you suspect one address family is causing slow connections, record resolution and connection results separately, then temporarily disable one side for comparison. Don't disable an entire address family globally before confirming the cause. After a change, test with a new connection. Let old cache entries expire or clear them using the app's supported method; there's no need to reset the whole system network for every test.

TUN Mode: Traffic Capture and Routing Loops

When to switch from a system proxy to TUN

A system proxy relies on apps honoring the proxy settings provided by the OS. If an app works with the system proxy, you don't need to switch to TUN just to cover more traffic. First confirm that the server, core and routing profile work with the system proxy. Consider a virtual network adapter if the target app ignores system proxy settings or you need to handle its UDP traffic. TUN passes selected IP traffic to the proxy stack; actual access also depends on system routes, the capture component, remote protocol support and the rules in use.

Don't treat v2rayN's node core and the TUN capture component as the same setting. Seeing a particular core listed for the active server doesn't prove it created the virtual adapter, or mean its regular inbound settings apply to the capture layer. Check the client's available TUN settings and startup logs, then confirm that the OS allows virtual interfaces and route changes. If you see a permissions error, grant access as documented for your OS and client. On devices where policy blocks virtual adapters, use an allowed connection method instead of trying to bypass device restrictions.

Keep the traffic capture path easy to restore

On a machine you can recover locally, note the system proxy setting, active network adapter, default route and any LAN access you need to preserve. For testing, disable unrelated traffic capture tools and follow the client instructions on whether to turn off the system proxy. If you disable it for comparison, test the same destination that worked before; don't change the server and DNS at the same time as the mode. Avoid changing the default route over a remote session to another machine unless you have local control or a reliable rollback plan.

PlatformRead-only checkWhat to compare
Windowsroute printChanges to interfaces and destination routes
macOSnetstat -rnVirtual interface and default route
Linuxip route show table all、ip rule showRouting table and selection rules

After enabling TUN, check the startup log and compare the state before and after with the commands above. Not every implementation replaces the default route; some add more specific routes or use other routing tables and selection policies. Seeing a virtual interface confirms only that it was created, not that app traffic reached it. Test an ordinary webpage, an app that didn't use the system proxy before, and a LAN service you need to keep available. If webpages work but a specific UDP app fails, that doesn't mean TUN isn't running at all.

Troubleshoot routing loops, lost LAN access and Android differences

If every connection times out after enabling TUN, first check whether the connection to the proxy server itself is being sent back through the virtual interface. Traffic to the active server needs to leave through a working physical network path. If the OS sends it into the capture stack, the stack may try to make a request over a connection that hasn't been established. Use the client-supported interface binding or route-exclusion options; don't exclude every public IP. Test again after switching Wi-Fi, since the outbound interface, gateway and server resolution may all change.

If only LAN access is affected, check whether the destination's private IP range is being captured. Selecting direct as the client's outbound doesn't mean the OS has excluded that destination; the system route still determines the interface. LAN discovery may also use multicast, so reaching a service by a fixed IP doesn't prove automatic discovery works. Check DNS separately for internal names. If the issue is hard to reproduce, test the same address with TUN off and on, then add the narrowest possible exception.

On Android, v2rayNG and v2flyNG usually request traffic capture through the system VPN service, so their permission prompts and per-app filters differ from desktop clients. Check whether the build offers an app list and whether selected apps are included or excluded. An app exclusion controls whether traffic enters the capture layer; domain-based outbound rules determine how captured traffic is handled. If another VPN service is already running, check which service Android has made active. Don't import desktop interface names, routing tables or driver settings.

FakeDNS: Mapping, Recovery and Use Cases

Understand the two stages in the same traffic path

FakeDNS returns an address allocated by the core, not the target server's public IP. The app then connects to that address; the capture layer retrieves the mapping, restores the original domain and applies the relevant routing rules. Two steps must work: the query must reach the resolver that allocates the address, and the connection must return to the component that can restore the mapping. If either step falls outside the capture path, you may see an address resolve successfully but the connection fail.

FakeDNS is useful when an app passes resolved IPs to the forwarding layer but your policy needs to route by domain. If the app already sends domains through a local proxy, ordinary domain rules should work; leave things as they are unless there's a reason to change them. FakeDNS doesn't make every DNS answer more accurate or fix an unreachable remote server. Before enabling it, confirm that the problem is actually the domain being lost during forwarding—not invalid server credentials, the wrong destination port or an ordinary routing rule error.

Check which configuration the capture layer uses

If the client offers a FakeDNS toggle, prefer the setting for the active capture mode. After enabling it, check the generated config and logs to see which mechanism is in use. The following is a snippet from a custom Xray configuration: top-level fakedns defines the address pool, and the object in dns.servers makes the example domain use FakeDNS. Keep other required fields in the actual config, and choose a range that won't conflict with existing interfaces, internal networks or other virtual networks. This example shows how to limit the scope; it isn't a default template for enabling FakeDNS globally.

{
  "fakedns": [
    {
      "ipPool": "198.18.0.0/15",
      "poolSize": 65535
    }
  ],
  "dns": {
    "servers": [
      {
        "address": "fakedns",
        "domains": ["domain:example.com"],
        "skipFallback": true
      },
      "https://1.1.1.1/dns-query"
    ]
  }
}

Merge the following sniffing fields into the Xray inbound that actually receives connections and restores the domain. This isn't a new inbound and doesn't replace TUN adapter or route settings. If the inbound already has sniffing overrides, merge the list to suit your needs; don't remove settings used for other purposes. If another component terminates TUN and handles the mapping, verify the full path in that component's settings. The node core name shown in the client doesn't prove this field will take effect.

{
  "sniffing": {
    "enabled": true,
    "destOverride": ["fakedns"]
  }
}

Verify the mapping end to end with two test domains

Enable mapping for one name you can test, and keep another name using ordinary DNS as a control. Check that the first returns an address from the pool. Then make a new connection from the same app and check that traffic reaches the expected inbound, the logs show the restored domain, and the expected outbound is selected. Verify that the control domain still resolves through its original path. A command-line tool may use a separate system resolver and show a real IP; that only means it took another query path, not that the app bypassed FakeDNS.

If logs show only pool addresses, first check that the connection reaches the inbound responsible for restoring domains. Then check whether resolution and connection are handled by different core instances. The address pool must not overlap with a corporate test network, another virtual interface or an old rule. An app may have cached a mapped address that no longer has a valid record after the core restarts. Close the app and create a fresh query and connection before deciding whether to change the pool. Narrowing the scope often makes problems easier to locate than enlarging the pool.

Test internal services, names that rely on the system resolver, and apps that need to pass real IPs to other processes separately; use ordinary DNS where needed. A connection to a fixed IP doesn't make a new domain query, and FakeDNS can't infer a name from that address. To turn it off, remove the mapping configuration first, then clear the relevant DNS cache using the app or system's supported method and reconnect. Changing the route to direct won't turn a mapped address back into a real one; existing connections may keep retrying along the wrong path.

Managing Multiple Subscriptions and Troubleshooting Update Failures

Keep sources, refresh methods and active servers separate

Create a subscription group for each source, and include its purpose and maintenance owner in the local name. Before updating, note the active server and its source group so an update doesn't leave you with only a similarly named server to select. Put manually imported single-server configs in a separate group; don't rely on a subscription refresh to recreate them. Don't mix two URLs from the same source if they use different default settings, or it will be hard to tell which response caused an entry to change. Update one group at a time and move on only after verifying it.

Treat subscription URLs like access credentials. When documenting an issue, keep the group name, time, update method and a redacted error message; remove the URL path, query parameters and anything that could identify an account. Never share a full URL in public documentation, screenshots or online conversion tools. When moving to another device, use the client's supported backup method and distinguish interface settings and routing data from subscription content that contains access credentials. If you're sharing troubleshooting details, don't send the entire backup.

Check the request result before investigating parsing

In v2rayN's subscription menu, check whether your build offers separate update methods for using or bypassing the proxy. To update through the proxy, you need at least one working connection. If that connection's old config has expired and you can only use it to refresh a new server list, you're stuck in an update dependency. Follow the provider's instructions and use an available, authorized network path to update the target group. If you have another valid connection, test it first, then use it to refresh the group. Don't clear all saved entries just because one group failed.

A network timeout, a rejected response and content that can't be parsed are different failures. For timeouts, check the current network, DNS and update method first. If the log reports a rejected request or an invalid URL, check the subscription status and client type. If the content can't be parsed, check whether the response was replaced by a login page or message, or whether the provider supplied a format the client doesn't support. Opening a page in a browser doesn't mean the client received importable content. You don't need to copy the full response; use the log to identify whether the failure happened during download or import.

If the interface says the update succeeded but the entries seem unchanged, first confirm you're viewing the target group rather than all entries. Then rule out the search box, filters and duplicate remarks. Compare a known new or renamed entry instead of guessing from the first item in a sorted list. If an old entry disappeared, check whether the provider changed its content before manually restoring anything. Don't assume manually edited settings in a copy will survive every refresh; keep important special settings in a clearly separate config you manage yourself.

Refresh one group at a time and keep a working baseline

When setting up multiple subscriptions for the first time, update each group manually and compare the results. Verify that each group can be fetched, parsed, selected and connected before enabling any automatic update option the client offers. Automatic update triggers vary by build and may depend on whether the app is running, power settings or network status. A successful desktop test doesn't prove Android will update in the background at the same time. To isolate an update, pause other scheduled changes, run one manual refresh and observe the result.

Break verification into three steps: open the target group and confirm the entry is there, select a server you just verified, then make a fresh connection to the same destination. A speed test reflects one test path; it doesn't prove the app works or guarantee the server supports the transport in use. If v2rayNG imports a subscription but v2flyNG can't make the same connection, check the actual protocol and transport settings instead of repeatedly deleting the subscription. Comparing the cores in two Android clients can help determine whether the issue is a subscription format difference or a core capability.

If several groups fail at the same time, look for a shared cause, such as a network change, a shared update route or a change to the upstream DNS. If only one group fails, keep the others as controls and check that URL, its filters and the response format. Once it works again, record the successful update method and a verified server so you can tell whether the next issue is the same kind. If you haven't imported a subscription yet, start with the subscription import steps in the guide to establish a baseline, then use this chapter to troubleshoot updates.

Custom Outbounds and Configuration Verification

Use them when you need distinct outbound roles

An outbound defines how the core handles a connection it has received. The simplest setup is to let the GUI client generate a proxy outbound, then add direct or blocking rules as needed. Custom outbounds are useful when you need clearly separated roles—for example, to separate work and test environments, or send a set of requests to a managed forwarding service already running on your machine. If you only need to switch servers temporarily, select another server in the main list instead of maintaining a separate JSON file.

First check whether your v2rayN build supports importing a complete custom config or editing selected fields in a generated template. A complete config must define valid inbounds, outbounds and any required routing; the client may not fill in every field for you. With a template, check whether some settings will be overwritten when changes are applied. Copy a working config as a baseline, then add one outbound with a clear tag. Don't edit a temporary runtime file generated by the client; it may be recreated the next time you start the app or switch servers.

Give every outbound a stable, unique tag

This is a minimal Xray config you can test locally. It listens for SOCKS on the loopback address and serves only local test processes; it doesn't enable the system proxy or a virtual adapter. direct sends connections through freedom, while block drops requests through blackhole. The last rule explicitly sends traffic from the test inbound through direct; the rule blocking an exact domain comes first. If the listening port is already in use, choose a free one and update the test commands to match.

{
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 10880,
      "protocol": "socks",
      "tag": "local-test",
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    }
  ],
  "outbounds": [
    {"tag": "direct", "protocol": "freedom"},
    {"tag": "block", "protocol": "blackhole"}
  ],
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "inboundTag": ["local-test"],
        "domain": ["full:example.org"],
        "outboundTag": "block"
      },
      {
        "type": "field",
        "inboundTag": ["local-test"],
        "outboundTag": "direct"
      }
    ]
  }
}

Before testing, make sure the client is using an Xray core that can read this file. If another proxy is already running locally, avoid a port conflict and don't bind the listener to every network interface. Once the config loads, run the two requests below from a command line with curl. socks5h passes the domain to the SOCKS server, so you can test domain matching. With local DNS resolution instead, the inbound may receive only an IP, which can't prove the block rule is broken.

curl --proxy socks5h://127.0.0.1:10880 --noproxy "" --max-time 10 -I https://example.com/
curl --proxy socks5h://127.0.0.1:10880 --noproxy "" --max-time 10 -I https://example.org/

If the test domain is reachable, the first request should get a response and the second should fail at the request stage. If both fail, distinguish a connection refusal from a forwarding failure. For a refusal, check the inbound listener, port availability and process status. For a forwarding failure, check the outbound tag, target name and whether direct access works locally. If both succeed, confirm that the requests actually reached the test port and check which config the running process loaded. A successful process startup doesn't prove that routing references and traffic paths are correct.

Move from a minimal config to a daily setup

Treat each new outbound for a real service as a separate change. Give it a role-specific tag and don't reuse an existing one; routing rules must reference the tag exactly. Get the server address, protocol, transport and identity settings from a service you are authorized to use. Renaming the example direct outbound doesn't turn it into a proxy. If you add chained forwarding, test each stage separately: confirm how the lower-level connection is sent before adding the upper-level dependency, so an outbound doesn't end up handing requests back to itself.

Before switching cores, read Xray and V2Fly feature comparison and check protocol and field support, not just the node name shown in the interface. The same client can host different configs, and Android shouldn't reuse a complete desktop inbound config. When maintenance is done, close the temporary inbound, return to the original profile and test everyday apps, LAN services and subscription updates. Keep a note describing the config's purpose, along with positive and negative test cases that demonstrate the rules work, so you can repeat the same checks after changing one setting later.