Android USB Network Connection

Share on:

It's possible to create a network connection between an Android phone and your computer over USB. Also some later Android versions have this option in the settings menu. This method uses the RNDIS protocol on a a jail broken phone. This information is available elsewhere but it's somewhat hard to find. So I am reposting here.

echo 0 > /sys/class/android_usb/android0/enable
echo 18d1 > /sys/class/android_usb/android0/idVendor
echo 4e23 > /sys/class/android_usb/android0/idProduct
echo rndis > /sys/class/android_usb/android0/functions
echo 224 > /sys/class/android_usb/android0/bDeviceClass
echo 1 > /sys/class/android_usb/android0/enable
setprop sys.usb.state rndis
netcfg rndis0 up
ifconfig rndis0 10.100.100.1 netmask 255.255.255.0

 This is the code that works on my Samsung Galaxy Nexus (yes a very old phone) running Android 4.3. I imagine the process is similar on other phones, but maybe the Vendor/Product codes need to change.

After the above script is run on your phone just connect it's USB cable to your computer. On Linux the interface will show up as for example usb0. I think the interface is provided by the rndis_host, cdc_ether and usbnet kernel modules which hopefully load automatically. Just configure it with a corresponding address on the subnet and you have a IP over USB to your phone.

Useful for sharing your phones 3g/Wifi or app development/hacking.