openwrt系列第十六期:疯狂的Hysteria2调优篇

网络技术 2年前 (2024) zy8347
0

openwrt系列第十六期:疯狂的Hysteria2调优篇

详细信息

hysteria2官网:https://v2.hysteria.network/

密码生成器:https://www.roboform.com/cn/password-generator

自签名证书:https://bkssl.com/ssl/selfsign

查看端口是否被占用:

1
2
netstat -lnp | grep 80
netstat -lnp | grep 443

命令合集:

1
2
3
4
5
6
启动:systemctl start hysteria-server.service
停止:systemctl stop hysteria-server.service
重启:systemctl restart hysteria-server.service
查看状态:systemctl status hysteria-server.service -l
设置开机启动:systemctl enable hysteria-server.service
取消开机启动:systemctl disable hysteria-server.service

说明:如果启动不了,也看不到错误信息,可能需要使用–log-level debug调整日志级别,例如:/usr/local/bin/hysteria server --log-level debug --config /etc/hysteria/config.yaml

测试命令:

1
/usr/local/bin/hysteria server --config /etc/hysteria/config.yaml

开放6443端口

1
iptables -I INPUT -p udp --dport 6443 -j ACCEPT

centos7部署步骤

1.升级内核

2.升级软件

1
yum update -y

3.开放80 443端口

1
2
3
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -p udp --dport 6443 -j ACCEPT

4.检查80 443 端口是否被占用

1
2
netstat -lnp | grep 80
netstat -lnp | grep 443

5.安装配置hysteria,包括证书

1
2
3
bash <(curl -fsSL https://get.hy2.sh/)
mkdir /home/hysteria
vim /etc/hysteria/config.yaml

6.开放hysteria端口

7.自有域名赋予普通用户低端口权限:

1
setcap cap_net_bind_service=+ep /usr/local/bin/hysteria

8.启动hysteria

查看端口是否被占用命令:

1
netstat -lnp | grep 端口号

端口跳跃:

开放20000-50000之间的端口号:

1
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 20000:50000 -j DNAT --to-destination :6443

端口跳跃+负载均衡

端口在线生成器:https://www.chahuo.com/random-port-generator.html

负载均衡(haproxy)

负载均衡,健康检查,监控与统计

负载均衡:按照权重将连接平均分配到不同的服务器/端口

健康检查:实时检查后端连接的可用性,如果不可用,会自动临时下线该服务器。如果可用了会再次上线该服务器。

		如果可用了会再次上线该服务器。

监控与统计:监控与统计服务器状态与流量

操作20000-50000之间的端口号:

1
2
3
4
添加:
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 20000:50000 -j DNAT --to-destination :6443
删除:
iptables -t nat -D PREROUTING -i ens33 -p udp --dport 20000:50000 -j DNAT --to-destination :6443

示例端口:

16669

27740

39171

49895

55831

1
2
3
4
5
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 16669 -j DNAT --to-destination :6443
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 27740 -j DNAT --to-destination :6443
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 39171 -j DNAT --to-destination :6443
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 49895 -j DNAT --to-destination :6443
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 55831 -j DNAT --to-destination :6443

passwall脚本文件路径:/tmp/etc/passwall/script_func

修改hysteria2窗口bug:/usr/lib/lua/luci/model/cbi/passwall/client/type

窗口优化配置:

1
2
3
4
5
quic:
  initStreamReceiveWindow: 26843545 
  maxStreamReceiveWindow: 26843545 
  initConnReceiveWindow: 67108864 
  maxConnReceiveWindow: 67108864 

参考资料

hysteria2官网:https://v2.hysteria.network/

centos7常见问题:https://github.com/apernet/hysteria/issues/810#issuecomment-1807690164

centos7更新内核:https://blog.yywq.me/article/39f87fd6-1c3e-4826-90d9-5d031393ca8d

版权声明:zy8347 发表于 2024-01-19 13:34:02。
转载请注明:openwrt系列第十六期:疯狂的Hysteria2调优篇 | Venom

暂无评论

暂无评论...