Hysteria2节点搭建

 

    • 1、VPS 一台,新手请重置好主流的操作系统( Debian / CentOS )
    • 2、域名一个,非必须,做好解析

相关工具和介绍

Hysteria 2 GitHub 项目地址:点击访问

Hysteria 2 详细中文文档:点击访问

Sing – Box 中文文档 :点击访问

Hysteria 2 下载:点击访问

V2rayN 科学上网工具下载:点击访问

搭建 Hysteria 2

安装 Hysteria 2 服务器端

更新 VPS 系统,安装所需组件 (根据系统,自行选择命令)

  1. apt update -y #Debian 命令
  2. apt install curl sudo -y #Debian 命令
  1. yum update -y #CentOS 命令
  2. yum install curl sudo -y #CentOS 命令

我们使用 Hysteria 官方的一键安装脚本

  1. # 安装或升级到最新版本 Hysteria 2:
  2. bash <(curl -fsSL https://get.hy2.sh/)
  3.  
  4. # 移除 Hysteria 2:
  5. bash <(curl -fsSL https://get.hy2.sh/) --remove

若无域名,生成自签证书

命令会在 VPS 目录 /etc/hysteria 中生成 server.crt 及 server.key 文件,并变更相关权限

  1. openssl req -x509 -nodes -newkey ec:<(openssl ecparam -name prime256v1) -keyout /etc/hysteria/server.key -out /etc/hysteria/server.crt -subj "/CN=bing.com" -days 36500 && sudo chown hysteria /etc/hysteria/server.key && sudo chown hysteria /etc/hysteria/server.crt

服务端配置文件

服务端的配置要和客户端状态一致,也就是说,服务端配置的是无域名的配置,客户端也必须选择无域名的配置参数,必须一致,反之一样,服务端配置的是有域名的,那稍后客户端也必须选择有域名的参数

好在配置更改起来很简单,有域名和无域名更换起来,也就几分钟的事情。

推荐密码设置 :点击访问 生成随机高强度密码

  1. listen: :443
  2. # 以下 acme 和 tls 字段,二选一
  3. # 有域名部署的选择 acme ,无域名的选择 tls
  4. # 选择 acme,必须注释掉 tls,反之一样
  5. acme:
  6. domains:
  7. - cn2.bozai.us # 域名
  8. email: your@email.com # 邮箱,格式正确即可
  9. #tls:
  10. # cert: /etc/hysteria/server.crt
  11. # key: /etc/hysteria/server.key
  12. auth:
  13. type: password
  14. password: 88888888 # 请及时更改密码
  15. masquerade:
  16. type: proxy
  17. proxy:
  18. url: https://bing.com # 伪装网站
  19. rewriteHost: true

服务相关命令

  1. systemctl start hysteria-server.service # 启动 hysteria 服务
  2. systemctl enable hysteria-server.service # 设置 hysteria 服务 开机自启
  3. systemctl restart hysteria-server.service # 重启 hysteria 服务
  4. systemctl stop hysteria-server.service # 停止 hysteria 服务
  5. systemctl status hysteria-server.service # 查看 hysteria 服务 状态

检查服务是否正常运行

如下图红框显示,即为服务正常!若有域名,并且多次CA证书下发失败,请尝试不用域名搭建





至此,服务端设置完毕。

客户端配置

Windows 推荐使用 V2rayN

当然 sing-box 正在研发之中,具体施工进程:点击查看该网页

V2rayN 科学上网工具下载:点击访问 推荐使用带 Core 的版本 v2rayN-With-Core.zip

解压 V2rayN,找到文件目录中的 \bin\hysteria2 ,替换 hysteria-windows-amd64.exe 为 最新文件,点击下载

客户端配置文件

请看清楚配置文件中的注释,修改 ip , auth(VPS 服务端 上面配置的密码) , bandwidth , sni , insecure 等参数

  1. server: ip:443
  2. auth: ****
  3.  
  4. #bandwidth:
  5. # up: 20 mbps
  6. # down: 100 mbps
  7. tls:
  8. sni: cn2.bozai.us # 若无域名,请改为 bing.com
  9. insecure: false # 若无域名,需要改参数为 true
  10.  
  11. socks5:
  12. listen: 127.0.0.1:1080
  13. http:
  14. listen: 127.0.0.1:8080

hysteria2的端口跳跃在服务端需要配置

# IPv4

iptables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:50000 -j DNAT --to-destination :443

# IPv6

ip6tables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:50000 -j DNAT --to-destination :443

评论

此博客中的热门博文

Ubuntu-24.04-LTS 安装 ERPNext15

2025年 eSIM方案选择和对比: 9eSIM、XeSIM 和 eSTK 优缺点对比

2025年 纳指100 QQQ和标普500 VOO 指数基金稳健投资策略