Skip to content

Instantly share code, notes, and snippets.

@Demandrel
Created February 24, 2026 10:45
Show Gist options
  • Select an option

  • Save Demandrel/9fe971e1695d87f94ed9ee751eab059f to your computer and use it in GitHub Desktop.

Select an option

Save Demandrel/9fe971e1695d87f94ed9ee751eab059f to your computer and use it in GitHub Desktop.
SHH Script
# === EDIT THESE VALUES ===
PROXY_IP="YOUR_PROXY_IP"
PROXY_PORT="YOUR_PROXY_PORT"
PROXY_USER="YOUR_USERNAME"
PROXY_PASS="YOUR_PASSWORD"
IPHONE_NAME="iPhone1"
IPHONE_MAC="AA:BB:CC:DD:EE:FF"
IPHONE_IP="192.168.8.201"
# === STOP EDITING ===
# Redsocks config
cat > /etc/redsocks.conf << EOF
base {
log_debug = off;
log_info = on;
log = "syslog:daemon";
daemon = on;
redirector = iptables;
redsocks_conn_max = 1024;
}
redsocks {
local_ip = 0.0.0.0;
local_port = 12081;
ip =$PROXY_IP;
port =$PROXY_PORT;
type = socks5;
login = "$PROXY_USER";
password = "$PROXY_PASS";
}
EOF
# Reserve iPhone IP
uci add dhcp host
uci set dhcp.@host[-1].name="$IPHONE_NAME"
uci set dhcp.@host[-1].mac="$IPHONE_MAC"
uci set dhcp.@host[-1].ip="$IPHONE_IP"
uci commit dhcp
/etc/init.d/dnsmasq restart
# Startup script (survives reboots)
cat > /etc/init.d/redsocks-custom << INITEOF
#!/bin/sh /etc/rc.common
START=99
start() {
redsocks -c /etc/redsocks.conf
sleep 1
iptables -t nat -N REDSOCKS 2>/dev/null
iptables -t nat -F REDSOCKS
iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A REDSOCKS -d$PROXY_IP -j RETURN
iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 12081
iptables -t nat -I PREROUTING 1 -s$IPHONE_IP -p tcp -j REDSOCKS
}
stop() {
killall redsocks 2>/dev/null
iptables -t nat -D PREROUTING -s$IPHONE_IP -p tcp -j REDSOCKS 2>/dev/null
iptables -t nat -F REDSOCKS 2>/dev/null
iptables -t nat -X REDSOCKS 2>/dev/null
}
INITEOF
chmod +x /etc/init.d/redsocks-custom
/etc/init.d/redsocks-custom enable
/etc/init.d/redsocks-custom start
echo ""
echo "=== SETUP COMPLETE ==="
echo "Now factory reset$IPHONE_NAME and connect it to WiFi."
echo "Test: https://ifconfig.me"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment