Skip to content

Instantly share code, notes, and snippets.

@salehjg
Last active January 3, 2023 22:53
Show Gist options
  • Save salehjg/b706b254249f2fd290d68d4ffd9f5bbc to your computer and use it in GitHub Desktop.
Save salehjg/b706b254249f2fd290d68d4ffd9f5bbc to your computer and use it in GitHub Desktop.
An ADB script to share the VPN on an android device with its hotspot USB/WIFI
echo "RUN AS ROOT ON THE ANDROID DEVICE (TERMUX: SU: NEXT LINE)"
ip rule show | grep 'iif rndis0 lookup tun0' || ip rule add from all iif rndis0 lookup tun0 pref 17999; iptables -n -v -L natctrl_FORWARD | grep 'ACCEPT all -- rndis0 tun0' || iptables -I natctrl_FORWARD 4 -i rndis0 -o tun0 -j ACCEPT; iptables -n -v -L natctrl_FORWARD | grep 'ACCEPT all -- tun0 rndis0' || iptables -I natctrl_FORWARD 4 -i tun0 -o rndis0 -m state --state RELATED,ESTABLISHED -j ACCEPT
#!/bin/bash
# Source: https://triffid-hunter.no-ip.info/misc-linux-scripts/home-bin/phone-route-takeover
adb shell "service call connectivity 34 i32 1 s16 text"
sleep 1
adb shell "su - -c \"ip rule show | grep 'iif rndis0 lookup tun0' || ip rule add from all iif rndis0 lookup tun0 pref 17999; iptables -n -v -L natctrl_FORWARD | grep 'ACCEPT all -- rndis0 tun0' || iptables -I natctrl_FORWARD 4 -i rndis0 -o tun0 -j ACCEPT; iptables -n -v -L natctrl_FORWARD | grep 'ACCEPT all -- tun0 rndis0' || iptables -I natctrl_FORWARD 4 -i tun0 -o rndis0 -m state --state RELATED,ESTABLISHED -j ACCEPT\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment