电脑技术:Hysteria2节点搭建【转载】
source link: https://www.taholab.com/26992
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
电脑技术:Hysteria2节点搭建【转载】
转载自:https://v2rayssr.com/hysteria2.html
去年9月2日,歇斯底里推出了 APP / V2.0.0,表示 Hysteria 协议,正式进入了 2.0 时代。
2.0版本,大幅提升了其性能和稳定性,而且支持反代伪装,这就进一步的增加了抗审查的能力。
因为是刚发布出来,各项运行也不是特别稳定,匹配的 APP 也是在极少数,所以使用的人群也并不算太大。
那,截止到目前,已经过去了差不多四个月了,Hysteria 2 也已经是更新到了 V2.2.3 ,很多 APP 也是逐渐适配了这个协议。图形化界面的客户端也是有了不少,涵盖了我们经常使用的各种平台,什么 PC 端、iOS、安卓、Openwrt 等等等等
那我们今天就一起在来看看这个简单、暴力的协议。
视频地址:https://www.youtube.com/watch?v=dRTID26OC7g
可以选择使用
ACME(CA证书)
和自签证书
两种方式,二选一,也就是可以使用域名,也可以不使用域名后面我们分别会讲到 服务端 / 客户端 的配置和参数
-
- 1、VPS 一台,新手请重置好主流的操作系统( Debian / CentOS ),演示用的 VPS 来自 搬瓦工 CN2 49$/年
- 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: [email protected] # 邮箱,格式正确即可
- #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
- sni: cn2.bozai.us # 若无域名,请改为 bing.com
- insecure: false # 若无域名,需要改参数为 true
- socks5:
- listen: 127.0.0.1:1080
- http:
- listen: 127.0.0.1:8080
具体配置文件导入,请看 演示视频
OpenWRT 推荐使用 PassWall2
添加协议,如下图所示:
下图配置为有域名的配置参数。(请自行评估自己的上传和下载带宽,数值过大会引起流量浪费)
若是无域名的配置,请在
域名
栏目,填写 伪装网站bing.com
,并勾选允许不安全连接
即可认证密码,为 VPS 服务端 上面配置的密码
Android / IOS / MacOS 推荐使用 sing-box
sing-box 图形化客户端下载:点击访问
MacOS 和 iOS 需要使用美区 AppleID (我只有美区,其他区域未进行尝试)进行正版下载,若是没有,可以 点击这里 免费申请外区 AppleID
sing-box 配置文件
请看清楚以下配置文件中的注释,请根据自己的需要,自行更改。
- “dns”: {
- “servers”: [
- “tag”: “cf”,
- “address”: “https://1.1.1.1/dns-query”
- “tag”: “local”,
- “address”: “223.5.5.5”,
- “detour”: “direct”
- “tag”: “block”,
- “address”: “rcode://success”
- “rules”: [
- “geosite”: “category-ads-all”,
- “server”: “block”,
- “disable_cache”: true
- “outbound”: “any”,
- “server”: “local”
- “geosite”: “cn”,
- “server”: “local”
- “strategy”: “ipv4_only”
- “inbounds”: [
- “type”: “tun”,
- “inet4_address”: “172.19.0.1/30”,
- “auto_route”: true,
- “strict_route”: false,
- “sniff”: true
- “outbounds”: [
- “type”: “hysteria2”,
- “tag”: “proxy”,
- “server”: “ip”, // VPS ip
- “server_port”: 443,
- “up_mbps”: 50, //上传速率,实际填写,过大会导致流量浪费
- “down_mbps”: 200, //下载速率,实际填写,过大会导致流量浪费
- “password”: “**********”, //hysteria2 服务密码
- “tls”: {
- “enabled”: true,
- “server_name”: “cn2.bozai.us”, //若域名搭建,请填写域名,若IP搭建,请填写 bing.com
- “insecure”: false //若域名搭建,请填写 false,若IP搭建,请填写 true
- “type”: “direct”,
- “tag”: “direct”
- “type”: “block”,
- “tag”: “block”
- “type”: “dns”,
- “tag”: “dns-out”
- “route”: {
- “rules”: [
- “protocol”: “dns”,
- “outbound”: “dns-out”
- “geosite”: “cn”,
- “geoip”: [
- “private”,
- “outbound”: “direct”
- “geosite”: “category-ads-all”,
- “outbound”: “block”
- “auto_detect_interface”: true
MacOS 客户端图片
在 Surge 中使用 Hysteria 2
在 Surge 中,我们也是可以配置 Sub-Store 来使用 hysteria2
具体的 Sub-Store 教程
使用域名搭建,download-bandwidth 根据实际填写
- Proxy = hysteria2, VPSip, 443, password=服务密码, sni=你的域名, download–bandwidth=200
无域名,使用IP搭建,download-bandwidth 根据实际填写
- Proxy = hysteria2, VPSip, 443, password=服务密码, skip–cert–verify=true,sni=bing.com, download–bandwidth=200
Hysteria 2 的伪装验证
进入 Chrome.exe
目标地址(路径),开启 Hysteria2
代理,Windows
打开 TUN
模式,cmd
命令如下:
- chrome —origin–to–force–quic–on=你的域名:443
访问 https://你的域名
,若是按照上述搭建的话,会跳转到 bing.com
的网页。
若是不明白,也是可以 观看本期视频
Hysteria 从出现就是饱受争议。
有人觉得他直接、有人觉得他暴力,还有人觉得他不道德,这个看我们如何去定义。
Hysteria 自有的拥塞控制算法,的确有别于传统的一些算法,若网络状态很好,丢包的情况少,我们在客户端可以选择不填入带宽数值,那其实 Hysteria 和其他的任何协议几乎一样,他并不能突破我们 VPS 的上传和下载的速度上限,使用的也仅仅是 BBR 的拥堵算法。
但若是网络拥挤,丢包率高,我们在填入了 UP 和 DOWN 的数值带宽数值以后,Hysteria 会通过计算丢包率来提升速度进行补偿。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK