hysteria2官方脚本手动搭建+端口跳跃
1、安装hysteria
bash <(curl -fsSL https://get.hy2.sh/)
2、设置hysteria2开机自启
systemctl enable hysteria-server.service
3、修改/etc/hysteria/config.yaml配置文件
nano /etc/hysteria/config.yaml
清空文件内容,将下列命令粘贴进去保存
listen: :9443 #端口自定义
acme: #域名证书
domains:
- xx.us #已解析好的域名
email: xx@gmail.com #随便输入邮箱名
auth:
type: password
password: 88888888 #密码自定义
masquerade:
type: proxy
proxy:
url: https://bing.com #伪装网站
rewriteHost: true
outbounds: #出站端口设置
- name: v4
type: direct
direct:
mode: 4
- name: v6
type: direct
direct:
mode: 6
acl:
inline: #内置出站规则,从上到下优先出站
- v4(geosite:netflix) #v4解锁nf
- v6(::/0) #v6分流
- v4(0.0.0.0/0) #v4分流
- direct(all) #其它直连出站
4、设置端口跳跃
注意:网卡名称eth0要根据vps具体情况更改,可用命令“ip a”查看网卡名称!
apt install iptables-persistent
iptables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:40000 -j DNAT --to-destination :9443
ip6tables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:40000 -j DNAT --to-destination :9443
netfilter-persistent save
5、启动Hysteria2
systemctl start hysteria-server.service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
passwall节点设置
Hysteria2相关命令
#一键安装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
#移除 Hysteria:
bash <(curl -fsSL https://get.hy2.sh/) --remove
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
提示:
#设置端口跳跃(不通的话尝试这个命令)
apt install iptables-persistent
iptables -t nat -A PREROUTING -p udp --dport 20000:40000 -j DNAT --to-destination :9443
ip6tables -t nat -A PREROUTING -p udp --dport 20000:40000 -j DNAT --to-destination :9443
netfilter-persistent save
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
若端口跳跃网卡名称需要修改,输入以下命令,修改对应的网卡名称
#查看网卡名称
ip a
nano /etc/iptables/rule.v4
nano /etc/iptables/rule.v6
#重启iptables命令(重新设置端口跳跃时用到)
systemctl restart iptables.service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~