Android Tethering: Using Android to access internet on your Linux machine

Android tethering Linux

What is Android Tethering?

Android Tethering is a way to access internet on your computer with the help of your Android smartphone. USB and Wi-Fi access point tethering is natively supported from Android Froyo 2.2.

Android tethering Linux

USB tethering

For USB tethering you must have root access to the phone and a USB cable to connect your phone to computer.

Step 1: First of all you will have to enable USB debugging on your Android. Go to Settings -> Applications -> Development -> USB debugging and enable it. After enabling just reboot your phone.

Step 2: Connect your phone to computer using USB cable.

Step 3: Now enable tethering option from your phone. For this go to Settings -> Wireless & Networks -> Internet tethering and enable it.

Step 4: Open up terminal on your computer and run the command given below

 ifconfig -a

The output will be like:

eth0      Link encap:Ethernet  HWaddr 40:61:86:B1:E9:33
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:480 (480.0 b)  TX bytes:480 (480.0 b)

usb0      Link encap:Ethernet  HWaddr C2:5A:11:8D:43:F5
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

usb0 is denoting your Android device. If you don’t see it then you will have to load the usbnet module and you can do that using modprobe command as:

 modprobe usbnet

Step 5: Now to configure new network device via DHCP use the command given below:

 ifconfig usb0 up && dhcpcd usb0

For configuring the new network device using iproute toolkit the command is:

 ip link set usb0 up && dhcpcd usb0

For stopping the network sharing the command is:

 dhcpcd -x usb0

 

Netcfg

You can use Netcfg to configure USB tethering, for that just add a static ethernet configuration like:

/etc/network.d/usb-tether

CONNECTION='ethernet'
DESCRIPTION='A basic dhcp ethernet connection using iproute'
INTERFACE='usb0'
IP='dhcp'