Skip to content

v2ray如何让出站流量走tun设备 #1062

Answered by jphilll
cncherisher asked this question in Q&A
Discussion options

You must be logged in to vote

我找到一个可用方案。

  • 先在 VPS 上运行以下命令:
ip rule add from x.x.x.x table 128      # x.x.x.x  是 VPS 的公网 IP 地址
ip route add table 128 to y.y.y.y/y dev ethX      # y.y.y.y/y 是 VPS 的公网 IP 地址的子网, ethX 是 VPS 的公网网卡名
ip route add table 128 default via z.z.z.z      # z.z.z.z 是 VPS 的默认网关地址
  • OpenVPN 部分配置 .ovpn(不要设置 route-nopull ):
client
dev tun
proto tcp
remote ***.***
#route-nopull # 注释掉 route-nopull
  • V2Ray Server 部分配置config.json
"outbounds": [
    {
        "sendThrough": "0.0.0.0",      # 直接从 `0.0.0.0` 网卡出站
        "protocol":"freedom",
        "settings":{
            "domainStrategy":"UseIP"
        },
        "tag":"direct"
    }
]

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jphilll
Comment options

Answer selected by cncherisher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants