Tethering your HTC Magic Android Phone in Ubuntu 9.04 (Jaunty Jackalope)
Sometimes I have the need to get on the internet using my laptop instead of my
lovely HTC Magic. To do that, I’d have to get mobile internet, which is yet another expense I don’t really want. Before I go ahead, I’d like to
strongly discourage doing this on a regular basis. Vodafone’s “unlimited” internet is 500MB fair use policy, which when using a
laptop can be used up really quickly – so proceed with caution! In addition, I do not know your contract
to confirm that this will not void your warranty or violate your terms of service. You carry out these steps at your own risk and
are provided here for informational purposes only. Basically, if you mess things up and Vodafone (or whoever your carrier
is) comes knocking on your door, I’m not being held responsible.
This process does involve a bit of fiddling and knowledge of how things work, and the instructions on the app’s page are pretty
straightforward anyway.
Tethering has been made really easy by using an app called Azilink. All it is
is an OpenVPN server on your phone, which allows your laptop to connect to it via a USB cable.
Here’s the steps – pretty much the same as on the instruction page linked above – but specifically for Ubuntu:
- Install OpenVPN (don’t bother with Network Manager): sudo apt-get install openvpn
- Enable USB debugging on your phone. From the home screen, this is
under Settings > Applications > Development > USB debugging.
- Download the Android 1.5 SDK: http://developer.android.com/sdk/download.html?v=android-sdk-linux_x86-1.5_r3.zip
- Extract to /opt/android-sdk-linux_x86-1.5_r3
- Add the /opt/android-sdk-linux_x86-1.5_r3/tools directory to your
path (e.g. in .bashrc add
PATH=/opt/android-sdk-linux_x86-1.5_r3/tools:”${PATH}”
- Log out and back in again for the .bashrc to update
- You should be able to run adb now – type “adb”, hit RETURN and it should say it’s starting a daemon.
- Create and open /etc/udev/rules.d/51-android.rules in your favourite editor
- Add the line: SUBSYSTEM==”usb”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
- Set the permissions of the file: sudo chmod a+rx /etc/udev/rules.d/51-android.rules
- Connect your HTC Magic via USB cable to your laptop (hint: “tail -f
/var/log/messages &” gives you information when your phone is
connected)
- Check adb recognises your device: “adb devices” you should see a device listed
- Download: http://lfx.org/azilink/azilink.apk
- Install the app to your phone by doing “adb install azilink.apk”
- You should see the Azilink app in your apps list (its a little moth icon).
- On your laptop, type “adb forward tcp:41927 tcp:41927″
- On your phone, run the Azilink app, and check the “Service active” checkbox. Status will change to “waiting for connection”
- Download: http://azilink.googlecode.com/files/azilink.ovpn
- On your laptop, run “sudo openvpn azilink.ovpn”
- In a few moments on your phone, Azilink should report the status is now “Connected to host”.
- In a new terminal (don’t close the openvpn program, you’ll lose
your connection!) edit /etc/resolv.conf and add “nameserver
192.168.56.1″
With any luck you should now have internet. Next time you want to
connect, I think you’ll have to do something like (and I’ve not checked
this yet!):
- On phone, check USB debugging is enabled (if you disabled it)
- Connect HTC Magic to laptop with USB cable
- On laptop terminal, type: “adb forward tcp:41927 tcp:41927″
- On phone, check the “Service active” box (if you disabled it — recommended as it will probably drain your battery!)
- On laptop run “sudo openvpn azilink.ovpn”
- Add “nameserver 192.168.56.1″ into your /etc/resolv.conf (assuming Network Manager over-writes your resolv.conf)
I did this on Ubuntu 9.04 (Jaunty Jackalope) and this worked for me. Hopefully this should work pretty straightforward without problems.
Essentially what this app does is run a VPN server on your phone. ADB (Android Debugging Bridge) is a development tool that allows
forwarding of TCP traffic from your laptop to the phone (and vica-versa) – working in a similar way to an SSH tunnel, but this is
all unencrypted. Then all you have to do is open an unecrypted VPN connection to the forwarded port (i.e. 127.0.0.1:41927), and route the
traffic through that. The nameserver isn’t auto set of course so that has to be done manually.
I have no idea why tethering is so difficult on the HTC Magic – it should be made much easier, especially as it’s such an open phone.
However, thanks to it’s open-ness, apps like Azilink exist and make tethering possible!