Android tethering
Tethering is a way to have internet access on your PC through your smartphone using its network connection. USB tethering and Wi-Fi access point tethering are natively supported since Android 2.2 "Froyo".
Wi-Fi access point
Using an Android phone as a Wi-Fi access point (to a 3G/4G mobile internet connection) is available for devices running Android 2.2 "Froyo" or newer.
Enable it via one of the following:
- Settings > Wireless & networks > Internet tethering > Wi-Fi access point
- Settings > More... > Tethering & mobile hotspot > Mobile Wi-Fi hotspot
USB tethering
USB tethering is available since Android 2.2 "Froyo".
- Connect the phone to your computer via USB (the USB connection mode -- Phone Portal, Memory Card or Charge only -- is not important, but please note that you will not be able to change the USB mode during tethering)
- Enable the tethering option from your phone. This is usually done from one of:
- Settings -> Wireless & networks -> Internet tethering (or Tethering & portable hotspot, for more recent versions)
- Settings -> More... -> Tethering & mobile hotspot -> USB tethering
- Install the usb_modeswitch package. See Mobile broadband modem#Mode switching for more information.
- Follow Network configuration.
- If you are using a cellular data plan and you have recently entered a new billing period, you may need to restart your phone.
Using systemd-networkd with udev
Using systemd-networkd you can automatically adjust the networking to use the phone as the gateway when plugged in.
/etc/udev/rules.d/90-android-tethering.rules
# Execute pairing program when appropriate ACTION=="add|remove", SUBSYSTEM=="net", ATTR{idVendor}=="18d1" ENV{ID_USB_DRIVER}=="rndis_host", SYMLINK+="android"
You may have to adjust the idVendor
attribute depending on your phone. You can check using udevadm:
$ udevadm info /sys/class/net/enp0s26u1u2
Then create the corresponding systemd-networkd file:
/etc/systemd/network/50-enp0s26u1u2.network
[Match] Name=enp0s26u1u2 [Network] DHCP=ipv4
USB tethering with AziLink
AziLink is an application that allows USB tethering for Android-based phones, without requiring root access. It is very useful for Android older than version 2.2, when there was no stock USB tethering feature implemented. It also does not require changes to your browser, and all network traffic is transparently handled (except ICMP pings). It may be somewhat CPU intensive on the phone at high usage rates (a 500 kBytes/sec data transfer rate may take more than 50% of phone CPU).
Tools needed
For Arch, you need to install the openvpn package. You will also need to install the android-tools package for the adb tool and android-udev which sets up the correct /usr/lib/udev/rules.d/51-android.rules
file for your device to be recognized. On the phone, you need the azilink.apk (azilink homepage). The android application acts as a NAT, adb forwards the ports to your phone, and your openvnp setup will connect to it.
Configuring the phone connection in Arch Linux
So that you do not have to run adb as root, we are going to grant your user permissions to your usb device. Make sure you have turned on USB debugging on the phone (usually in Settings -> Applications -> Development -> USB debugging) so that it will be shown as a device, and that it is plugged in to your computer via the USB cable. You should see it with you run the lsusb
command. Original azi link instructions are here
The device should be listed. Example output for the Acer Liquid phone:
Bus 001 Device 006: ID 0502:3202 Acer, Inc.
Then, create the following file, replacing ciri
by your own Linux user name, and 0502 by the vendor ID of your own phone:
/etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", ATTR(idVendor)=="0502", MODE="0666" OWNER="ciri"
As root run the udevadm control --reload
command to make the change effective. To make sure the change took effect, run adb devices
and it should say device
instead of unauthorized
. Another way to make it take effect is to reboot. Another test is to run adb shell
to get to your phones unix prompt.
Procedure
Run the AziLink application in the phone and select About at the bottom to receive instructions, which basically are:
- You will have to enable USB debugging on the phone if it was not already enabled (usually in Settings -> Applications -> Development -> USB debugging).
- Connect the phone with the USB cable to the PC.
- Run AziLink and make sure that the Service active option at the top is checked.
- Run the following commands in your Linux PC:
$ adb forward tcp:41927 tcp:41927 # openvpn azilink.ovpn
azilink.ovpn
source from here
azilink.ovpn
dev tun remote 127.0.0.1 41927 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 socket-flags TCP_NODELAY keepalive 10 30 dhcp-option DNS 192.168.56.1
You may need to manually update the contents of resolv.conf to
/etc/resolv.conf
nameserver 192.168.56.1
If you are running NetworkManager, you may need to stop it before running OpenVPN.
USB tethering with EasyTether
Get the easytether linux client software. The commands to set it up and run it are as follows.
# pacman -U easytether-0.8.5-2-x86_64.pkg.tar.xz # easytether-usb # dhcpcd tap-easytether
Make sure you have the EasyTether android app installed on your phone for it to connect to. Note: The Lite app disables some connections and you must have the paid app for full functionality. For this reason, using the AziLink setup is recommended instead.
Tethering via Bluetooth
Android (from at least 4.0 onwards, possibly earlier) can provide a Bluetooth personal-area network (PAN) in access point mode.
NetworkManager can perform this action and handle the network initialisation itself; consult its documentation for more details.
Alternatively: pair and ensure you can connect your computer and Android device, as described on Bluetooth, then, substituting the address of the device (here given as AA_BB_CC_DD_EE_FF
), do:
$ dbus-send --system --type=method_call --dest=org.bluez /org/bluez/hci0/dev_AA_BB_CC_DD_EE_FF org.bluez.Network1.Connect string:'nap'
This will create a network interface bnep0
. Finally, configure a network connection on this interface; Android offers DHCP by default.
Tethering with SOCKS proxy
With this method tethering is achieved by port forwarding from the phone to the PC. This is suitable only for browsing. For Firefox, you should set network.proxy.socks_remote_dns
to true
in about:config
( address bar )
Tools needed
- The android-tools and android-udev packages
- USB connection cable from your phone to PC
- Either Tetherbot or Proxoid
Instructions
Tetherbot
Tetherbot is an experimental SOCKS proxy and Port Bouncer that should allow you to connect your laptop to the internet using the internet connection (EDGE, 3G or Wifi) of your T-Mobile G1 Cellphone. It is discontinued and its website is down, but still can be accessed from Wayback Machine[1] where its APK can also be downloaded from.
In order to do SOCKS proxy via Tetherbot to connect your browser to the Internet, do:
- For your phone, open the application Tetherbot and press the Start Socks button
- Start your SOCKS proxy by running:
# adb forward tcp:1080 tcp:1080
- Now go to your web browser's proxy settings, set a manual proxy configuration with the proxy host address
localhost
and port1080
, leaving the rest blank.
Proxoid
Follow the instructions demonstrated in the following link.