[GUIDE] USB Reverse Tethering - New method - All PC operating systems

Search This thread
Jul 9, 2014
6
0
33
Delhi
Reverse tethering script

I was too lazy to unlock my phone and enable tethering every time... so i wrote a little script that performs the entire setting in a go....
Code:
#!/bin/bash
adb shell su -c service call connectivity 34 i32 1
sleep 5s
echo "tethering turned on"
adb shell su -c netcfg rndis0 dhcp
adb shell su -c ifconfig rndis0 10.42.0.2 netmask 255.255.255.0
adb shell su -c route add default gw 10.42.0.1 dev rndis0
adb shell su -c busybox route add default gw 10.42.0.1 dev rndis0
adb shell su -c ifconfig rmnet0 0.0.0.0
echo "reverse tethering enabled"
 

sudhingr8

Member
Jul 28, 2013
7
0
Kerala
www.chordzone.org
Cannot find USB Connection

Hi, I am using Micromax Canvas A116. I have installed SamFlare v6 as well.
I have enabled USB debugging and USB internet in my phone. But when I check the device manager in my windows 7 32bit, I cannot find the USB Connection. Therefore I cannot choose it as the selection in the network connections.

Can somebody please help me out? What am I doing wrong?
 

legend1

New member
Jul 29, 2008
1
0
USB tethering option says:
No USB device connected
While phone is connected with PC via usb cable.

How can I enable it?

--------------------------------------------------------------------------------------------
Samsung Galaxy S Advance Rooted JellyBean 4.1.2
Windows 7 Home Basic
 

Shivam_s

New member
Jul 24, 2014
3
0
Many many Thanks

I was searching around to share my Window's Internet connection via usb to my Android ,and i thank you that you wrote this article .Only difficulty i encountered is to how to root my Android ,because i was unable to run any commands in android .So i specifically search for my device and found an app Framaroot ,I run it and now i was able to run commands which you mentioned above and Wow! ,i was accessing google on my Android.
Thank you.

---------- Post added at 05:40 PM ---------- Previous post was at 05:24 PM ----------

Hi, I am using Micromax Canvas A116. I have installed SamFlare v6 as well.
I have enabled USB debugging and USB internet in my phone. But when I check the device manager in my windows 7 32bit, I cannot find the USB Connection. Therefore I cannot choose it as the selection in the network connections.

Can somebody please help me out? What am I doing wrong?

