電訊茶室's Archiver

角色 發表於 2019-2-6 18:37

V2Ray load balancing and smart connect (同时看YouTube 和 CCTV5)

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

如果我们用电脑,怎样根据我去过的地方做分流呢?例如在大陆淘宝、爱奇艺、CCTV5等等网走local,不走proxy。现在的同法就是如果要看,就断开proxy,直接上网(上local网就可以),如果要看YouTube、Facebook、世界新闻那么要用proxy,那么你要转来转去,挺麻烦的。

还有你有好几个国外的vmess或shadowsocks servers,那么怎样聪明地用他们,而不是用死一个,有的时候用某个用得多了,就会死掉一段时间,如果有多个服务器,那么你的traffic就可以分开了走。还有如果servers够多的话,那么你就不会因某个server挂了不能用。如果你有10个朋友,那么把他们的V2Ray servers做成一个组,那么某个不能正常工作就跳到一下一个,这个可以分担全死的情况。

怎样去实现,主要出自与在大陆的local节点,如果你有电脑,或者Raspberry Pi,NAS,那么实现这样的方法是非常简单,大家可以参考下面的方案。因为我用家里的QNAP NAS Container Station,没有listen address,你把它加上就可以。你家里的电脑的broswer开socks5 proxy,然后指向局域网内V2Ray node 的IP和port number就可以。

用起来非常方便,还有不用改settings,就可以自由看YouTube和CCTV5、爱奇艺网都没有问题,非常方便。[code]
{
  "inbounds": [
    {
      "port": 1081,  
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http","tls"]
      },
      "settings": {
        "udp,tcp": true
      }
    },
  ],
  "outbounds": [
    {
      "tag": "us1",
      "protocol": "vmess",
      .
      .
      .
    },
    {
      "tag": "us2",
      "protocol": "vmess",
      .
      .
      .
    },
    {
      "tag": "hk1",
      "protocol": "shadowsocks",
      .
      .
      .
    },
    {
      "protocol": "freedom",
      "tag": "direct",
      "settings": {}
    }
  ],
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "balancers": [
      {
        "tag": "loadbalance",
        "selector": [
          "us1",
          "us2",
          "hk1"
        ]
      }
    ],
    "rules": [
      {
        "type": "field",
        "outboundTag": "direct",
        "domain": [
          "geosite:cn"
        ]
      },
      {
        "type": "field",
        "ip": ["geoip:private"],
        "ip": ["geoip:cn"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "network": "tcp,udp",
        "balancerTag": "loadbalance"
      }
    ]
  }
}
[/code]

角色 發表於 2019-2-6 19:45

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

在用同一台电脑,可以同时播放YouTube和CCTV5

[attach]4288[/attach]

vpn-learner 發表於 2019-2-6 22:16

可否解释下outbounds 内的内容?

角色 發表於 2019-2-6 22:37

在一楼的我的local config.json, 现在我把我现在用的config,删去server,UUID和port number,那么你可以有一个完整的config。要注意这是一个local configure,就是你在大陆的local V2Ray node,你美国安装的remote V2Ray node。[code]
{
  "inbounds": [
    {
      "port": 1081,  
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http","tls"]
      },
      "listen": "10.0.3.2",
      "settings": {
        "udp,tcp": true
      }
    }
  ],
  "outbounds": [
    {
      "tag": "us1”,
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": “Server-us1-IP or hostname",
            "port": 12301,
            "users": [
              {"id": “UUID-us1“ }
            ]
          }
        ]
      }
    },
    {
      "tag": "us2",
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": “Server-us2-IP or hostname",
            "port": 12302,
            "users": [
              {"id": “UUID-us2" }
            ]
          }
        ]
      }
    },
    {
      "tag": "hk1",
      "protocol": "shadowsocks",
      "settings": {
        "servers": [
          {
            "address": “Server-hk1 or hostname",
            "port": 12303,
            "method": "chacha20-poly1305",
            "password": “password-hk1",
            "ota": false,
            "level": 0
          }
        ]
      }
    },
    {
      "protocol": "freedom",
      "tag": "direct",
      "settings": {}
    }
  ],
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "balancers": [
      {
        "tag": "loadbalance",
        "selector": [
          "us1",
          "us2",
          "hk1"
        ]
      }
    ],
    "rules": [
      {
        "type": "field",
        "outboundTag": "direct",
        "domain": [
          "geosite:cn"
        ]
      },
      {
        "type": "field",
        "ip": ["geoip:private"],
        "ip": ["geoip:cn"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "network": "tcp,udp",
        "balancerTag": "loadbalance"
      }
    ]
  }
}
[/code].

角色 發表於 2019-2-6 22:42

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

因为你现在主要接触remote V2Ray node,不太习惯看local V2Ray node。

一般电脑用sock5 proxy(outbound point)---> local V2Ray inbound ---> local V2Ray routing ---> local V2Ray outbound ---> remote V2Ray inbound ---> remote V2Ray routing ---> remote V2Ray outbound (freedom)

一般outbounds里只有两个outputs ,
1) Line 18, tag: us1, vmess protocol
2) Line 65, tag: direct, freedom protocol

现在多了两个个us2 (line 33)和 hk1 (line 48)。

主要是routing: {} 这一部分。

"routing": {
   "domainStrategy": ...  ,
   "balancers": [ ],
   "rules": []
}

当你的信息inbounds (Line 02)进入,然后转到routing的rules。

Line 82-88,如果input hostname是大陆,走direct outbound (直接走大陆gateway)(Line 63-67)
Line 89-94,如果input IP是大陆,走direct outbound (直接走大陆gateway)(line 63-67)
Line 95-98,其他走loadbalance tag(就是走proxy)(在line71-78里有define loadbalance这个tag)

在白话文里有说详细介绍
[url]https://toutyrater.github.io/routing/balance2.html[/url]

角色 發表於 2019-2-7 20:18

如果没有这个方法,需要搞一大轮的东西,要依据IP去分流,而不是hostname!!!

而现在两边都能自动走,大陆的网站走local直走,其他就走proxy,效果非常好!不用转来转去。

角色 發表於 2019-2-12 18:43

如果你们用Windows 10,需要加入一个http proxy, port number 1080 (可以改别的),那么都有同样的效果,就是在大陆可以在Windows 10同时看YouTube、CCTV5、爱奇艺,不用转来转去。

角色 發表於 2019-2-16 19:50

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

我试过如果把某些rules合起来,只能看到YouTube,某些电影要求在大陆地区播放就不能放。[code]
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "ip": ["geoip:cn"],
        "domain": ["geosite:cn"],
        "outboundTag": "direct"
      },
       ...
    ]
[/code]之前的configure可以同时看YouTube和CCTV5,两个IP的可以放在一起,而domain单独放。从而推算就是所有IPs的可以放在一起,而所有domains都可以放在一起。

角色 發表於 2019-4-27 07:28

如果单用一个servers,分分整天都不太畅顺,现在改用了多servers方案就畅顺很多了。

角色 發表於 2019-5-12 11:08

有了上面的settings,如果某一个server被QoS了,也不知道总体速度会慢,因为会下次(怎样选我也不知道,但是好像每次都轮流换),效果也不错。

jerryjdp 發表於 2019-7-18 09:51

老大,请问路由器仅仅通过v2ray能否实现透明网关,还是一定要配合iptables之类的才可以?

谢谢!

角色 發表於 2019-7-18 18:29

我以前用Raspberry Pi安装V2Ray,在Raspberry Pi里再更改iptables,就可以做到透明代理的。

頁: [1]

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