USB Reverse Tethering on Android 5/6

In order to set up reverse tethering via on Android 5.1 in combination with Windows,
one first has to enable “USB Tethering” through the GUI of the Android device. Windows then should install the necessary driver for a “Remote NDIS Device”. When sharing the internet connection to that RNDIS device via ICS, Windows assigns the default IP to that interface.

The steps explained in detail:

1) open a terminal on the device via ADB by entering:

adb shell

2) elevate privileges (required for network configuration):

shell@shamu:/ $ su

3) configure the IP address of interface rndis0:

ifconfig rndis0

4) define some DNS servers – for example Google’s public DNS:

setprop net.dns0
setprop net.dns1

5) define a default gateway for interface rndis0:

busybox route add default gw rndis0

6) optional: bring up the interface:

netcfg rndis0 up

In case Windows will recognize it as a “Public Network”, you may want to demilitarize a little. For example, when able to ping the gateway with a 100% packet-loss, most likely ICMPv4 echo request isn’t permitted. One can even disable the firewall for that interface altogether, while only using it in the reverse direction.

In order to get the packets forwarded to the internet, one has to enable routing on Windows (please see the link to the KB below). After that a reboot is required, in order to reload the Windows registry. In case the default “ping” binary won’t work – “busybox ping” and “busybox traceroute” seem to work fine, while I still haven’t determined yet how to fix SE Linux address/port labeling on Android. Unless the Xposed Framework will be ported to API v22 there probably is little one can do to get the “Connectivity Hack” module working, in order to make the OS pretend the WiFi interface would be online. Hope this helps – because programming while being microwaved isn’t too healthy.

In order to disable system update notifications (for rooted devices in general):

Settings > Application Manager > All > Google Services Framework, uncheck "Show notifications" there.

Update: As of Android Marshmallow 6.0.1…
there is RNDIS available as USB configuration in the developer options:

Android 6.0.1 Developer Options

RNDIS is now available as USB configuration option

External Links:
Xposed Module Repository (not yet compatible)
Microsoft KB99686 – Enabling IP Routing