Skip to content

Instantly share code, notes, and snippets.

@yuguorui
Created December 11, 2018 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuguorui/be953bef1311c5fb91dfb0b2b501a3d8 to your computer and use it in GitHub Desktop.
Save yuguorui/be953bef1311c5fb91dfb0b2b501a3d8 to your computer and use it in GitHub Desktop.
设置透明代理
#!/bin/bash
VPS_IP=$(getent hosts www.ygo-note.com|awk '{print $1}')
iptables -t nat -N SHADOWSOCKS
# 在 nat 表中创建新链
iptables -t nat -A SHADOWSOCKS -d ${VPS_IP} -j RETURN
# 123.456.789.111 是 ss 代理服务器的 ip, 如果你只有一个 ss服务器的 ip,却能选择不同端口,就设置此条
iptables -t nat -A SHADOWSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 240.0.0.0/4 -j RETURN
iptables -t nat -A SHADOWSOCKS -p tcp -j REDIRECT --to-ports 8388
# 7777 是 ss-redir 的监听端口,ss-local 和 ss-redir 的监听端口不同,配置文件不同
# iptables -t nat -I PREROUTING -p tcp -j SHADOWSOCKS
# 在 PREROUTING 链前插入 SHADOWSOCKS 链,使其生效,这里是OUTPUT链,以便处理本机
iptables -t nat -I OUTPUT -p tcp -j SHADOWSOCKS
ss-tunnel -s ${VPS_IP} -p 10057 -m rc4-md5 -k 你猜? -b 127.0.0.52 -l 53 -L 8.8.8.8:53
systemctl stop systemd-resolved.service
# 设置本机的dns为127.0.0.52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment