Android tethering - ArchWiki

# Android tethering

From ArchWiki

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

Note: On some phones, this method will discharge the battery rapidly and tends to cause intense heating, unlike USB.

## USB tethering

USB tethering is available for devices running Android 2.2 "Froyo" or newer.

- Disconnect your computer from any wireless or wired networks
- Connect the phone to your computer using the USB cable (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
- Make sure that the USB interface is recognized by the system by using the following command:

      $ ip link

  You should be able to see a `usb0` or `enp?s??u?` device listed like this (notice the enp0s20u3 device).

    # ip link

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
        link/ether ##:##:##:##:##:## brd ff:ff:ff:ff:ff:ff
    3: wlp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
        link/ether ##:##:##:##:##:## brd ff:ff:ff:ff:ff:ff
    5: enp0s20u3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
        link/ether ##:##:##:##:##:## brd ff:ff:ff:ff:ff:ff

Note: Take care to use the device name from your own system in the following commands.
Warning: The name may change depending on the usb port you use. You may want to change the device name to create a unique name for your device regardless of the usb port.

- The final step is to configure a network connection[broken link: invalid section] on this interface. For example:

      # dhcpcd enp0s20u3

- If you're using a cellular data plan instead of Wi-Fi, a restart of your phone may be required if you've recently entered a new billing period.

#### 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", RUN+="/usr/bin/systemctl restart systemd-networkd.service"

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

This method works for all known Android versions and requires neither root access nor modifications in the phone. It does not require changes to your browser. 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 with sudo, 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 `sudo 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. The command should work without needing sudo.

### Procedure

Run the AziLink application in the phone and select "About" at the bottom to receive instructions, which basically are:

1. You will have to enable USB debugging on the phone if it was not already enabled (usually in Settings -> Applications -> Development -> USB debugging).
2. Connect the phone with the USB cable to the PC.
3. Run AziLink and make sure that the Service active option at the top is checked.
4. Run the following commands in your Linux PC:

      $ adb forward tcp:41927 tcp:41927

      # sudo 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're 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[broken link: invalid section] 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

Follow the instructions under Using the Socks Proxy on [1].

#### Proxoid

Follow the instructions demonstrated in the following link[dead link 2017-05-31]

Categories:

- Network sharing
- Mobile devices

Hidden categories:

- Pages with broken section links
- Pages with dead links