hysteria2安装教程

hysteria2安装教程

服务器相关指令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#一键安装Hysteria2 *
bash <(curl -fsSL https://get.hy2.sh/)
#生成自签证书
#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
#启动Hysteria2 *
systemctl start hysteria-server.service
#重启Hysteria2
systemctl restart hysteria-server.service
#查看Hysteria2状态 *
systemctl status hysteria-server.service
#停止Hysteria2
systemctl stop hysteria-server.service
#设置开机自启 *
systemctl enable hysteria-server.service
#查看日志
journalctl -u hysteria-server.service

服务器配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
cat << EOF > /etc/hysteria/config.yaml
listen: :8443 #监听端口

#使用CA证书
acme:
domains:
- a.com #你的域名,需要先解析到服务器ip
email: [email protected]

#使用自签证书
#tls:
# cert: /etc/hysteria/server.crt
# key: /etc/hysteria/server.key

auth:
type: password
password: 123456 #设置认证密码

masquerade:
type: proxy
proxy:
url: https://bing.com #伪装网址
rewriteHost: true
EOF

客户端配置

配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
server: ip:8443
auth: 123456

bandwidth:
up: 20 mbps
down: 100 mbps

tls:
sni: a.com
insecure: false #使用自签时需要改成true

socks5:
listen: 127.0.0.1:1080
http:
listen: 127.0.0.1:8080

端口跳跃配置

1
2
# 添加NAT规则
iptables -t nat -A PREROUTING -i eth0 -p udp --dport 40000:45000 -j REDIRECT --to-ports 8443