Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行服务之后,客户端无法连接(超时),端口扫描 结果为端口关闭 #1205

Open
ruanjinchen opened this issue Sep 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ruanjinchen
Copy link

ruanjinchen commented Sep 21, 2024

描述问题
请尽量清晰精准地描述你遇到的问题。
我的网络环境是主路由192.168.0.1桥接光猫并拨号(公网V4),旁路由192.168.0.2与主路由网关互指。虚拟机开在群辉NAS上(ubuntu20.04)。群辉固定ip,且网关为192.168.0.1,虚拟机ip为192.168.0.4,虚拟机网关为192.168.0.1,按照官方文档的安装指令bash <(curl -fsSL https://get.hy2.sh/) 安装了Hysteria2,因为家宽80和443都被屏蔽了,所以没用群辉的ddns域名,用的自建证书。运行服务是成功的。端口转发设置在主路由上(虚拟机的网关就是主路由)。log如下。但是!扫描端口扫不出来外部端口,而且我客户端也连不上(Windows和iOS都连不上)。我查了一些issues,测试了udp端口互访是可以的(局域网内,Windows的虚拟机访问NAS的虚拟机,nc -ulp 6443做了测试,是没问题的)。另外ISP没有封我的外部端口,这个端口我换到NAS的WebDav是能用的。求教!

如何复现
如上。同时我还安装了22.04版本(在Windows VMware下,22.04和20.04都进行了测试),同样的步骤,一样连不上。同时在阿里云的云服务器上也部署了同样的服务(20.04下),并且配置了阿里云服务器面板的防火墙允许相应端口的udp进入。同样连不上,阿里云的服务器的ip端口同样扫不到(阿里云的是公网ip)。

配置文件

listen: 0.0.0.0:6443

tls:
  cert: /home/ruan/my.crt
  key: /home/ruan/my.key

auth:
  type: password
  password: 123456

masquerade: 
  type: proxy
  proxy:
    url: https://bing.com/
    rewriteHost: true

预期行为
应该端口能扫到吧

日志

ruan@ruan:~$ journalctl --no-pager -e -u hysteria-server.service
-- Logs begin at Fri 2024-09-20 16:48:19 PDT, end at Sat 2024-09-21 08:28:35 PDT. --
Sep 20 17:17:55 ruan systemd[1]: Started Hysteria Server Service (config.yaml).
Sep 20 17:17:55 ruan hysteria[6897]: 2024-09-20T17:17:55-07:00        INFO        server mode
Sep 20 17:17:55 ruan hysteria[6897]: 2024-09-20T17:17:55-07:00        INFO        server up and running        {"listen": ":6443"}
Sep 20 18:12:07 ruan systemd[1]: Stopping Hysteria Server Service (config.yaml)...
Sep 20 18:12:07 ruan systemd[1]: hysteria-server.service: Succeeded.
Sep 20 18:12:07 ruan systemd[1]: Stopped Hysteria Server Service (config.yaml).
Sep 20 18:12:13 ruan systemd[1]: Started Hysteria Server Service (config.yaml).
Sep 20 18:12:13 ruan hysteria[8192]: 2024-09-20T18:12:13-07:00        INFO        server mode
Sep 20 18:12:13 ruan hysteria[8192]: 2024-09-20T18:12:13-07:00        INFO        server up and running        {"listen": "0.0.0.0:443"}
Sep 20 18:14:09 ruan systemd[1]: Stopping Hysteria Server Service (config.yaml)...
Sep 20 18:14:09 ruan systemd[1]: hysteria-server.service: Succeeded.
Sep 20 18:14:09 ruan systemd[1]: Stopped Hysteria Server Service (config.yaml).
Sep 20 18:14:15 ruan systemd[1]: Started Hysteria Server Service (config.yaml).
Sep 20 18:14:15 ruan hysteria[8296]: 2024-09-20T18:14:15-07:00        INFO        server mode
Sep 20 18:14:15 ruan hysteria[8296]: 2024-09-20T18:14:15-07:00        INFO        server up and running        {"listen": "0.0.0.0:6443"}
-- Reboot --
Sep 21 07:19:57 ruan systemd[1]: Started Hysteria Server Service (config.yaml).
Sep 21 07:19:57 ruan hysteria[2235]: 2024-09-21T07:19:57-07:00        INFO        server mode
Sep 21 07:19:57 ruan hysteria[2235]: 2024-09-21T07:19:57-07:00        INFO        server up and running        {"listen": "0.0.0.0:6443"}
Sep 21 07:25:22 ruan systemd[1]: Stopping Hysteria Server Service (config.yaml)...
Sep 21 07:25:22 ruan systemd[1]: hysteria-server.service: Succeeded.

设备和操作系统
虚拟机Linux Ubuntu 22.04、虚拟机Linux Ubuntu 20.04

@ruanjinchen ruanjinchen added the bug Something isn't working label Sep 21, 2024
@LouisFonda
Copy link

描述问题 请尽量清晰精准地描述你遇到的问题。 我的网络环境是主路由192.168.0.1桥接光猫并拨号(公网V4),旁路由192.168.0.2与主路由网关互指。虚拟机开在群辉NAS上(ubuntu20.04)。群辉固定ip,且网关为192.168.0.1,虚拟机ip为192.168.0.4,虚拟机网关为192.168.0.1,按照官方文档的安装指令bash <(curl -fsSL https://get.hy2.sh/) 安装了Hysteria2,因为家宽80和443都被屏蔽了,所以没用群辉的ddns域名,用的自建证书。运行服务是成功的。端口转发设置在主路由上(虚拟机的网关就是主路由)。log如下。但是!扫描端口扫不出来外部端口,而且我客户端也连不上(Windows和iOS都连不上)。我查了一些issues,测试了udp端口互访是可以的(局域网内,Windows的虚拟机访问NAS的虚拟机,nc -ulp 6443做了测试,是没问题的)。另外ISP没有封我的外部端口,这个端口我换到NAS的WebDav是能用的。求教!

如何复现 如上。同时我还安装了22.04版本(在Windows VMware下,22.04和20.04都进行了测试),同样的步骤,一样连不上。同时在阿里云的云服务器上也部署了同样的服务(20.04下),并且配置了阿里云服务器面板的防火墙允许相应端口的udp进入。同样连不上,阿里云的服务器的ip端口同样扫不到(阿里云的是公网ip)。

配置文件

listen: 0.0.0.0:6443

tls:
  cert: /home/ruan/my.crt
  key: /home/ruan/my.key

auth:
  type: password
  password: 123456

masquerade: 
  type: proxy
  proxy:
    url: https://bing.com/
    rewriteHost: true

预期行为 应该端口能扫到吧

日志

ruan@ruan:~$ journalctl --no-pager -e -u hysteria-server.service
-- Logs begin at Fri 2024-09-20 16:48:19 PDT, end at Sat 2024-09-21 08:28:35 PDT. --
Sep 20 17:17:55 ruan systemd[1]: Started Hysteria Server Service (config.yaml).
Sep 20 17:17:55 ruan hysteria[6897]: 2024-09-20T17:17:55-07:00        INFO        server mode
Sep 20 17:17:55 ruan hysteria[6897]: 2024-09-20T17:17:55-07:00        INFO        server up and running        {"listen": ":6443"}
Sep 20 18:12:07 ruan systemd[1]: Stopping Hysteria Server Service (config.yaml)...
Sep 20 18:12:07 ruan systemd[1]: hysteria-server.service: Succeeded.
Sep 20 18:12:07 ruan systemd[1]: Stopped Hysteria Server Service (config.yaml).
Sep 20 18:12:13 ruan systemd[1]: Started Hysteria Server Service (config.yaml).
Sep 20 18:12:13 ruan hysteria[8192]: 2024-09-20T18:12:13-07:00        INFO        server mode
Sep 20 18:12:13 ruan hysteria[8192]: 2024-09-20T18:12:13-07:00        INFO        server up and running        {"listen": "0.0.0.0:443"}
Sep 20 18:14:09 ruan systemd[1]: Stopping Hysteria Server Service (config.yaml)...
Sep 20 18:14:09 ruan systemd[1]: hysteria-server.service: Succeeded.
Sep 20 18:14:09 ruan systemd[1]: Stopped Hysteria Server Service (config.yaml).
Sep 20 18:14:15 ruan systemd[1]: Started Hysteria Server Service (config.yaml).
Sep 20 18:14:15 ruan hysteria[8296]: 2024-09-20T18:14:15-07:00        INFO        server mode
Sep 20 18:14:15 ruan hysteria[8296]: 2024-09-20T18:14:15-07:00        INFO        server up and running        {"listen": "0.0.0.0:6443"}
-- Reboot --
Sep 21 07:19:57 ruan systemd[1]: Started Hysteria Server Service (config.yaml).
Sep 21 07:19:57 ruan hysteria[2235]: 2024-09-21T07:19:57-07:00        INFO        server mode
Sep 21 07:19:57 ruan hysteria[2235]: 2024-09-21T07:19:57-07:00        INFO        server up and running        {"listen": "0.0.0.0:6443"}
Sep 21 07:25:22 ruan systemd[1]: Stopping Hysteria Server Service (config.yaml)...
Sep 21 07:25:22 ruan systemd[1]: hysteria-server.service: Succeeded.

设备和操作系统 虚拟机Linux Ubuntu 22.04、虚拟机Linux Ubuntu 20.04

你的家庭网络我没看明白,但是阿里云服务器之所以没连进去是因为没把对应端口的udp流量放行,我今天下午也被这个地方坑了,应为服务器一般是放行80,443,22的,但是这些都是tcp流量,对应udp没有放行,我的服务跑在本地127.0.0.1:2443,使用nginx stream把443的udp流量都转发到本地2443,这样对外就像是一个运行在443的http3网站,放行udp流量就可以了,服务跑起来肯定能连上的

@haruue
Copy link
Collaborator

haruue commented Sep 21, 2024

局域网内测试能互访说明不了问题, 你要从公网访问, 就要走公网测 nc -ulp 443 才行。

然后, Hysteria 的 UDP 端口不回应不符合 QUIC 格式的数据包, 如果用 nmap -sU 去扫描 Hysteria 端口, 由于 Hysteria 不对 nmap 的探测包作出任何回应, nmap 会认为这个端口的状态是 open|filtered 。 如果你看到的是 closed , 说明 nmap 收到了 ICMP addr/port unreachable, 这种情况下你的端口转发或者防火墙没配置正确。

经验上来说, 对于比较复杂的网络环境, 在客户端和服务端两边同时使用 tcpdump 抓包是比较容易找出问题的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants