点击“添加” 增加socks配置,socks节点列选择你搭建好的hysteria节点,填写socks5监听端口(假设是10808,注意不要设置为1070,在上一张图的上一张图中已经被占用)和http监听端口(假设是10809),勾选 “socks主开关”,最后点击“保存&应用”
1、配置iptables防火墙规则
#安装iptables-persistent
apt install iptables-persistent
#允许所有入站
iptables -P INPUT ACCEPT
#清空所有默认规则
iptables -F
#清空所有自定义规则
iptables -X
#所有计数器清零
iptables -Z
#允许本地访问
iptables -A INPUT -i lo -j ACCEPT
#开放22端口
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
#开放80端口(HTTP)
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#开放443端口(HTTPS)
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
#开放10010端口(UDP)
iptables -A INPUT -p udp --dport 10010 -j ACCEPT
#开放20000-40000端口(UDP)
iptables -A INPUT -p udp --dport 20000:40000 -j ACCEPT
#允许接受本机请求之后的返回数据
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#其他入站一律禁止
iptables -P INPUT DROP
#允许所有出站
iptables -P OUTPUT ACCEPT
#查看开放的端口
iptables -L
#添加NAT规则
iptables -t nat -A PREROUTING -p udp --dport 20000:40000 -j DNAT --to-destination :10010
#查看NAT规则
iptables -t nat -nL --line
#保存iptables规则
netfilter-persistent save
2、下载hysteria
wget -O /usr/bin/hysteria https://github.com/apernet/hysteria/releases/download/v1.3.4/hysteria-linux-amd64
3、使hysteria可执行
chmod +x /usr/bin/hysteria
4、编辑hysteria配置信息
mkdir /etc/hysteria && cd $_
touch config.json
#config.json配置信息
{
"listen": ":10010", //监听地址
"protocol": "udp", //"udp","wechat-video","faketcp",留空默认"udp"
"acme": {
"domains": [
"mydomain.com" //你的域名
],
"email": "email@gmail.com" //你的邮箱
},
"up_mbps": 200, // 单客户端最大上传速度
"down_mbps": 500, // 单客户端最大下载速度
"disable_udp": false,
"obfs": "obfs123", // 混淆密码
"auth": {
"mode": "password", // 验证模式,目前支持 "none", "passwords", "external"
"config": [
"xiao001" //修改为自己的验证密钥,密钥可多组(多用户),示例:"xiao001","xiao002","xiao003"
]
},
"alpn": "h3",
"recv_window_conn": 15728640, //QUIC流接收窗口
"recv_window_client": 67108864, //QUIC连接接收窗口
"max_conn_client": 4096, // 单客户端最大活跃连接数
"disable_mtu_discovery": false
}
5、为hysteria配置开机自启
cat > /etc/systemd/system/hysteria.service <<EOF
[Unit]
Description=Hysteria Server Service
After=network.target
[Service]
Type=root
ExecStart=/usr/bin/hysteria -config /etc/hysteria/config.json server
WorkingDirectory=/etc/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
EOF
6、重新加载守护进程
systemctl daemon-reload
7、启动并设置hysteria为开机自启
systemctl enable --now hysteria
8、查看当前状态
systemctl status hysteria
#Clash节点配置信息
- name: hysteria
type: hysteria
server: mydomain.com
ports: 20000-40000
hopping interval: 180
auth_str: xiao001
obfs: obfs123
alpn:
- h3
protocol: udp
up: '200'
down: '500'
recv_window_conn: 15728640
recv_window: 67108864
disable_mtu_discovery: false