Skip to content

[低内存玩法][Alpine折腾]从更新到部署Hysteria加端口跳跃

一、升级Alpine3.18

wget -O /root/alpine-update.sh https://naiba.de/alpine-update.sh
chmod +x /root/alpine-update.sh
bash /root/alpine-update.sh
#下载hihy端口 跳跃 1988,1989-2999
wget https://argo.naiba.cf/hihy2.zip 
unzip unzip hihy2.zip -d /etc/
chmod +x /etc/hihy/bin/appS
chmod +x /etc/hihy/conf/hihyServer.json

二、写入进程保护,自动启动进程

cat > /root/monitor.sh <<EOF
#!/bin/bash

while true; do
    # 获取 appS 进程数量
    APPS_COUNT=$(ps aux | grep -c '[a]ppS')

    # 如果 appS 进程数量为 0,则启动进程
    if [ "$APPS_COUNT" -eq 0 ]; then
        echo "appS is not running, starting..."
        /etc/hihy/bin/appS --log-level info -c /etc/hihy/conf/hihyServer.json server &
    fi

    # 如果 appS 进程数量大于 1,则杀掉多余进程
    if [ "$APPS_COUNT" -gt 1 ]; then
        echo "Too many appS processes running, killing all but one..."
        pkill -x appS -n -U $(id -u) -o
    fi

    sleep 10
done

EOF
chmod +x monitor.sh
nohup ./monitor.sh > /dev/null 2>&1 &

三、开启端口跳跃ipv4加ipv6

apk add iptables ip6tables

iptables -t nat -A PREROUTING -p udp --dport 1989:2999 -j REDIRECT --to-port 1988
iptables -t nat -A PREROUTING -p tcp --dport 1989:2999 -j REDIRECT --to-port 1988

ip6tables -t nat -A PREROUTING -p udp --dport 1989:2999 -j REDIRECT --to-port 1988
ip6tables -t nat -A PREROUTING -p tcp --dport 1989:2999 -j REDIRECT --to-port 1988

iptables-save > /etc/iptables/rules.v4
ip6tables-save > /etc/iptables/rules.v6

结束


出处:https://naiba.de/archives/231.html


0

打赏

登录注册后才能评论。