Hello ! When you first connect you Android device and turn on USB tethering ,(don't turn on the USB storage, as far as i know you should turn it off because my device showed error that you have to turn off the USB storage tio use USB tethering )In my device there is an option "USB Internet" when i checked, it installed RNDIS driver ,if RNDIS is installed or not ,you can check it in Network and Sharing center >Change adapter settings.Then you have to Root your android phone to run the commands.Search for root software for your phone .Run Android terminal emulator and run the commands which are mentioned above .It will work .If not ,we are here to help you.
 

hasanbasri_93

Member
Oct 12, 2012
8
0
Bogor
Awesome ...

Introduction
This guide is intended to help you share Internet connection from your PC to your Android smartphone/tablet via USB cable. This technique is called USB reverse tethering. It is different from USB tethering in which you share Internet from your Android to your PC. There are many reasons why you need this technique working:
- You don't have mobile/wifi network and your PC doesn't have any wifi adapter
- You can't do tethering over wifi, for example, your company doesn't let you make any hotspot at work
- You don't want to spend money for a mobile plan, and you want a more stable and faster Internet connection than wifi
- You don't want your PC and your Android to become too hot because of wifi
- You want your Android charged while in use
...

You have searched and found some applications/tools/solutions, you followed exactly their instructions but finally you were frustrated because they didn't work, here I come for a new method. :D
This method works following Internet connection sharing basics. If your Android device is able to do USB tethering, you will be able to do USB reserve tethering with this method!
Advantages:
- No additional software on your PC. Leave no trace on your PC. Imagine when you are at work and you have to install some crappy "toy" application on your PC to estiblish a tunnel connection for this task.
- Works with Windows, Linux and Mac OS X
- You know what you do. Who knows what the "easy-to-use" tools do when they fail to help you?
Disadvantages:
- You have to type some commands on your Android.
If you are ready, let's start!

Requirements:
- Rooted Android device with "USB tethering" capability. Check in Android Settings - Wireless & networks - Tethering & portable hotspot. Many stock ROMs disable this capability. You must enable it somehow (root your Android and use an application to enable or replace the stock ROM). CyanogenMod ROMs always have this capability. The important thing to remember is when you connect your Android and enable "USB tethering", it appears as a USB network adapter, not a mass storage or media device.
- PC with a working Internet connection.
- USB cable to connect your Android to your PC.
- Terminal Emulator on your Android. If you don't want to type commands on your touchscreen with Terminal Emulator, you can use your PC keyboard to enter commands with "adb shell". adb is a part of Android SDK which is available for download from Google. To use adb, you need to enable "USB debugging" on your Android.
- Optional, BusyBox on your Android.

Step 1: Connect your Android to PC by USB cable and enable "USB tethering". You are still allowed to enable this option even when your 3g/wifi on your Android is off.
- If you are using Linux (Ubuntu), you don't need to install anything. NetworkManager applet will try to establish a connection on the new detected wired network device.
- If you are using Windows, Windows will automatically search Windows Update and install driver for you. You can skip Windows Update search and install manually an already included driver from Microsoft. In Install Driver window, click Browse My Computer, then Let me pick..., select Network Adapters, uncheck Show Compatible Hardware, look at "Microsoft Corporation" at the left column, and choose Remote NDIS Compatible Device from the right column. You can install or update a driver from Device Manager in Windows.
- If you are using Mac, install driver HoRNDIS. You will be notified about a new network interface. Click "Network Preferences" in the dialog to add it to known interfaces list. Then "Apply".
- If you are using Linux without GUI or NetworkManager, run these commands as root (or use sudo):
Code:
ifconfig usb0 10.42.0.1 netmask 255.255.255.0
(suppose that you don't have any other USB network adapter, otherwise, your Android may be usb1, usb2...)
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
Command for sudo will be:
Code:
sudo 'echo 1 > /proc/sys/net/ipv4/ip_forward'
Code:
iptables -t nat -F
iptables -t nat -A POSTROUTING -j MASQUERADE

Step 2:
- If you are using Linux, click on NetworkManager applet at the top right of your screen, select "Edit Connections...". In tab "Wired", choose the new established connection (be careful, not Ethernet LAN connection) and click "Edit..." In tab "IPv4 Settings", choose "Shared to other computers" as Method. Click "Save". NetworkManager will reestablish the connection and assign to your PC an IP address on this USB network connection, default: 10.42.0.1. Leave Internet connections (wired or wireless) untouched.
- If you are using Windows, open "Network Connections" in Control Panel. It is somewhat different from setup in Linux. Right click on an Internet connection that you have. I assume that you are using a desktop which doesn't have any wifi adapter, so right click on LAN Ethernet connection with Internet, and select "Properties". In tab "Sharing" (or "Advanced" for Windows XP), click "Allow other network users to connect through...", then select the USB connection in dropdown list below. Click OK. Windows will automatically setup your USB network connection and assign to it an IP address, default for Windows 7: 192.168.137.1, default for Windows XP: 192.168.0.1. You can see your Internet connection is now "Shared" and your USB connection is now "Unidentified network".
- If you are using Mac, open System Preferences - Network. If you installed HoRNDIS, you will see a new network interface corresponding to your USB connection. With "Using DHCP" as Configure Ipv4, it may be already connected. Go back to System Preferences, click "Sharing". Select "Internet Sharing". Choose the Internet connection (Ethernet or Airport...) in "Share your connection from", and choose USB connection interface in "To computers using". Mac will assign to your USB connection interface an IP address, default: 192.168.2.1.
- If you are using Linux without GUI or NetworkManager, you have done all PC setup in step 1.

Your PC setup is now done!

Step 3:
Open Terminal Emulator on your Android. Type:
Code:
su
The command prompt must change from $ to #. If it does not, check to ensure that your device is rooted properly.
[UPDATED]Type the following command in Terminal Emulator, the same for all PC operating systems:
Code:
netcfg rndis0 dhcp
The name for usb interface inside Android may vary. It is usually rndis0 or usb0. Type
Code:
busybox ifconfig
to identify the name.
Use OLD instructions below when automatical dhcp method does not work.

[OLD]Type these following commands in Terminal Emulator:
For Linux PC:
Code:
ifconfig rndis0 10.42.0.2 netmask 255.255.255.0
route add default gw 10.42.0.1 dev rndis0
If route fails, try:
Code:
busybox route add default gw 10.42.0.1 dev rndis0
For Windows PC, use the same above commands, replace 10.42.0.2 by 192.168.137.2 (192.168.0.2 for Windows XP), replace 10.42.0.1 by 192.168.137.1 (192.168.0.1 for Windows XP)
For Mac PC, replace 10.42.0.2 by 192.168.2.2, replace 10.42.0.1 by 192.168.2.1

Now you can close Terminal Emulator and start the browser for Internet.

Some applications (download in Google Play, GMail, Facebook...) don't recognize Internet connection. You can try this way (WARNING: NOT TESTED):
- Enable temporarily 3G connection on your Android
- Type:
Code:
ifconfig rmnet0 0.0.0.0
The name for 3G interface inside Android may vary: ppp0, rmnet0... Type
Code:
busybox ifconfig
to identify the name.
before ifconfig rmnet0 ... above.
This will make applications see your Internet connection via USB as 3G!

USB tethering settings on Android will be reverted automatically when you unplug USB cable. To revert back settings on PC, uncheck "Allow other network users to connect through..." on Windows, "Internet sharing" on Mac, change from "Shared to other computers" back to "Automatically (DHCP)", or simply delete USB connection from NetworkManager on Linux.


Veryy good,, fully work in my phone Sony Live With Walkan
 

raj90012000

Member
Oct 21, 2012
35
0
hi

See what I did on my s3 was simple.I am on 4.3 android and windows 7

1. Connect your phone to pc
2. enable usb thetring, my phone now shows as 'local area connection 3'
3. Then I share the internet with local area connection 3 in the 'local area connection'(default one)
4.I open emulator in the phone and type

su
netcfg rndis0 dhcp
route add default gw 10.42.0.1 dev rndis0


5. Then I go to the mobile network and create a new access point and in the apn I type 0.0.0.0
6. I select the new access point
8. I enable data connection
9. Then I type in the emulator ifconfig rmnet0 0.0.0.0

I am done and I get a speedy internet in my mobile

Let me know if any doubts


i got error action dhcp failed no such device
 

raman_

Senior Member
Nov 13, 2013
196
9
New Delhi
Pls help

Hi....Thanks for your valuable tutorial. Actually when I removed the usb cable, I am not able to connect my 3g connectivity. Is there something I have to do. Any help will be appreciated pls.

Thanks
 

raman_

Senior Member
Nov 13, 2013
196
9
New Delhi
I was too lazy to unlock my phone and enable tethering every time... so i wrote a little script that performs the entire setting in a go....
Code:
#!/bin/bash
adb shell su -c service call connectivity 34 i32 1
sleep 5s
echo "tethering turned on"
adb shell su -c netcfg rndis0 dhcp
adb shell su -c ifconfig rndis0 10.42.0.2 netmask 255.255.255.0
adb shell su -c route add default gw 10.42.0.1 dev rndis0
adb shell su -c busybox route add default gw 10.42.0.1 dev rndis0
adb shell su -c ifconfig rmnet0 0.0.0.0
echo "reverse tethering enabled"

Can u pls tell/ guide me as now a days we have option of connect your pc internet using USB. If we click that option and if still it doesnt work on the phone then what to do? All the drivers are installed.

Thanks
 

migui0401

Senior Member
Jul 30, 2013
231
223
Miami, Fl.
androidmatz.blogspot.com
I was using the app method and worked for me percetly on a 64 bits windows computer. Now i'm using a 32 bits windows 7 seven laptop. In the app it's says that ies correct, but when i open browser, looks like there isn't any data crossing over my connection. Help!
 

bergerkos

Member
Mar 18, 2008
31
0
OK, thanks for the howto.
Here are two problems related to this method (so it doesn't work on my tablet the way it's supposed to).
1. netcfg rndis0 dhcp -- this works, but keeps just for a little while, then it has to be rerun again to keep the connection alive.
2. on my tablet NO apps can use Internet with this connection. Apparently what's missing is domain name resolution and i don't know how it's done in Android.
However, command line apps do work -- when I supply the Internet address. How can that be handled?

EDIT: browsers don't work even if I supply the address instead of domain name.
 
Last edited:

Private.Indo

Senior Member
Jan 4, 2011
98
5
Quick question.
Everything fine when i'm using google dns 8.8.8.8,
but everything change when the network administrator nation attack,
they told me i need to change dns to default ip number (my pc ip) otherwise i'm unable connect to net.
Now i'm unable to use reverse tethering, i think is dns problem. cause i can connect to net using my pc, but my phone wont.

any idea?
 

bergerkos

Member
Mar 18, 2008
31
0
Well in my case setting DNS to whatever doesn't help.. On the bright sight of it, though, I know now how to set DNS in Android... Command line utilities work fine, damn browsers keep looking for WiFi connection. Yea, I think Richard Stallman is right about "non-free", after all.
 

migui0401

Senior Member
Jul 30, 2013
231
223
Miami, Fl.
androidmatz.blogspot.com
See what I did on my s3 was simple.I am on 4.3 android and windows 7

1. Connect your phone to pc
2. enable usb thetring, my phone now shows as 'local area connection 3'
3. Then I share the internet with local area connection 3 in the 'local area connection'(default one)
4.I open emulator in the phone and type

su
netcfg rndis0 dhcp
route add default gw 10.42.0.1 dev rndis0


5. Then I go to the mobile network and create a new access point and in the apn I type 0.0.0.0
6. I select the new access point
8. I enable data connection
9. Then I type in the emulator ifconfig rmnet0 0.0.0.0

I am done and I get a speedy internet in my mobile

Let me know if any doubts
Could you simulate or emulate 3g connection? I couldn't :/ Help!!!!!
 

sgajjala

Member
Dec 7, 2012
26
0
While sharing the connection in my Office network I get this error message...

Internet connection sharing cannot be enabled. A LAN connection is already configured with the IP address that is required for automatic IP Addressing.

Can someone help me to resolve this?
 

sudhingr8

Member
Jul 28, 2013
7
0
Kerala
www.chordzone.org
Sharing On Wifi

This method and the apps work exceptionally great on my Canvas HD A116.
However, I would like to know how to share this internet connection through my phone to other phones.
I have tried using wifi tethering hotspot in my phone to provide the connection as a hotspot. But the other phone are not being able to browser anything. Is there a solution for this problem? Other than buying external hardware?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 194
    Introduction
    This guide is intended to help you share Internet connection from your PC to your Android smartphone/tablet via USB cable. This technique is called USB reverse tethering. It is different from USB tethering in which you share Internet from your Android to your PC. There are many reasons why you need this technique working:
    - You don't have mobile/wifi network and your PC doesn't have any wifi adapter
    - You can't do tethering over wifi, for example, your company doesn't let you make any hotspot at work
    - You don't want to spend money for a mobile plan, and you want a more stable and faster Internet connection than wifi
    - You don't want your PC and your Android to become too hot because of wifi
    - You want your Android charged while in use
    ...

    You have searched and found some applications/tools/solutions, you followed exactly their instructions but finally you were frustrated because they didn't work, here I come for a new method. :D
    This method works following Internet connection sharing basics. If your Android device is able to do USB tethering, you will be able to do USB reserve tethering with this method!
    Advantages:
    - No additional software on your PC. Leave no trace on your PC. Imagine when you are at work and you have to install some crappy "toy" application on your PC to estiblish a tunnel connection for this task.
    - Works with Windows, Linux and Mac OS X
    - You know what you do. Who knows what the "easy-to-use" tools do when they fail to help you?
    Disadvantages:
    - You have to type some commands on your Android.
    If you are ready, let's start!

    Requirements:
    - Rooted Android device with "USB tethering" capability. Check in Android Settings - Wireless & networks - Tethering & portable hotspot. Many stock ROMs disable this capability. You must enable it somehow (root your Android and use an application to enable or replace the stock ROM). CyanogenMod ROMs always have this capability. The important thing to remember is when you connect your Android and enable "USB tethering", it appears as a USB network adapter, not a mass storage or media device.
    - PC with a working Internet connection.
    - USB cable to connect your Android to your PC.
    - Terminal Emulator on your Android. If you don't want to type commands on your touchscreen with Terminal Emulator, you can use your PC keyboard to enter commands with "adb shell". adb is a part of Android SDK which is available for download from Google. To use adb, you need to enable "USB debugging" on your Android.
    - Optional, BusyBox on your Android.

    Step 1: Connect your Android to PC by USB cable and enable "USB tethering". You are still allowed to enable this option even when your 3g/wifi on your Android is off.
    - If you are using Linux (Ubuntu), you don't need to install anything. NetworkManager applet will try to establish a connection on the new detected wired network device.
    - If you are using Windows, Windows will automatically search Windows Update and install driver for you. You can skip Windows Update search and install manually an already included driver from Microsoft. In Install Driver window, click Browse My Computer, then Let me pick..., select Network Adapters, uncheck Show Compatible Hardware, look at "Microsoft Corporation" at the left column, and choose Remote NDIS Compatible Device from the right column. You can install or update a driver from Device Manager in Windows.
    - If you are using Mac, install driver HoRNDIS. You will be notified about a new network interface. Click "Network Preferences" in the dialog to add it to known interfaces list. Then "Apply".
    - If you are using Linux without GUI or NetworkManager, run these commands as root (or use sudo):
    Code:
    ifconfig usb0 10.42.0.1 netmask 255.255.255.0
    (suppose that you don't have any other USB network adapter, otherwise, your Android may be usb1, usb2...)
    Code:
    echo 1 > /proc/sys/net/ipv4/ip_forward
    Command for sudo will be:
    Code:
    sudo 'echo 1 > /proc/sys/net/ipv4/ip_forward'
    Code:
    iptables -t nat -F
    iptables -t nat -A POSTROUTING -j MASQUERADE

    Step 2:
    - If you are using Linux, click on NetworkManager applet at the top right of your screen, select "Edit Connections...". In tab "Wired", choose the new established connection (be careful, not Ethernet LAN connection) and click "Edit..." In tab "IPv4 Settings", choose "Shared to other computers" as Method. Click "Save". NetworkManager will reestablish the connection and assign to your PC an IP address on this USB network connection, default: 10.42.0.1. Leave Internet connections (wired or wireless) untouched.
    - If you are using Windows, open "Network Connections" in Control Panel. It is somewhat different from setup in Linux. Right click on an Internet connection that you have. I assume that you are using a desktop which doesn't have any wifi adapter, so right click on LAN Ethernet connection with Internet, and select "Properties". In tab "Sharing" (or "Advanced" for Windows XP), click "Allow other network users to connect through...", then select the USB connection in dropdown list below. Click OK. Windows will automatically setup your USB network connection and assign to it an IP address, default for Windows 7: 192.168.137.1, default for Windows XP: 192.168.0.1. You can see your Internet connection is now "Shared" and your USB connection is now "Unidentified network".
    - If you are using Mac, open System Preferences - Network. If you installed HoRNDIS, you will see a new network interface corresponding to your USB connection. With "Using DHCP" as Configure Ipv4, it may be already connected. Go back to System Preferences, click "Sharing". Select "Internet Sharing". Choose the Internet connection (Ethernet or Airport...) in "Share your connection from", and choose USB connection interface in "To computers using". Mac will assign to your USB connection interface an IP address, default: 192.168.2.1.
    - If you are using Linux without GUI or NetworkManager, you have done all PC setup in step 1.

    Your PC setup is now done!

    Step 3:
    Open Terminal Emulator on your Android. Type:
    Code:
    su
    The command prompt must change from $ to #. If it does not, check to ensure that your device is rooted properly.
    [UPDATED]Type the following command in Terminal Emulator, the same for all PC operating systems:
    Code:
    netcfg rndis0 dhcp
    The name for usb interface inside Android may vary. It is usually rndis0 or usb0. Type
    Code:
    busybox ifconfig
    to identify the name.
    Use OLD instructions below when automatical dhcp method does not work.

    [OLD]Type these following commands in Terminal Emulator:
    For Linux PC:
    Code:
    ifconfig rndis0 10.42.0.2 netmask 255.255.255.0
    route add default gw 10.42.0.1 dev rndis0
    If route fails, try:
    Code:
    busybox route add default gw 10.42.0.1 dev rndis0
    For Windows PC, use the same above commands, replace 10.42.0.2 by 192.168.137.2 (192.168.0.2 for Windows XP), replace 10.42.0.1 by 192.168.137.1 (192.168.0.1 for Windows XP)
    For Mac PC, replace 10.42.0.2 by 192.168.2.2, replace 10.42.0.1 by 192.168.2.1

    Now you can close Terminal Emulator and start the browser for Internet.

    Some applications (download in Google Play, GMail, Facebook...) don't recognize Internet connection. You can try this way (WARNING: NOT TESTED):
    - Enable temporarily 3G connection on your Android
    - Type:
    Code:
    ifconfig rmnet0 0.0.0.0
    The name for 3G interface inside Android may vary: ppp0, rmnet0... Type
    Code:
    busybox ifconfig
    to identify the name.
    before ifconfig rmnet0 ... above.
    This will make applications see your Internet connection via USB as 3G!

    USB tethering settings on Android will be reverted automatically when you unplug USB cable. To revert back settings on PC, uncheck "Allow other network users to connect through..." on Windows, "Internet sharing" on Mac, change from "Shared to other computers" back to "Automatically (DHCP)", or simply delete USB connection from NetworkManager on Linux.
    10
    Script update

    [05/09/2015 : script update] : if looking for a cleaner script it is the one I'm using today, with dhcp options in the header to disable the non required dhcp server of dnsmasq, this the script posted in this ticket: https://code.google.com/p/android/issues/detail?id=99034 or this mirror http://pastebin.com/snS9erAP also included in this post now


    The method to reverse tether shown by the original poster only works for Android 4.4.4, if you need one working method for Android 4.4.4, 5.0.1 and higher you need to run you own dnsmasq instance, to do so follow the instructions below

    I have explained the method in different previous posts in this thread but in this post I recapitulates all you have to do (close to nothing to do once all is set)

    Since my latest posts in this thread, I have updated the script to export the variables into environment variable in case you need to change dns, ip or anything, or download it if you are not familiar in doing UNIX line ending scripts (attached a zip with all the scripts I'm using to this post)

    Code:
    IP=192.168.137.101                      # 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, 255.255.255.255 = 32 | 255.255.255.0 = 24 | 255.255.0.0 = 16 | 255.0.0.0 = 8)
    GATEWAY=192.168.137.1           # gateway of the rndis interface (main route, if using Windows Internet Connection Sharing usually set to 192.168.137.1, or your home internet box if using a Network Bridge like 192.168.1.1)
    DNS1=8.8.8.8                            # domain name resolution (google public dns1 = 8.8.8.8, but should be faster to your home internet box like 192.168.1.1)
    DNS2=8.8.4.4                            # domain name resolution (google public dns2 = 8.8.4.4)
    
    USE_DHCP=0                                      # loads the DHCP server option of dnsmasq (not required, defaults to 0)
    DHCP_FROM=192.168.137.10        # ignored if USE_DHCP=0
    DHCP_TO=192.168.137.90          # ignored if USE_DHCP=0
    
    # ! NO NEED TO EDIT AFTER THIS LINE ! Tested working on Android 4.4.4 and 5.x
    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 0.0.0.0 netmask 0.0.0.0 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 net.rndis0.gw $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
    else
            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
    fi

    How to use these scripts
    1) Unpack and copy all the .sh script to the Smartphone shared folder in Windows, for example with a Nexus 5, place files in This PC\Nexus 5 base folder where others folders are showing like DCIM etc.., they will point to /sdcard/ in your phone
    2) In a Terminal of your phone, type: su (to get root privilege) and make sure your phone's internet access are disabled, Wifi off, Phone internet off. (the Terminal I'm using in screenshot is Terminal Emulator by Jack Paleviche, very good one)
    3) In the Terminal type: su -c 'sh /sdcard/rn.sh' (In the background this will enable the rndis interface in Windows, set the ip of rndis0 in the phone to 192.168.137.101, gateway to 192.168.137.1, set google's public dns to the properties and to dnsmasq, NO ERRORS SHOULD BE SHOWN, ONLY ECHO COMMANDS AS SHOWN IN SCREENSHOT, if you see errors you need to reset the changes with su -c 'sh /sdcard/rnoff.sh' and restarts from step 3 until you fix, or ask here if you are lost how to fix)
    4) In Windows uncheck/recheck Internet Connection Sharing on the Internet card (this reenable Internet Connection Sharing sometimes buggy after unpluggin phone and restarting the computer, this should also automatically assign the ip 192.168.137.1 and netmask 255.255.255.0 to the RNDIS interface in Windows, if in your case it is not showing as 137.1 but another IP you will need to update the gateway of the script to point to this IP, or you can also set this ip manually to a new one you will remember 192.168.137.2 and update the gateway in the scripts to point to this new ip 137.2, but the ultimate best approach is to fix why Windows does not automatically attrib 137.1 to it because you will need to disable/enable again the ICS frequently so it is better to have it pointing to its default address by default in case one day it does no more assign your custom IP.

    From here you should get Internet Access in Google Chrome and Speedtest.net App
    But to get access in 100% of the App you need to run the Wifi interface set to the IP of the RNDIS interface

    5) In the Phone enable manually Wifi, connect your home wifi access point in STATIC IP mode, for example here I do IP: 192.168.137.102, GATEWAY: 192.168.137.1 DNS1:8.8.8.8 DNS2:8.8.4.4
    6) On Android 4.4.4 you should be all set, on Android 5.0 sometimes the route is not set properly, in this case you can use my wifi scripts
    7) su -c 'sh /sdcard/wloff.sh' once to reset the wlan0 interface and shortly after su -c 'sh /sdcard/wl.sh' to set again wifi on again with the same settings (if you get an error after setting the route, just execute wloff.sh/wl.sh again this will pass)

    Some useful commands
    netcfg (see network cards running state, the ip and netmask of each one)
    busybox route -n (see network card routes/gateways)
    vi (file edition)
    su (alone in the terminal editor to get root privilege directly in the terminal)
    su -c 'sh /path/toscript.sh' (run a script as root)
    mount -o remount, RW /system (allows writing in system files for example for adding your custom aliases to the /etc/mkshrc file, it reverts to read only after a reboot)

    Some custom aliases example (to add in /etc/mkshrc to type things fastly once you are all set, "rn" will start reverse tether, "rnoff" will stop, etc...)
    alias rn='sh /sdcard/rn.sh'
    alias rnoff='sh /sdcard/rnoff.sh'
    alias wl='sh /sdcard/wl.sh'
    alias wloff='sh /sdcard/wloff.sh'
    alias rm='sh /sdcard/rm.sh'
    alias rmoff='sh /sdcard/rmoff.sh'
    alias ro='busybox route -n'
    alias pi='ping google.com'
    alias piip='ping 8.8.8.8'
    alias pirn='ping -I rndis0 google.com'
    alias wr='mount -o remount, RW /system'
    alias n='netcfg'

    Screenshot of all the procedure under Android 5.0, RNDIS + WIFI
    8
    For anyone struggling to do this, here's a one-click tool to do this:
    https://github.com/Genymobile/gnirehtet/blob/master/README.md#run-simple

    Just install ADB on computer, enable ADB on Android device, and just run the executable/binary from CMD/terminal.
    As simple as that..!!

    No root required!
    3
    Awesome tutorial! I moved to a new office at work and lost my 4G signal, they don't have new WiFi AP's up yet, and Edge sucks. I figured out the first half but couldn't figure out how to take a DHCP address on the USB connection on my phone. That worked perfectly and if you leave WiFi or mobile data on then ifconfig it to 0.0.0.0 Gmail et. al. work fine as well. Combined with my Open VPN bridged tunnel to my home network this is a great system for getting a connection away from wireless signals.
    3
    If it can be interesting to someone I wrote a short free guide for non-rooted devices that works with android 5+ and a linux pc. Visit salutepc.it --> tips or click here (for more details but only in italian language (for now) see here). EDIT: I wrote another guide for USB Reverse Tethering No Root No ADB Android (all versions) & Linux that should work for all versions of Android (tested on Android 4.2+). It only needs the (built-in) USB tethering function of Android and "OpenVPN for Android" app.

    I have adapted the "quick mode guide" for Windows users here --> USB Reverse Tethering No Root No ADB Android (all versions) & Windows 10.

    Update: video on https://youtu.be/tr1hm01a-Ik