Practical V2Ray Routing Strategies: A Guide to Fine-Grained Traffic Splitting by Domain and IP

5/9/2026 · 3 min

1. Overview of V2Ray Routing Strategies

V2Ray's routing functionality is one of its most powerful features, allowing users to direct data packets to different outbounds (e.g., direct connection, proxy, or specific nodes) based on traffic characteristics such as target domain, IP address, port, or protocol. With proper routing configuration, you can achieve the classic split-tunneling pattern: "direct for domestic traffic, proxy for foreign traffic." This reduces unnecessary proxy overhead while ensuring access speed and privacy.

2. Domain-Based Traffic Splitting

Domain-based splitting is the most common strategy, suitable for distinguishing traffic by website domain. V2Ray supports multiple domain matching methods:

  • Exact domain match: Use domain:example.com to match a specific domain exactly.
  • Subdomain match: Use domain:google.com to match google.com and all its subdomains.
  • Keyword match: Use keyword:google to match any domain containing "google".
  • Regex match: Use regex:.*\.googlevideo\.com to match domains matching a regular expression.

Configuration Example

"routing": {
  "rules": [
    {
      "type": "field",
      "domain": [
        "domain:google.com",
        "domain:youtube.com",
        "keyword:facebook"
      ],
      "outboundTag": "proxy"
    },
    {
      "type": "field",
      "domain": [
        "domain:baidu.com",
        "domain:qq.com"
      ],
      "outboundTag": "direct"
    }
  ]
}

3. IP-Based Traffic Splitting

IP-based splitting is useful when domain-based matching is not feasible, such as when applications communicate using fixed IPs or when you need to bypass specific IP ranges. V2Ray supports CIDR notation and individual IP matching.

Configuration Example

"routing": {
  "rules": [
    {
      "type": "field",
      "ip": [
        "geoip:cn",
        "10.0.0.0/8",
        "192.168.0.0/16"
      ],
      "outboundTag": "direct"
    },
    {
      "type": "field",
      "ip": [
        "geoip:us",
        "8.8.8.8"
      ],
      "outboundTag": "proxy"
    }
  ]
}

geoip:cn is a built-in IP database that includes all Chinese IP ranges, greatly simplifying domestic IP identification.

4. Combined Strategies and Best Practices

In production, it is recommended to combine domain and IP rules, and pay attention to rule order: V2Ray matches rules from top to bottom and stops at the first match. Therefore, place more specific rules first.

Recommended Strategy

  1. Direct for domestic domains: Use domain rules to match common domestic websites.
  2. Direct for domestic IPs: Use geoip:cn to match all domestic IPs.
  3. Proxy for foreign domains: Use domain rules to match foreign websites that need proxying.
  4. Proxy for remaining traffic: Set the default outbound to proxy, ensuring unmatched traffic goes through the proxy.

Complete Configuration Example

"routing": {
  "domainStrategy": "IPOnDemand",
  "rules": [
    {
      "type": "field",
      "domain": ["domain:baidu.com", "domain:qq.com"],
      "outboundTag": "direct"
    },
    {
      "type": "field",
      "ip": ["geoip:cn"],
      "outboundTag": "direct"
    },
    {
      "type": "field",
      "domain": ["domain:google.com", "domain:youtube.com"],
      "outboundTag": "proxy"
    },
    {
      "type": "field",
      "network": "tcp,udp",
      "outboundTag": "proxy"
    }
  ]
}

5. Common Issues and Debugging

  • Rules not working: Check rule order; ensure no earlier rule matches the target traffic.
  • DNS pollution: Consider using DNS resolution strategies like domainStrategy: "IPIfNonMatch" or "IPOnDemand".
  • Performance optimization: Avoid excessive regex rules; prefer domain and geoip for efficiency.

With fine-grained routing configuration, V2Ray becomes a powerful tool for network acceleration and secure access.

Related reading

Related articles

V2Ray Configuration in Practice: From Basics to Advanced, Building a Stable and Reliable Proxy Environment
This article provides a hands-on guide to V2Ray configuration from scratch, covering basic installation, core protocol setup, advanced features (like load balancing and dynamic ports), and security hardening, aiming to help users build a stable, efficient, and secure proxy environment.
Read more
The Evolution of V2Ray Protocols: Balancing Performance and Security from VMess to VLESS
This article delves into the evolution of V2Ray's core protocols from VMess to VLESS, analyzing key design decisions in performance optimization, security enhancement, and usability improvements. It reveals how modern proxy protocols seek the optimal balance between efficiency and protection in complex network environments.
Read more
VLESS Practical Deployment Guide: Building High-Performance Encrypted Tunnels in Restricted Network Environments
This article provides a detailed practical deployment guide for the VLESS protocol, focusing on configuring high-performance, low-latency encrypted proxy tunnels in environments with strict network censorship or limited bandwidth. It covers the complete configuration process for both server and client, TLS camouflage optimization strategies, and tuning techniques for specific network restrictions.
Read more
VPN Optimization for Hybrid Work Environments: Practical Techniques to Improve Remote Access Speed and User Experience
As hybrid work models become ubiquitous, the performance and stability of corporate VPNs are critical to remote collaboration efficiency. This article delves into the key factors affecting VPN speed and provides comprehensive optimization strategies, ranging from network protocol selection and server deployment to client configuration, aiming to help IT administrators and remote workers significantly enhance their remote access experience.
Read more
V2Ray vs. Mainstream Proxy Protocols: Analysis of Performance, Security, and Applicable Scenarios
This article provides an in-depth comparison between V2Ray and mainstream proxy protocols like Shadowsocks, Trojan, and WireGuard. It analyzes key dimensions including transmission performance, security mechanisms, censorship resistance, and applicable scenarios, offering professional guidance for users to select the most suitable network acceleration and privacy protection solution based on their specific needs.
Read more
Analyzing the V2Ray Ecosystem Toolchain: A Complete Solution from Configuration Generators to Traffic Monitoring
This article provides an in-depth analysis of the complete V2Ray ecosystem toolchain, covering various tools from configuration generation, client management, traffic monitoring to advanced feature integration, helping users build efficient, secure, and manageable proxy solutions.
Read more

FAQ

In V2Ray routing rules, which has higher priority: domain matching or IP matching?
V2Ray matches rules in the order they appear in the configuration file and stops at the first match. Therefore, priority is determined by rule order, not the matching type. It is recommended to place more specific rules (e.g., specific domains) first, and general rules (e.g., geoip) later.
How can I debug whether V2Ray routing rules are working?
You can enable V2Ray's logging by setting `loglevel: "debug"` and observe the matching results for each traffic flow in the logs. Additionally, use the `v2ray test` command to check the configuration file syntax.
Why does traffic to domestic websites still go through the proxy even though I set domestic IPs to direct?
Possible reasons include: 1) DNS resolution returns foreign IPs; 2) Incorrect rule order where proxy rules match before direct rules; 3) Using `domainStrategy: "AsIs"` which skips IP resolution. It is recommended to use `domainStrategy: "IPIfNonMatch"` or `"IPOnDemand"`.
Read more