Xray-core icon indicating copy to clipboard operation
Xray-core copied to clipboard

wireguard出站v6支持问题

Open kdurov opened this issue 2 years ago • 6 comments

文档 outbounds 章节并没有看到 wireguard protocol 相关, 参考 https://xtls.github.io/document/level-2/warp.html 添加了自己搭的 wireguard 节点(解锁用,服务器是纯 v6)。配合路由分流后,Google 测IP不行,然后发现什么都连不上。 测试用warp的话也是只有 v4 通 v6 不通

相关日志只能看到

2022/12/04 13:19:52 [Info] [1925420457] app/dispatcher: taking detour [wg0] for [tcp:www.google.com:443]
2022/12/04 13:19:52 [Info] switching dialer
2022/12/04 13:19:52 [Debug] UAPI: Updating private key
2022/12/04 13:19:52 [Debug] peer([pubkey]) - UAPI: Created
2022/12/04 13:19:52 [Debug] peer([pubkey]) - UAPI: Updating endpoint
2022/12/04 13:19:52 [Debug] peer([pubkey]) - UAPI: Updating persistent keepalive interval
2022/12/04 13:19:52 [Debug] peer([pubkey]) - UAPI: Updating preshared key
2022/12/04 13:19:52 [Debug] peer([pubkey]) - UAPI: Adding allowedip
2022/12/04 13:19:52 [Debug] peer([pubkey]) - UAPI: Adding allowedip
2022/12/04 13:19:52 [Debug] UDP bind has been updated
2022/12/04 13:19:52 [Debug] peer([pubkey]) - Starting
2022/12/04 13:19:52 [Debug] Interface state was Down, requested Up, now Up

2022/12/04 13:19:52 [Debug] Routine: encryption worker 1 - started
2022/12/04 13:19:52 [Debug] Routine: decryption worker 1 - started
2022/12/04 13:19:52 [Debug] Routine: handshake worker 1 - started
2022/12/04 13:19:52 [Debug] Routine: TUN reader - started
2022/12/04 13:19:52 [Debug] Routine: event worker - started
2022/12/04 13:19:52 [Debug] Interface up requested
2022/12/04 13:19:52 [Debug] Routine: receive incoming Open - started
2022/12/04 13:19:52 [Debug] peer([pubkey]) - Routine: sequential sender - started
2022/12/04 13:19:52 [Debug] peer([pubkey]) - Routine: sequential receiver - started

2022/12/04 13:19:52 [Debug] peer([pubkey]) - Sending handshake initiation
2022/12/04 13:19:52 [Debug] transport/internet: dialing to udp:[IPv6 addr]:12345
2022/12/04 13:19:52 [Debug] peer([pubkey]) - Received handshake response
2022/12/04 13:20:02 [Debug] peer([pubkey]) - Receiving keepalive packet

相关的服务器端配置

            {
                "type": "field",
                "ip":
                [
                    "geoip:netflix",
                    "geoip:google",
                    "2000::/3"
                ],
                "outboundTag": "wg0"
            }


{
            "protocol": "wireguard",
            "settings":
            {
                "secretKey": "",
                "peers":
                [
                    {
                        "publicKey": "",
                        "endpoint": "[IPv6 addr]:12345"
                    }
                ]
            },
            "tag": "wg0"
        }

wg0 conf大致这样

[Interface]
Address = fda1:0856:9e80::1/64
SaveConfig = true
ListenPort = 12345
PrivateKey = 

wg set wg0 peer (pubkey) allowed-ips fda1:0856:9e80::2

请教下正确的配置方法,或者说目前 wireguard 出站对 v6 支持还有问题?

谢谢

kdurov avatar Dec 04 '22 14:12 kdurov

此外貌似用 warp 出站的话,单线程速度卡在 20多 Mbps上不去。 直接在 VPS 上连的 wgcf warp 的话单线程能跑满几百 Mbps 没问题,性能有问题?还是需要配置什么? 有没有出站 wireguard 的详细文档?

kdurov avatar Dec 04 '22 14:12 kdurov

参考 https://github.com/XTLS/Xray-core/issues/1385#issuecomment-1329621046

把 "0.0.0.0/0", 删了,就只走V6,都有是V4优先

                        "allowedIPs": [
                            "0.0.0.0/0",
                            "::/0"

你这机是纯V6,你出站就写direct吧,wgcf全局代理得了

chika0801 avatar Dec 04 '22 14:12 chika0801

文档在 https://github.com/XTLS/Xray-core/pull/1344 这pr里的

chika0801 avatar Dec 04 '22 14:12 chika0801

@chika0801 谢谢。加上对应的 address 和 allowedIPs 就能正常连接了。 不过貌似还是有性能问题?用 outbounds 走wg 比起服务器上直接 wireguard 连接配路由表要慢上很多的样子。 ytb 的连接速度和单线程测速结果都貌似卡在 20Mbps前后上不去,这个可以确认是 xray 性能问题吗? (解锁搭 wg0 的机子是纯 v6,准确说是 NAT+v6;实际搭 xray 的机子是双栈但是都不解锁,所以配和能解锁的 NAT v6 机使用)

kdurov avatar Dec 04 '22 16:12 kdurov

几种不同方式套,快慢我没对比测试过。版本更新那天,我测试了下xray配置写法,研究了下v4v6优先级后,就没用这功能了。 平时我的机,我也不套wgcf用warp。

chika0801 avatar Dec 04 '22 16:12 chika0801

走 warp 还是有用的吧,保护隐私了。 cloudflare peer 那么多,比小商家 VPS 自己线路也好。

kdurov avatar Dec 04 '22 16:12 kdurov