For readers adjusting routing in v2rayN or editing V2Ray routing JSON directly. Start by testing an outbound with a single hostname, then expand to domain suffixes, IP ranges, and resource groups. If a rule looks right but does not take effect, check the actual inbound destination, rule order, and DNS strategy one by one.
Domain rules: the domain field vs. the domain: prefix
domain is an array field in a routing rule; domain: is one type of matching prefix for array entries. Add hostnames or match expressions to the array, not URLs. For example, in https://docs.example.com/help, the domain condition checks docs.example.com; the scheme and /help path are ignored.
full: Exact hostname
Recommendedfull:example.com matches only example.com, not www.example.com. When testing a new rule, start with this narrow match to limit its scope. Once it works, broaden the match if needed.
Best for: One-off site exceptions and initial rule testing
domain: Domain and subdomains
domain:example.com matches both the root domain and its subdomains, such as www.example.com, but not notexample.com. It matches on domain-label boundaries, not arbitrary substrings.
Best for: Routing an entire site and its subdomains through the same outbound
regexp: Regular expressions
regexp:^cdn[0-9]+[.]example[.]com$ matches cdn2.example.com, but not cdn.example.com or cdn2.example.com.test. The anchors at the beginning and end limit the match, and [.] represents a literal period.
Best for: Hostnames with fixed numbering that cannot be accurately matched with a single domain suffix
In raw routing JSON, example.com by itself uses substring matching, which may also include notexample.com. For exact or subdomain matches, specify the prefix. If you use a backslash to escape a period in a regular expression, you must escape it again in the JSON string. The [.] syntax above avoids that extra step.
IP addresses and resource groups: CIDR, geosite, and geoip
The ip array accepts IP addresses, CIDR ranges, and geoip: groups. Put geosite: groups in the domain array instead. They use different resource data: geosite:cn checks whether the hostname matches a domain entry, while geoip:cn checks whether the destination address falls within an IP group. A domain and its server address can match different groups, so one condition cannot replace the other.
Use a single-address rule for a single IP
To add an exception for just 192.0.2.8, use 192.0.2.8/32, not 192.0.2.0/24; the latter includes other addresses in the same range. These addresses illustrate match scope and are not accessible test services.
geoip:private matches private address ranges in the data file being used. The exact ranges depend on the resource version loaded by the core; this group is not generated by scanning your local network interfaces. To route just one of your own subnets, specify that subnet directly for a more precise match.
- To route a business domain through a specific outbound, start with
full:ordomain:rather than pinning it to an address from a single DNS response. An IP address may be shared by other services, and DNS results can change. - If the core logs that a resource file or group is missing, check which
geosite.datandgeoip.datfiles the current core actually uses, along with the group name. A rule being saved in the client does not mean the core can load it.
Rule priority: the first matching rule wins
The core checks rules in the order they appear in the routing.rules array. It does not automatically move full: rules ahead of domain: rules or reorder CIDR ranges by prefix length. Multiple values in a rule's domain array are OR conditions; if you also add port, both the domain and port conditions must match. To route traffic when either a domain or an IP range matches, use two separate rules rather than putting domain and ip in the same rule object.
This is a routing snippet to merge into an existing configuration, not a standalone config. direct and proxy must match the tag values of existing outbounds; tags do not create outbounds or determine their protocols.
{
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"domain": ["full:example.com"],
"outboundTag": "direct"
},
{
"type": "field",
"domain": ["domain:example.com"],
"outboundTag": "proxy"
},
{
"type": "field",
"ip": ["192.0.2.0/24"],
"outboundTag": "direct"
}
]
}
}
- For a request that reaches the core as the domain
example.com, both domain rules match. The first one wins, so the request usesdirect. Swap the rules and the exact-match rule will no longer handle this domain. - A request that reaches the core as
www.example.comdoes not match the first rule, but it matches the second and usesproxy. The third rule is not checked. - A request that reaches the core as the IP
192.0.2.8can match the third rule. If the destination is a domain and the strategy isAsIs, the routing stage will not resolve the domain specifically for this rule.
domainStrategy: When to resolve domains for IP matching
routing.domainStrategy controls when routing looks up a destination address; it is not the DNS setting for outbound connections. It also does not reverse-resolve a bare IP to find its domain. If an app resolves a domain to an IP before traffic reaches the proxy, whether a domain rule can match also depends on whether the inbound uses sniffing to obtain a domain for routing.
| Strategy | How domain requests are matched | Use case |
|---|---|---|
AsIs | Does not resolve domains for IP matching during routing; destinations that are already IP addresses can still match IP rules. | Primarily route by domain, or use IP-range rules only for IP addresses already known at the inbound. |
IPIfNonMatch | If no rule matches in the first pass, resolve the domain and check the rules again using the resolved address. | Prefer domain rules, then try routing unmatched requests by destination address. |
IPOnDemand | Can resolve a domain request when an IP condition needs to be evaluated during matching. | Intentionally prioritize an earlier IP-range rule over later domain rules. |
With IPIfNonMatch, check especially for a catch-all rule covering all TCP and UDP traffic at the end. If that rule matches in the first pass, resolution and the second matching pass will not run. To prioritize domains, use IP matching as a fallback, and then rely on the default outbound, remove catch-all rules like this and verify that the default outbound is the one you want.
v2rayN routing settings and local testing
This example uses the v2rayN 6.60 series interface on Windows. First check which routing profile is active, then change one rule. Avoid changing the node, system proxy, and DNS at the same time; when multiple settings change together, it is hard to tell what caused an outbound change in the logs.
Check the routing profile
From the main window, open Settings → Routing Settings and check which profile is in use. Note the current rule order and domain strategy. If the client has multiple routing profiles, saving changes to an inactive profile will not affect current traffic.
Add an exact-match exception
In the active profile, place
full:example.combefore thedomain:example.comrule that would otherwise match it, and assign a different outbound to each rule. Save and apply the changes, then check the main window log to confirm the core reloaded without configuration errors.Test with the domain intact
First check the local SOCKS inbound port. If it is
10808, use the commands below to send two requests; replace the port number if you have changed it.--socks5-hostnamepasses the destination hostname to the proxy, preventing the test program from resolving it first and sending only the IP address.Check the outbound used
Find both destinations in the core access log by test time and compare their outbound tags. A page loading successfully only shows that the request worked; it does not prove that the expected rule matched. If no outbound is logged, check the log settings first, then send one request at a time.
curl.exe --socks5-hostname 127.0.0.1:10808 -I https://example.com/
curl.exe --socks5-hostname 127.0.0.1:10808 -I https://www.example.com/
These commands reproduce rule matches; they are not for speed testing. If the outbound tag is correct but the request fails, investigate that outbound's connection or DNS resolution rather than routing. If the tag is wrong, check the order of the rules actually in effect.
Common routing issues
Why does traffic still use the proxy when full: is configured correctly?
First check whether the destination in the log matches the hostname in the exact-match rule. After visiting a root domain, the browser may follow a redirect or request a page resource from a different subdomain; check each connection separately. If the destination is the same, look for an earlier, broader rule that may have matched first.
Why doesn't geoip:private send a local network hostname directly?
First check whether the proxy receives an IP address or a hostname. An address can be compared directly against IP rules. For a hostname, check whether the routing strategy allows resolution and whether the core can resolve it to the expected local network address using the current DNS settings. You can also add an explicit domain rule to send a known local hostname directly.
Why did the outbound change after a subscription update when the old rule is still there?
Check the active routing profile, selected node, and outbound tags actually loaded by the core. Even if the outbound tag in the rule has not changed, the node assigned to that tag may have changed. The log can show the same rule matching while traffic goes through a different node.
The same site uses different outbounds in a browser and the command line. What should I check first?
Start with the SOCKS command above to keep the inbound and destination consistent, then check whether the browser uses the same local port. If browser traffic goes through the system proxy or TUN, check whether the corresponding inbound receives a hostname or an IP address. For requests missing from the core log, investigate the proxy entry point before changing routing rules.