hysteria2官网:https://v2.hysteria.network/
密码生成器:https://www.roboform.com/cn/password-generator
自签名证书:https://bkssl.com/ssl/selfsign
一键安装
bash <(curl -fsSL https://get.hy2.sh/)
端口占用查询
netstat -lnp | grep 80
netstat -lnp | grep 443
配置文件示例:
listen: :6443
tls:
cert: /home/hongyanzui2023/self-sign.crt
key: /home/hongyanzui2023/private.key
#需要使用非root用户把证书存放到home文件夹
auth:
type: password
password: 密码可用生成器
masquerade:
type: proxy
proxy:
url: https://www.bing.com/
rewriteHost: true
quic:
initStreamReceiveWindow: 26843545
maxStreamReceiveWindow: 26843545
initConnReceiveWindow: 67108864
maxConnReceiveWindow: 67108864命令合集:
启动: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
开放端口
iptables -I INPUT -p udp --dport 6443 -j ACCEPT
测试命令
/usr/local/bin/hysteria server --config /etc/hysteria/config.yaml
说明:如果启动不了,也看不到错误信息,可能需要使用–log-level debug调整日志级别,例如:/usr/local/bin/hysteria server --log-level debug --config /etc/hysteria/config.yaml
端口跳跃+负载均衡
端口在线生成器:https://www.chahuo.com/random-port-generator.html
负载均衡(haproxy)
负载均衡,健康检查,监控与统计
负载均衡:按照权重将连接平均分配到不同的服务器/端口
健康检查:实时检查后端连接的可用性,如果不可用,会自动临时下线该服务器。如果可用了会再次上线该服务器。
监控与统计:监控与统计服务器状态与流量
添加:
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端口转发
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 随机端口 -j DNAT --to-destination :6443
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 随机端口 -j DNAT --to-destination :6443
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 随机端口 -j DNAT --to-destination :6443
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 随机端口 -j DNAT --to-destination :6443
iptables -t nat -A PREROUTING -i ens33 -p udp --dport 随机端口 -j DNAT --to-destination :6443
性能优化
系统缓冲区大小
Linux
# 将发送、接收两个缓冲区都设置为 16 MB
sysctl -w net.core.rmem_max=16777216
sysctl -w net.core.wmem_max=16777216流控制接收窗口大小
Hysteria 在客户端和服务器配置中都有以下 QUIC 流控制接收窗口参数:
quic:
initStreamReceiveWindow: 26843545
maxStreamReceiveWindow: 26843545
initConnReceiveWindow: 67108864
maxConnReceiveWindow: 67108864
评论