Tethering android and OSX without root
This guide explains how to tether your android phone to a OSX machine over USB. It supports Android 1.5 Cupcake. I have only tested this on an Android Development phone (HTC Magic aka Google Ion), but it should work on others.
UPDATE 1/21/10: Confirms works on Nexus One.
This guide assumes several things. You must have macports, be able to install apps on your phone (IE android SDK), be familiar with the terminal, and be aware what your cell carrier’s position on tethering is.
Lets get started.
- Install the openvpn port for OSX:
sudo port install openvpn2
This may take a while depending on your connection speed and processor speed. It will build several dependencies, including openvpn2.
- Download AziLink:
http://azilink.googlecode.com/files/azilink-2.0.2.apk - Install AziLink to your phone:
with the sdk installed:adb install azilink.apk
or on the phone: http://lfx.org/azilink/azilink.apk
- Enable USB debugging on the phone. From the home screen, this is under Settings>Applications>Development>USB debugging.
- Install the Android USB driver (if you don’t already have one installed). See http://developer.android.com/guide/developing/device.html for more information. The driver is included in the ADB download if you don’t want to get the full SDK.
- Create a script (I called it androidtether) and make it executable:
touch androidtether chmod 755 androidtether
- copy bash script from http://jimcortez.com/code/androidtether into that file
This file (credited below) will take care of all the setup and tear down of the tethering - On the phone, run AziLink and make sure “Service active” is checked.
- run the script
./androidtether - If all goes well, you are now tethered! AziLink should have a connected status and network stats should start flowing.
And yes, it does work, I am posting from a tethered MacBook Pro! - When you are done, hit contrl+c and the tear down will be triggered
Problems and Notes
- I had a problem running the script, I got this error message:
Cannot allocate TUN/TAP dev dynamically
There are many theories about why this happens. The range from co-installation of Cisco VPN to faulty TUN/TAP drivers. I fixed it by simply installing tunnelblick (http://code.google.com/p/tunnelblick/). I think it included some helpful drivers.
- If you do a network connect/disconnect/switch on the computer or phone (ie wifi to 3G, ethernet to wifi). You must restart all the services.
- This is NOT a secured connection, the above does not utilize the encryption capabilities!
Credits
I cobbled this guide together from so many sources, it was hard to keep track. Feel as though I didn’t give you credit? Please let me know!
- TUN/TAP issue:
http://www.macosxhints.com/article.php?story=20060803032236476 - some stolen instruction steps:
http://code.google.com/p/azilink/ - script from mochabyte post:
http://forum.xda-developers.com/archive/index.php/t-481162.html
This is the most awesome thing ever!! Thanks so much for posting!!!
I can’t wait to try it out.
Thanks for this description!!!
Tried nearly five variants of tethering and finally this works
Internet connection works great, but I have a DNS problem (cannot resolve) : after running the script /etc/resolv.conf also disappears and placing a new one does not really help…Does somebody have a hint or tip?
Problem found : no UDP traffic is send trough. Solved by using Tunnelblick as the actual openvpn client. See http://thinkden.com/index.php/general/admin/75, I think it’s a more elegant solution.
Your instructions are quite readable: thank you for that.
For some reason I also had to install tunnelblick, from then on it works!
Next step (maximum awesomeness) is to enable using bluetooth for tethering.
One other thing: if you have Parallels installed, you might have to disable the 2 Parallels networking adapters (host-only adapter and shared adapter) from “System Preferences -> Network”. Once I did this, everything worked fine.
It does seem really slow to pull up websites though (anywhere from a few seconds to 60+ seconds). I’m wondering why it’s so much slower than just browsing from the phone. The VPN must be a real bottleneck, eventhough it’s not encrypting anything.
I’d love to see someone get bluetooth tethering working without rooting as well
Dave
YOU ARE THE MAN!!! You saved me brother. I have been going crazy trying to get this to work. I can now cancel my home internet and save money. You are awesome. I had that TUN/TAP issue too. All I did was download Tunneblick and it solves it. You don’t even have to have it running. Fantastic!
Jovial1
Great, confirmed for the HTC Hero with Snow Leopard on the mac.
After the TUN/TAP issue, installing Tunnelblick – and making it to try and connect to a non existing connection, also had to be done prior to fixing it.
Tnx man!
Jasper.
Thank you for your instruction above…
I have an Hero, and a Macbook.
but I am a new user… and I am not familiar with these writing…
I was only able to comply with your instruction number
2. 3. 4.
I’m not sure if I need Number 5! the android usb driver.
for when I plug in, my mac obviously respond to the USB.
and Number 1, openvpn2 seems a very complex issue…
I opened the appointed webpage,
and there were a bunch of lines of computer writing…
some of which says “deroot”…
I thought this solution wasn’t about rooting the android phone…
so i wasn’t dare to try anything.
besides, I was trying to download openvpn…
and it led to the page at version tracker…
http://www.versiontracker.com/php/search.php?mode=basic&action=search&str=download
where the file wasn’t available for download.
As for Androidthether file… Stupid as I am…
I don’t know how to make an executable file… dumb me..
However, I’m not all in vain…
here are two things a dummy in mAC such as I am have found…
1. parallel does respond to SYNC software, subsequently,
my parallel was able to get connected via my HERO.
but that doesn’t answer the question as most of the mac software still can’t get linked…
2. mac computer does respond to android phone usb connection!
I opened the network from system preference, and found that
I can make an android phone connection.
the problem with this is that…inside this android phone connection,
when I press advance button, there are a lot of ways how apple can get connected.
inside the “vendor” option, there wasn’t anything coming from HTC…
i tried literally EVERY single one of them… but none gets me connected.
which is a lot by the way.
I even tried the “generic”… which seems the closest one…
I tried generic mode for the vendor option, and pressed GPRS(GSM/3G)
option for the model. but it doesn’t connect me.
So other than the above instruction which I don’t know how to execute…
if anyone can help figure out which vendor & model format can HTC hero uses.
I suppose this would be a much easier way for HERO to be connected to a macbook with USB line.
thus… look forward to any good news or help. tks a lot
First of all, thanks for the clear instructions!
But, there seems to be a problem on my Leopard (not SL) Macbook.
First of all an addition to your script: The new openvpn2, version 2.1, requires one to add the following flag to the openvpn2 command:
–script-security 2
After fixing this, there seems to be a problem with scutil:
./androidtether
Mon Jan 11 22:14:55 2010 OpenVPN 2.1.1 i386-apple-darwin9.8.0 [SSL] [LZO2] built on Jan 11 2010
Mon Jan 11 22:14:55 2010 NOTE: the current –script-security setting may allow this configuration to call user-defined scripts
Mon Jan 11 22:14:55 2010 ******* WARNING *******: all encryption and authentication features disabled — all data will be tunnelled as cleartext
Mon Jan 11 22:14:55 2010 TUN/TAP device /dev/tun0 opened
Mon Jan 11 22:14:55 2010 /sbin/ifconfig tun0 delete
ifconfig: ioctl (SIOCDIFADDR): Can’t assign requested address
Mon Jan 11 22:14:55 2010 NOTE: Tried to delete pre-existing tun/tap instance — No Problem if failure
Mon Jan 11 22:14:55 2010 /sbin/ifconfig tun0 192.168.56.2 192.168.56.1 mtu 1500 netmask 255.255.255.255 up
Mon Jan 11 22:14:55 2010 ./androidtether up tun0 1500 1502 192.168.56.2 192.168.56.1 init
sudo: scutil: command not found
Mon Jan 11 22:14:55 2010 script failed: external program exited with error status: 1
Mon Jan 11 22:14:55 2010 Exiting
Any ideas? Thanks in advance!!
@Marvin: scutil must be installed. Try replacing that line with “/usr/sbin/scutil”
@Tai: That is a bash script, use step 6. You are going to need the android development tools.
Hi there, when I copy and pasted your script into my Mac’s “Script Editor” and attempted to run the script, it found a great deal of syntactical errors including the { and } symbols in various places, and also had an issue with the use of the word “forward” at some point. How do I remedy these problems so I can run the script? Thank you
@CKN: It is not an appleScript, it is a bash script. It should be run from the command line. Follow steps 6 and 7
I did that and it worked, and after fixing all the errors and actually having it running someone posted on androidcommunity.com that there is a software: pdanet that does all that. I checked it out, and it did work.. very simple and easy too.. so check it out as well:
http://www.junefabrics.com/android/mac.php
AHAHAHAHAH! F*ck you Rogers and your $6/hr pimply-faced tech support that can’t spell Linux, let alone support it. My Android Developer phone is now tethered to my MacBook Pro, despite your best efforts to stop me thanks to this well written and WORKING method of tethering my Android G1 to my MBP!
Works on HTC Desire as well.
Really nice, this means I wont need to root it
Thanks!
Works on snow leopard 10.6.5
I just needed to add the “-script-security 3 system” flag to the openvpn call in the script
line 8:
sudo openvpn2 –dev tun \
–remote 127.0.0.1 41927 \
–proto tcp-client \
–ifconfig 192.168.56.2 192.168.56.1 \
–route 0.0.0.0 128.0.0.0 \
–route 128.0.0.0 128.0.0.0 \
–keepalive 10 30 \
–up “$0 up” \
–down “$0 down” \
–script-security 3 system
[...] [...]