Android tethering (Русский)
Тетеринг - это раздача интернета на компьютер со смартфона с помощью его сетевого подключения. USB tethering and Wi-Fi access point tethering are natively supported since Android Froyo (2.2). In older versions of the Android OS, most unofficial ROMs have this option enabled.
Contents
Wi-Fi access point
Using an Android phone as a Wi-Fi access point (using 3G) has been accessible by default since Froyo (Android 2.2) without needing to root the phone. Moreover, this method will discharge the battery rapidly and tends to cause intense heating, unlike USB. See : menu/wireless & networks/Internet tethering/Wi-Fi access point
USB модем
Что вам понадобится
- Root доступ на телефоне (для старых версий Android, Froyo (Android 2.2) и ещё более ранних это можно сделать из коробки.)
- USB кабель для подключения смартфона к компьютеру
Порядок действий
- Отключите ваш компьютер от всех беспроводных и проводных сетей
- Подключите телефон к компьютеру с помощью USB кабеля (режим подключения USB -- Медиа устройство, Монтирование SD карты или Только зарядка -- это не важно, но обратите внимание, что вы не сможете поменять режим подключения USB во время тетеринга)
- Включите режим USB-модем на телефоне. Обычно эта настройка находится так
Настройка --> Беспроводные сети --> Ещё --> Режим модема
(илиTethering & portable hotspot
, на некоторых версиях) - Убедитесь, что USB интерфейс распознан системой с помощью следующей команды:
-
$ ip link
- Вы должны увидеть
usb0
илиenp?s??u?
устройство в вашем списка (например, здесь это устройство enp0s20u3).
# 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
- Последним шагом является настройка сетевого соединения[broken link: invalid section] на данном интерфейсе.
USB tethering with OpenVPN
This method works for any old Android version and requires neither root access nor modifications in the phone (it is also suitable for Android 2.2 and later, but no longer required).
It does not require changes to your browser. In fact, all network traffic is transparently handled for any PC application (except ICMP pings). It is 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 on a powerful Acer Liquid).
Tools Needed
For Arch, you need to install the openvpn package. It is also required to have the Android SDK installed (which can be obtained here or from the AUR). On the phone, you need the azilink application, which is a Java-based NAT that will communicate with OpenVPN on your computer.
Configuring the phone connection in Arch Linux
Once you have installed the Android SDK, in order to use the provided tools your phone must be properly set up in udev and your Linux user needs to be granted rights. Otherwise you may need root privileges to use the Android SDK, which is not recommended. To perform this configuration, turn on USB debugging on the phone (usually in Settings -> Applications -> Development -> USB debugging), connect it to the PC by the USB cable and run the lsusb
command. 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 restart
command (or reboot your computer) to make the change effective.
Now run in your linux PC the adb shell
command from the Android SDK as plain (non root) user: you should get a unix prompt in your phone.
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
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
Troubleshooting
DNS
You may need to manually update the contents of resolv.conf to
/etc/resolv.conf
nameserver 192.168.56.1
NetworkManager
If you're running NetworkManager, you may need to stop it before running OpenVPN.
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
- android-sdkAUR and android-sdk-platform-toolsAUR from AUR and android-udev from official repositories
- 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