Showing posts with label 3g modem. Show all posts
Showing posts with label 3g modem. Show all posts

Friday, March 05, 2010

Use Android phone as 3G modem on Mac OSX

** Only tested at Google Nexus One

Reference from :
Using Android Phone as a USB Tether on Mac OS X
Tethering android and OSX without root
Mac OS X Droid Tethering (USB/Wired)

1. Download and install necessary applications at OSX :
- TunnelBlick OpenVPN for Mac OS X
- tuntap for Mac OS X
* need to reboot to make sure kext got loaded at startup.
* or manually load them by blow command w/o reboot :
sudo kextload /Library/Extensions/tun.kext
sudo kextload /Library/Extensions/tap.kext

2. Download and install azilink.apk at android phone :
- azilink for google android
* execute azilink at android phone, enable service

3. Download Android SDK, cp tools/adb into executable path ( like /usr/sbin )

4. Enable USB debugging on the Android phone :
- Settings>Applications>Development>USB debugging.

5. Save blow script into ~/azilink.sh ( from http://pastie.org/701122 ), and execute it :

#!/bin/bash
#
# azilink for OS X
# based on http://pastie.org/405289 but works with Tunnelblick only
# (no need to install a separate copy of OpenVPN2 from macports
# or building from source by hand, thankfully)
# Requires:
# - azilink running on android phone (http://code.google.com/p/azilink/)
# (run the app and check the box to start the service).
# - adb on system path (comes with the Android SDK;
# add its tools folder to your PATH in ~/.profile or
# place or symlink the sdk's tools/adb file in e.g. usr/local/bin or somewhere else on the PATH)
# - Tunnelblick, a nice OS X packaging of OpenVPN (http://code.google.com/p/tunnelblick/)
# Install Tunnelblick to Applications. Tested with Tunnelblick 3.0b22

init() {
adb forward tcp:41927 tcp:41927
sudo /Applications/Tunnelblick.app/Contents/Resources/openvpn --dev tun \
--script-security 2\
--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"
}

up() {
tun_dev=$1
ns=192.168.56.1
sudo /usr/sbin/scutil << EOF
open
d.init
get State:/Network/Interface/$tun_dev/IPv4
d.add InterfaceName $tun_dev
set State:/Network/Service/openvpn-$tun_dev/IPv4

d.init
d.add ServerAddresses * $ns
set State:/Network/Service/openvpn-$tun_dev/DNS
quit
EOF
}


down() {
tun_dev=$1
sudo /usr/sbin/scutil << EOF
open
remove State:/Network/Service/openvpn-$tun_dev/IPv4
remove State:/Network/Service/openvpn-$tun_dev/DNS
quit
EOF
}


case $1 in
up ) up $2 ;; # openvpn will pass tun/tap dev as $2
down) down $2 ;;
* ) init ;;
esac