Android USB tethering

''Tethering means sharing the Internet connection of an Internet-capable mobile phone with other devices. This sharing can be offered over a wireless LAN (Wi-Fi), or over Bluetooth, or by physical connection using a cable'' (Tethering).

Our focus in this article will be the USB tethering.

Your Android mobile phone can behave as an external network interface usbN, connected via the USB infrastructure. The usbN interface is in turn connected to the mobile phone LAN, providing dhcp server, DNS server, gateway and so on.

That's how your mobile phone can provide an Internet connection to another device.

Android phones are already equipped to provide this functionality. Simply connect the USB cable and go to Settings -> Wireless settings -> Tethering -> Tethering USB.

What you need is some kernel and network configuration on the other side (e.g. your laptop).

Kernel configuration
You can either build the options in the kernel or leave them as module.

Tested Devices

 * Google Nexus One (Android 2.3.6 build GRK39F)
 * Google Nexus 4 (Android 4.3 build JWR66Y - uses rndis_host)
 * HTC One M7 (Sense 5.5, Android 4.3, Software number 3.62.401.1,HTC SDK API level 5.65 - I used rndis_host, cdc_ether and usbnet modules ONLY to get it to work)
 * LG P350 (Android 2.2.1 build FRG83)
 * LG E400 (Android 2.3.6 build GRK39F)
 * LG L7 P705 (Android 4.1.2 build JZO54K)
 * Motorola Defy (Android 2.3.7 Cyanogenmod 7)
 * Motorola Moto G 4G 2013 (1st Gen) (Android 5.1) -- needed rndis_host module -- User:mercuriete
 * Samsung Galaxy S i9000
 * Samsung Galaxy Nexus i9250 (Android 4.0.1 ITL41D)
 * Samsung Galaxy S2
 * Samsung Galaxy S3 (GT-I9300 Android 4.3 Stock Rom)
 * Sony Xperia Go (St27i Android 4.1.2 Stock Rom build no 6.2.A.1.100 -- needed rndis_host module for me - User:LordVan )
 * HTC Desire HD (Android 2.3.6 Stock Rom build and Android 4.4.4 (unofficial CyanogenMod 11) -- needed rndis_host module for both Roms)
 * Huawei Honor 4x (unofficial CyanogenMod 11 / Android 4.4.4, works great) -- needed rndis_host module AleiPhoenix (talk) 13:57, 3 July 2015 (UTC)
 * Samsung Galaxy S4 Mini Duos (GT-I9192, unofficial CyanogenMod 12.1 / Android 5.1) -- needed rndis_host module -- User:equaeghe

Testing
If you see usb0 (or whatever number you'll get) you are all set.

Connecting
Since the mobile phone LAN changes its addresses, you need a DHCP client to configure the usbN device.

If you are on a laptop, you probably have a DHCP client. If not, emerge.

Manually
Simply run dhcpcd after plug/mobile activation.

Permanent configuration
Edit your to have a permanent, automatic activation of the interface.

Once plugged in and activated on the mobile phone side, the usb0 will be up and configured.

Checks
Run the usual checks to verify your connection.

Advanced network settings
The DHCP is very quick, but the default settings don't give you as much freedom as you may want.

A possible scenario is that you are in a corporate, protected LAN context that doesn't give you the Internet connection but where you need to stay connected to have access to some Intranet resource.

Or maybe you have a free but limited connection (a public wifi allowing http only, an evil firewall, etc.). Since mobile connections could be expensive, you could want to save your money up using the tethering only when needed.

Here is a handful of examples about the DHCP usage.

If you want to limit the information set by DHPC, you can fine-tune its behaviour.

E.g.:

This will let your default gateway, and hostname as they are, letting you provide extra info by hand.

E.g.:

Finally, you can permanently configure your USB network interface.

E.g.

Generally, you can avoid every DHCP setting (see the man page) but gather them with

Then you can set what you want in the postup hook.