- 1、VPS 一台,新手请重置好主流的操作系统( Debian / CentOS )
- 2、域名一个,非必须,做好解析
相关工具和介绍
Hysteria 2 GitHub 项目地址:点击访问
Hysteria 2 详细中文文档:点击访问
Sing – Box 中文文档 :点击访问
Hysteria 2 下载:点击访问
V2rayN 科学上网工具下载:点击访问
搭建 Hysteria 2
安装 Hysteria 2 服务器端
更新 VPS 系统,安装所需组件 (根据系统,自行选择命令)
- apt update -y #Debian 命令
- apt install curl sudo -y #Debian 命令
- yum update -y #CentOS 命令
- yum install curl sudo -y #CentOS 命令
我们使用 Hysteria 官方的一键安装脚本
- # 安装或升级到最新版本 Hysteria 2:
- bash <(curl -fsSL https://get.hy2.sh/)
-
- # 移除 Hysteria 2:
- bash <(curl -fsSL https://get.hy2.sh/) --remove
若无域名,生成自签证书
命令会在 VPS 目录 /etc/hysteria 中生成 server.crt 及 server.key 文件,并变更相关权限
- 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
服务端配置文件
服务端的配置要和客户端状态一致,也就是说,服务端配置的是无域名的配置,客户端也必须选择无域名的配置参数,必须一致,反之一样,服务端配置的是有域名的,那稍后客户端也必须选择有域名的参数
好在配置更改起来很简单,有域名和无域名更换起来,也就几分钟的事情。
推荐密码设置 :点击访问 生成随机高强度密码
- listen: :443
-
- # 以下 acme 和 tls 字段,二选一
- # 有域名部署的选择 acme ,无域名的选择 tls
- # 选择 acme,必须注释掉 tls,反之一样
-
- acme:
- domains:
- - cn2.bozai.us # 域名
- email: your@email.com # 邮箱,格式正确即可
-
- #tls:
- # cert: /etc/hysteria/server.crt
- # key: /etc/hysteria/server.key
-
- auth:
- type: password
- password: 88888888 # 请及时更改密码
-
- masquerade:
- type: proxy
- proxy:
- url: https://bing.com # 伪装网站
- rewriteHost: true
服务相关命令
- systemctl start hysteria-server.service # 启动 hysteria 服务
- systemctl enable hysteria-server.service # 设置 hysteria 服务 开机自启
- systemctl restart hysteria-server.service # 重启 hysteria 服务
- systemctl stop hysteria-server.service # 停止 hysteria 服务
- 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 等参数
- server: ip:443
- auth: ****
-
- #bandwidth:
- # up: 20 mbps
- # down: 100 mbps
-
- tls:
- sni: cn2.bozai.us # 若无域名,请改为 bing.com
- insecure: false # 若无域名,需要改参数为 true
-
- socks5:
- listen: 127.0.0.1:1080
- http:
- 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
评论
发表评论