Setup USB Tethering on your Android Phone, No Root Access Required

by
on
May 18, 2010

Initial Setup and Configuration

Download the current Android SDK (Linux version).
$ wget http://developer.android.com/sdk/download.html?v=android-sdk_r04-linux_86.tgz

Untar the SDK.
$ tar xvf android-sdk_r04-linux_86.tgz

Copy the “adb” application to your Ubuntu /usr/bin directory (sudo privs needed)
$ sudo cp android-sdk-linux_86/tools/adb /usr/bin/adb

Create a rules file called /etc/udev/rules.d/91-android.rules containing the information below. This will allow udev to see your device. Make sure you replace <username> with your username. This example shows the idVendor for the Motrola Droid “22b8″, if you are using a Nexus One change the idVendor to “18D1″, for the HTC Incredible use “0BB4″.
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", SYMLINK+="android_adb", MODE="0666", OWNER="<username>"
For other android devices you can use the lsusb command with your phone connected over USB. The vendor ID is the bold text. This example shows the Motrola Droid.
$ lsusb
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 22b8:41db Motorola PCS
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Change the file permissions.
$ sudo chmod a+r /etc/udev/rules.d/91-android.rules

Restart udev so that it uses the new rules.
$ sudo restart udev

On your phone enable “USB debugging” Settings -> Applications -> Development.

Connect your Droid to the computer with the USB cable and check that it recognizes the device.
$ adb devices

Install OpenVPN on Ubuntu.
$ sudo apt-get install network-manager-openvpn openvpn
$ sudo /etc/init.d/networking restart
$ sudo /etc/init.d/network-manager restart

Install OpenVPN on your Phone. The adb command will install the azilink app on your phone from your computer. Alternatively you can copy the azilink.apk to your phone and install it directly if you have the Settings -> Applications -> Unknown Sources option enabled.
$ wget http://lfx.org/azilink/azilink.apk
$ adb install azilink.apk
$ wget http://azilink.googlecode.com/files/azilink.ovpn

Create a script called android_tether with the following code. This script handles .
adb forward tcp:41927 tcp:41927
sudo mv /etc/resolv.conf /etc/resolve.conf.backup
sudo echo "domain lan" > /etc/resolv.conf
sudo echo "search lan" >> /etc/resolv.conf
sudo echo "nameserver 192.168.56.1" >> /etc/resolv.conf
sudo openvpn --config azilink.ovpn

Set your new script to be executable.
$ chmod 755 android_tether

« IntroductionStart and Stop Tethering Service »

11 Comments
guides
, , , , , , , , , , , , , , ,

Related posts:

  1. Install Wireless Tether App from Outside the Android Market
  2. Setup the Android SDK on Ubuntu
  3. How to root your Motorola Droid running stock Android

Comments (10)

Hello Ryan… Thanks for posting this! Just wanted to let everyone know that I’ve created a script to set this up for the Ubuntu 9.10+ machines … See it on my blog at humans-enabled.com, or use the direct link to it:
http://dl.dropbox.com/u/394584/Droid-Tether-SV.tgz
Instructions here:
http://dl.dropbox.com/u/394584/Droid-Tether-SV-README

Enjoy!

    Thanks for the update!

    Hey Shannon,

    Your script failed on my Fedora 14 install but I popped a livecd of Ubuntu 10.10 in my machine and it ran like a champ. thanks for throwing this together.

Hi Ryan, I currently use a similar setup with Proxoid but it seems to only use 1 port (8080 by default). Does AziLink use multiple ports?

    I don’t believe that it uses multiple ports. This line does port forwarding from host port 41927 to android port 41927.
    adb forward tcp:41927 tcp:41927

Hi Ryan

You forgot to put /etc/resolv.conf instread of resolv.conf
in the line :

sudo echo "nameserver 192.168.56.1" >> resolv.conf

Thanks for your tutorial it was very clear and helpfull to me !

    Good catch thanks, fixed now.

Ryan,

Thanks for the info, this is the most straight forward setup I have seen to date to get this accomplished.

Thanks again!

Hi Ryan,

Perhaps you can help me. I am using your script with limited success to tether my Fedora 13 workstation to my Evo 4G.

The short story, I run the script, start AziLink on my Evo, and get ‘Status: Connected to host’ reported by AziLink. Unfortunately, AziLink also shows ‘Bytes received: 0, Bytes sent: 0, TCP connections: 0, NAT table size: 0′. I don’t get any indications of networking.

More details

Output from android_tether:

# ./android_tether
Fri Sep 3 15:36:35 2010 OpenVPN 2.1.1 x86_64-redhat-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] built on Jan 5 2010
Fri Sep 3 15:36:35 2010 WARNING: --ping should normally be used with --ping-restart or --ping-exit
Fri Sep 3 15:36:35 2010 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Fri Sep 3 15:36:35 2010 ******* WARNING *******: all encryption and authentication features disabled -- all data will be tunnelled as cleartext
Fri Sep 3 15:36:35 2010 TUN/TAP device tun0 opened
Fri Sep 3 15:36:35 2010 /sbin/ip link set dev tun0 up mtu 1500
Fri Sep 3 15:36:35 2010 /sbin/ip addr add dev tun0 local 192.168.56.2 peer 192.168.56.1
Fri Sep 3 15:36:35 2010 WARNING: potential route subnet conflict between local LAN [128.32.147.0/255.255.255.0] and remote VPN [128.0.0.0/128.0.0.0]
Fri Sep 3 15:36:35 2010 Attempting to establish TCP connection with 127.0.0.1:41927 [nonblock]
Fri Sep 3 15:36:35 2010 TCP connection established with 127.0.0.1:41927
Fri Sep 3 15:36:35 2010 TCPv4_CLIENT link local: [undef]
Fri Sep 3 15:36:35 2010 TCPv4_CLIENT link remote: 127.0.0.1:41927
Fri Sep 3 15:36:45 2010 Peer Connection Initiated with 127.0.0.1:41927
Fri Sep 3 15:36:45 2010 Initialization Sequence Completed

Contents of resolv.conf after starting checks out:

#cat /etc/resolv.conf
domain lan
search lan
nameserver 192.168.56.1

What can I see?

# ping http://www.ibm.com
ping: unknown host http://www.ibm.com

Or, explicitly providing an IP address (for http://www.ibm.com.cs186.net):

# ping 129.42.56.216
PING 129.42.56.216 (129.42.56.216) 56(84) bytes of data.
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted

What about the device?

# ping 192.168.56.0
PING 192.168.56.0 (192.168.56.0) 56(84) bytes of data.
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted


# ping 192.168.56.1
PING 192.168.56.1 (192.168.56.1) 56(84) bytes of data.
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted


# ping 192.168.56.2
PING 192.168.56.2 (192.168.56.2) 56(84) bytes of data.
64 bytes from 192.168.56.2: icmp_seq=1 ttl=64 time=0.041 ms
64 bytes from 192.168.56.2: icmp_seq=2 ttl=64 time=0.021 ms

Finally, for what it’s worth, here’s what ifconfig has to say:

# ifconfig tun0
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:192.168.56.2 P-t-P:192.168.56.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP 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:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

I’m not sure how to interpret this (I’ve little expertise on networking), but it seems that the host can talk with the device, but not the nameserver.

Any suggestions?

thanks,
-Mark

does this work for windows?

Trackbacks (1)

Leave a Comment

(displayed with your post)
(will not be published)
(optional)

Copyright 2008-2010 AndroidNexus.com. All rights reserved.