脚本笔记8/27/2026

vtun.sh

来源文件:vtun.sh
已自动脱敏 10 处敏感信息。

bash
wget https://github.com/net-byte/vtun/releases/download/v1.7.0/vtun-linux-amd64
chmod +x vtun-linux-amd64
apt install net-tools
pm2 start ./vtun-linux-amd64 -- -S -l :8080 -p ws -path /wplogin -c [REDACTED_IP]/24 -k asdfasdf110 -v


vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding=1
sysctl -p /etc/sysctl.conf

iptables -t nat -A POSTROUTING -o ens5 -j MASQUERADE
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
iptables -A INPUT -i ens5 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT

iptables -A FORWARD -j ACCEPT



wget https://github.com/net-byte/vtun/releases/download/v1.7.0/vtun-linux-amd64
pm2 start ./vtun-linux-amd64 -- -s [REDACTED_IP]:1080 -p ws -path /wplogin -c [REDACTED_IP]/24 -k asdfasdf110 -g -v


./vtun-linux-amd64 -s [REDACTED_IP]:16000 -c [REDACTED_IP]/24 -k asdfasdf110 -g




sudo apt update
sudo apt install nodejs  -y
sudo apt install npm  -y
npm install pm2 -g
sudo apt-get -y install iptables-persistent
apt install net-tools


mkdir certs
cd certs
wget https://raw.githubusercontent.com/simon4545/vtun/master/certs/server.key
wget https://raw.githubusercontent.com/simon4545/vtun/master/certs/server.pem

wget https://filobj.oss-cn-hangzhou.aliyuncs.com/vtun-linux-amd64
chmod +x vtun-linux-amd64
systemctl enable netfilter-persistent.service
pm2 start ./vtun-linux-amd64 -- -S -l :16000 -obfs -p ws -path /wplogin -c [REDACTED_IP]/24 -k asdfasdf110 -v
pm2 save
pm2 startup
echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf
sysctl -p
echo "1"> /proc/sys/net/ipv4/ip_forward

eth=$(ls /sys/class/net | awk '/^e/{print}')

iptables -t nat -A POSTROUTING -o $eth -j MASQUERADE
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
iptables -A INPUT -i $eth -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT

iptables -A FORWARD -j ACCEPT

port_forward(){
    eth=$(ls /sys/class/net | awk '/^e/{print}')
    interfaceip=$(ifconfig $eth | awk -F ' *|:' '/inet /{print $3}')
        # 设置端口转发
        iptables -t nat -I PREROUTING -d $interfaceip -p tcp -m multiport ! --dports 22,1080,16000 -j DNAT --to-destination [REDACTED_IP]
        iptables -t nat -I PREROUTING -d $interfaceip -p udp -m multiport ! --dports 22,1080,16000 -j DNAT --to-destination [REDACTED_IP]
        iptables -t nat -I POSTROUTING -s [REDACTED_IP] -j SNAT --to-source $interfaceip
        netfilter-persistent  save
}



apt update
apt install net-tools curl
wget https://filobj.oss-cn-hangzhou.aliyuncs.com/vtun-linux-amd64
chmod +x vtun-linux-amd64
apt install -y nodejs
npm i -g pm2

start_menu(){
    clear
    read -p "请输入远程公网IP:" remote
    pm2 start ./vtun-linux-amd64 -- -s $remote:16000 -obfs -p ws -path /wplogin -c [REDACTED_IP]/24 -k asdfasdf110 -g
    pm2 save
    pm2 startup
}

start_menu