電訊茶室's Archiver

角色 發表於 2019-2-23 20:10

V2Ray使用教程——基础概念2

[i=s] 本帖最後由 角色 於 2019-2-24 13:19 編輯 [/i]

在《[url=http://www.telecom-cafe.com/forum/viewthread.php?tid=7370&extra=page%3D1]V2Ray使用教程——基础概念1[/url]》,所有traffic都通过VN1的outbound送到remote VN2的inbounds,对于内地的网站都一样,这不够人性化。

这幅帖子讲述在VN1加上一个routing的object,那么就可以依据hostname and IP address去分流,网络概念图如下:

[attach]4297[/attach]

角色 發表於 2019-2-23 20:14

[i=s] 本帖最後由 角色 於 2019-2-23 23:23 編輯 [/i]

现在我们有两个outbounds,第一个是proxy outbound,第二时是direct outbound。[code]
   "outbounds": [
     {
       "protocol": "vmess",
       "settings": {
         "vnext": [
           {
             "address": "VN2 IP address or hostname",
             "port": 10086,
             "users": [
               {"id": "UUID" }
             ]
           }
         ]
       }
     },
     {
       "protocol": "freedom",
       "tag": "direct",
       "settings": {}
     }
   ]
[/code]

角色 發表於 2019-2-23 23:17

那么我们routing有什么要求?

1. Same LAN address (private address) should go to the "direct" path.
2. Mainland China website hostname should go to the "direct" path.
3. Mainland China IP address should go to the "direct" path.
4. Otherwise go to the proxy path. (By default, it will go to the first outbound if the tag is not specified)

the "routing" object contains:[code]
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "direct"
      },
      {
       "type": "field",
        "domain": [ "geosite:cn"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "ip": ["geoip:cn"],
        "outboundTag": "direct"
      }
    ]
  }
[/code].

角色 發表於 2019-2-23 23:27

整个VN1的configuration file,config.json contains[code]
{
  "inbounds": [
    {
      "port": 1081,  
      "protocol": "socks"
    }
  ],
  "outbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "VN2 IP address or hostname",
            "port": 10086,
            "users": [
              {"id": "UUID" }
            ]
          }
        ]
      }
    },
    {
      "protocol": "freedom",
      "tag": "direct",
      "settings": {}
    }
  ],
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "direct"
      },
      {
       "type": "field",
        "domain": [ "geosite:cn"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "ip": ["geoip:cn"],
        "outboundTag": "direct"
      }
    ]
  }  
}
[/code]

角色 發表於 2019-2-24 00:02

测试结果:

With additional outbound "direct" and routing object, the performance tests are as follows:

1. private LAN NAS can be reachable.
2. Youtube, Facebook can be reachable
3. CCTV5 and 爱奇艺 can be watched smoothly

Both CCTV5/爱奇艺 and YouTube/Facebook can be watched simultaneously.

角色 發表於 2019-2-25 09:06

再回看Routing,如果每个IP或者domain都分开写,那么我们会重复很多,回看V2Ray官网的结构,我们可以把IP组合起来在[]里,那么就更加简洁,效果也一样。

结合起来的routing是:[code]
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
       "type": "field",
        "domain": [ "geosite:cn"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "ip": [
          "geoip:cn",
          "geoip:private"
        ],
        "outboundTag": "direct"
      }
    ]
  }
[/code].

頁: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.