Created
March 20, 2026 18:05
-
-
Save IsHacker003/08f61b713d0c44354dd91acdb656cf74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Detect tethering interface name on the phone (rndis0 or usb0) | |
| intf_cmd=$(adb shell "su -c 'if [ -e \"/sys/class/net/usb0\" ]; then echo \"Tethering interface: usb0\"; elif [ -e \"/sys/class/net/rndis0\" ]; then echo \"Tethering interface: rndis0\"; else echo "Unable to find tethering interface."; fi'") | |
| if [ "$intf_cmd" == "Tethering interface: usb0" ] | |
| then | |
| echo "$intf_cmd" | |
| intf="usb0" | |
| elif [ "$intf_cmd" == "Tethering interface: rndis0" ] | |
| then | |
| echo "$intf_cmd" | |
| intf="rndis0" | |
| else | |
| echo "$intf_cmd" | |
| exit 1 | |
| fi | |
| echo "NOTE: Make sure only ONE device is connected and USB debugging and USB tethering are enabled." | |
| read -n 1 -r -s -p $'Press enter to continue...\n' | |
| # Obtain prefix and link-local IPv6 address of the usb tethering interface | |
| a=$(adb shell su -c ip -6 addr | grep inet6 | awk -F '[ \t]+|/' '{print $3}' | grep -v ^::1 | grep -v ^fe80 | head -n 1 | cut -d: -f4) | |
| b=$(echo $(adb shell su -c ip -6 addr | grep inet6 | awk -F '[ \t]+|/' '{print $3}' | grep -v ^::1 | grep -v ^fe80 | head -n 1) | grep -o .*$a)"::" | |
| c=$b"aaaa" | |
| d=$(adb shell su -c ifconfig $intf | grep inet6 | awk -F '[ \t]+|/' '{print $4}') | |
| e=$(ifconfig | grep enx | awk '{print $1}' | sed -e 's/://g') | |
| echo "Prefix: $b" | |
| echo "Using IP: $c" | |
| echo "Link-local address of tethering interface: $d" | |
| # Add the IP and gateway to PC | |
| sudo ip -6 a add $c/128 dev $e | |
| sudo ip -6 r add default via $d dev $e | |
| # Enable IPv6 forwarding and Proxy NDP | |
| adb shell "su -c 'echo 1 > /proc/sys/net/ipv6/conf/all/forwarding'" | |
| adb shell "su -c 'echo 1 > /proc/sys/net/ipv6/conf/all/proxy_ndp'" | |
| # Add the IP on the phone | |
| adb shell "su -c ip neigh add proxy $c dev wlan0" | |
| adb shell "su -c ip -6 r add $c/128 dev $intf table wlan0" | |
| adb shell "su -c ip -6 r add $c/128 dev $intf table local_network" | |
| echo 'Done! Now you have IPv6 connectivity. You can test it with "ping ipv6.google.com".' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment