跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[程序员] 求助 QUIC 协议走 Wireguard 代理不通的问题

发表于

环境

电脑 --- 路由器 --- 跳板服务 --- 目标服务器

电脑 IP:10.10.*.*

路由器 Wireguard IP:192.168.69.1

要访问的远程服务器 IP:17.*.*.*

问题

电脑在内网,路由器上配置了 Wireguard ,Wireguard 另一端跳板服务在公网。现在内网的电脑想通过 Wireguard 访问到公网的服务器的 QUIC 协议的服务。

现在情况是,如果不走 Wireguard ,电脑通过路由器是可以正常访问到目标服务的,没有问题。但是配置走了 Wireguard ,就无法正常访问了。

conntrack 和 Wireshark 抓包的结果:

w9KQ9lV5.png

lp3Bo0Ox.png

看起来是电脑在发送 QUIC 请求,服务端返回了响应包,但是电脑对收到的每个响应包都会回一个 ICMP Port unreachable 的响应,导致连接立即被中断 DESTROY 。

尝试排查

因为 QUIC 协议是基于 UDP 的,所以我拿 Node.JS 简单写了个测试程序,在服务器上监听 UDP 端口,做一个 echo 服务,电脑上给服务端发 UDP 请求,服务端给返回多个响应包:

服务端:

import dgram from 'node:dgram';

const server = dgram.createSocket('udp4');
server.bind(443);

server.addListener('message', async (msg, rinfo) => {
    console.log(`Received ${msg.length} bytes from ${rinfo.address}:${rinfo.port}: ${msg}`);
    for (let i = 0; i < 5; ++i) {
        // 延迟 1 秒
        await new Promise(r => setTimeout(r, 1e3));
        server.send(Buffer.concat([msg, Buffer.from(i.toString())]), rinfo.port, rinfo.address, (error, bytes) => {
            console.log('send to', rinfo.address, rinfo.port, error, 'bytes', bytes);
        });
    }
});

客户端:

import dgram from 'node:dgram';

const socket = dgram.createSocket('udp4');

socket.addListener('message', (msg, rinfo) => {
    console.log(`Received ${msg.length} bytes from ${rinfo.address}:${rinfo.port}: ${msg}`);
});

socket.send("asd", 443, " [脱敏,远端 IP ] ");

结果是正常的,电脑上运行客户端代码,会用一个随机端口给服务器的 443 发请求,服务端收到的包显示远端 IP 是 Wireguard 远端的 IP ,表示数据包确实是走 Wireguard 转发到服务端的,然后服务端回复给 Wireguard 远端的 5 个包也都能正常被内网的电脑收到。


目前没有其他头绪了,来求助问一下,还有什么方向可以排查的吗?可能是什么问题呢?

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.