安装
下载地址
linux一键安装脚本
说明文档
使用systemctl管理hysteria2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| [Unit] Description=Hysteria Server Service (config.yaml) After=network.target
[Service] Type=simple ExecStart=/usr/local/bin/hysteria server --config /etc/hysteria/config.yaml WorkingDirectory=/etc/hysteria User=hysteria Group=hysteria Environment=HYSTERIA_LOG_LEVEL=info CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW NoNewPrivileges=true
[Install] WantedBy=multi-user.target
|
管理服务
1 2 3
| sudo systemctl enable hysteria-server.service sudo systemctl start hysteria-server.service sudo systemctl stop hysteria-server.service
|
服务端
记得防火墙放行udp端口
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| listen: :80
tls: cert: key:
speedTest: true
auth: type: password password: xxxx
masquerade: type: file | proxy | string file: dir: /www/masq proxy: url: https://some.site.net rewriteHost: true string: content: hello stupid world headers: content-type: text/plain custom-stuff: ice cream so good statusCode: 200
outbounds:
- name: my_outbound_1 type: socks5 socks5: addr: ip:port
- name: my_outbound_2 type: http http: url: http://ip:port
- name: my_outbound_3 type: direct direct: mode: auto
acl: file: /etc/hysteria/acl.txt
|
客户端
以clash为例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| proxies: - name: test type: hysteria2 server: port: 80 udp: true password: xxx up: "150 Mbps" down: "100 Mbps" sni: skip-cert-verify: false
|
出站
修改出站规则,以解锁网易云灰色歌曲为例
1 2 3 4 5 6 7 8 9 10 11
| outbounds: - name: music type: http http: url: http://ip:8081 - name: Direct type: direct direct: mode: auto acl: file: /etc/hysteria/acl.txt
|
1 2 3 4 5 6 7 8 9 10
| # 网易云解锁 music(music.163.com) music(apm.music.163.com) music(apm3.music.163.com) music(interface.music.163.com) music(interface3.music.163.com) music(interface.music.163.com.163jiasu.com) music(interface3.music.163.com.163jiasu.com) # 直连 Direct(all)
|
端口跃迁
服务端
Hysteria 服务端并不能同时监听多个端口,因此不能在服务器端使用上面的格式作为监听地址。建议配合 iptables 或 nftables 的 DNAT 将端口转发到服务器的监听端口。
1 2 3 4
| iptables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:50000 -j REDIRECT --to-ports 443
ip6tables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:50000 -j REDIRECT --to-ports 443
|
在这个示例中,服务器监听 443 端口,但客户端可以通过 20000-50000 范围内的任何端口连接
无法连接节点的排错记录
域名证书过期
1 2
| sni: pve.010920.xyz skip-cert-verify: false
|
sni对应证书的域名;skip-cert-verify设置为false的情况下,证书过期会无法连接,临时设置为true即可
DNS解析
1
| server: your-domain-name
|
设置为域名的情况下,要保证该域名能被设置的DNS服务器解析,否则会因找不到IP地址无法连接