Skip to content

Reverse Tethering

CHEF-KOCH edited this page Jun 4, 2016 · 10 revisions
# Tested working on Android 4.4.4 up to 5.x
# Original posted over here:
# All credits belongs to: class101
# This also requires the Xposed framework to be installed:
# Download the entire package:!QQ0zFK6I!GwnGj-zF7JnuMt9r0FEhq9NSX8ktX9Urvffv5mSfTlk
# App:

# Ensure in AFWall+ that the incoming LAN option was checked together with root and LAN (for DHCP).
# Nexus 6 needs -> adb shell: settings put global tether_dun_required 0

IP=			# ip of the rndis interface (if using Windows Internet Connection Sharing usually set to an ip in the 192.168.137.x range, or your home network range if using a Network Bridge like 192.168.1.x)
NETMASK=24					# netmask of the rndis interface (if you don't know this setting set it to 24, = 32 | = 24 | = 16 | = 8)
GATEWAY=		# gateway of the rndis interface (main route, if using Windows Internet Connection Sharing usually set to, or your home internet box if using a Network Bridge like
DNS1=				# domain name resolution (google public dns1 =, but should be faster to your home internet box like
DNS2=				# domain name resolution (google public dns2 =

USE_DHCP=0					# loads the DHCP server option of dnsmasq (not required, defaults to 0)
DHCP_FROM=	# ignored if USE_DHCP=0
DHCP_TO=		# ignored if USE_DHCP=0

# Not to need to edited after these lines  
echo -- rndis0: setting usb mode to rndis --
setprop sys.usb.config 'rndis'
echo -- rndis0: adding ip rule --
ip rule add from all lookup main
echo -- rndis0: flushing interface --
ip addr flush dev rndis0
echo -- rndis0: setting ip --
ip addr add $IP/$NETMASK dev rndis0
echo -- rndis0: starting the interface --
ip link set rndis0 up
echo -- rndis0: setting route --
#ip route add default via ${GATEWAY} dev rndis0
busybox route add -net netmask gw $GATEWAY dev rndis0
#echo -- rndis0: (optional) setting iptables --
#iptables -t nat -I POSTROUTING 1 -o rndis0 -j MASQUERADE
#echo -- rndis0: (optional) setting ip_forward --
#echo 1 > /proc/sys/net/ipv4/ip_forward
echo -- rndis0: setting properties --
setprop net.dns1 $DNS1
setprop net.dns2 $DNS2
setprop net.rndis0.dns1 $DNS1
setprop net.rndis0.dns2 $DNS2
setprop $GATEWAY
setprop net.rndis0.gateway $GATEWAY
killall dnsmasq &> /dev/null
if [ $USE_DHCP = 1 ]; then
	echo -- rndis0: starting dnsmasq with dhcp --
	dnsmasq --no-poll --pid-file --interface=rndis0 --interface=wlan0 --interface=rmnet0 --bogus-priv --filterwin2k --no-resolv --server=${DNS1} --server=${DNS2} --cache-size=1000 --dhcp-range=${DHCP_FROM},${DHCP_TO} --dhcp-lease-max=253 --dhcp-authoritative --dhcp-leasefile=/cache/usb_tether_dnsmasq.leases < /dev/null
	echo -- rndis0: starting dnsmasq without dhcp --
	dnsmasq --no-poll --pid-file --interface=rndis0 --interface=wlan0 --interface=rmnet0 --bogus-priv --filterwin2k --no-resolv --server=${DNS1} --server=${DNS2} < /dev/null

Step 1 Step 2 Step 3

You can’t perform that action at this time.