遇到一个实际使用场景,VPS 分配有 IPv6,V2ray 的 freedom 出站协议会优先走 IPv6,谷歌等网站可能将 IPv6 识别为 machine 并触发 CAPTCHA 。这种情况就希望流量通过 IPv4 出口访问互联网,或是仅有部分 IPv6-ONLY 网站通过 IPv6 出口。此时可以通过 V2ray 的路由策略实现分流。
多Inbounds 对 多Outbounds
以下 V2ray 配置可实现 ipv4-in 进站的流量,通过 ipv4-out 出口; ipv6-in 进站流量通过 ipv6-out 出口。
配置 ipv4-out 中的 "sendThrough":"YOUR_LOCAL_IPV4_ADDR" 是实现 IPv4 ONLY 出口的关键配置。
{
"inbounds": [
{
...
"tag": "ipv4-in"
},
{
...
"tag": "ipv6-in"
}
],
"routing":{
"rules":[
{
"type": "field",
"inboundTag": "ipv4-in",
"outboundTag": "ipv4-out"
},
{
"type": "field",
"inboundTag": "ipv6-in",
"outboundTag": "ipv6-out"
}
]
},
"outbounds": [
{
"tag": "ipv6-out",
"protocol": "freedom",
"settings": {}
},
{
"tag": "ipv4-out",
"sendThrough": "YOUR_LOCAL_IPV4_ADDR",
"protocol": "freedom",
"settings": {}
}
]
}
在此配置下,ipv4-in 的入站流量,出站将仅通过 IPv4 地址出站。而 ipv6-in 的入站流量将优先通过 IPv6 地址出站。
IPv6-ONLY 网站分流
以下配置仅有一个 Inbound ,默认出口为 IPv4 地址,某些指定 IPv6-ONLY 域名将通过 IPv6 地址出站。
{
"inbounds": [
{
...
}
],
"routing":{
"rules":[
{
"type": "field",
"domain": [
"bt.byr.cn"
],
"outboundTag": "ipv6-out"
}
]
},
"outbounds": [
{
"tag":"ipv4-out",
"sendThrough": "YOUR_LOCAL_IPV4_ADDR",
"protocol": "freedom",
"settings": {}
},
{
"tag":"ipv6-out",
"protocol": "freedom",
"settings":{}
}
]
}
向Forev3rNAlway5进行回复 取消回复