Skip to content

Commit

Permalink
Update reverse-tethering.rst
Browse files Browse the repository at this point in the history
- Add more details.
- Adjust required steps to the more recent versions of UT and Ubuntu.
- Add some known issues and another reference.
- Fix some formatting issues.

Tested with Ubuntu Touch 16.04 (OTA-24) and Ubuntu 22.04.
  • Loading branch information
MarkMuth authored and doniks committed Jan 3, 2023
1 parent 8e2932b commit f9a9aa5
Showing 1 changed file with 58 additions and 15 deletions.
73 changes: 58 additions & 15 deletions userguide/advanceduse/reverse-tethering.rst
Original file line number Diff line number Diff line change
@@ -1,34 +1,77 @@
Reverse tethering
=================

This tutorial helps you to connect your Ubuntu Touch device to your computer to access the Internet on it.
This is useful if there is no available Wi-Fi connection or you don't have a data subscription on your Ubuntu Touch device.

Prerequisite: A Ubuntu Touch device with "Developer mode" on, attached via USB to the computer connected to the Internet.
This tutorial explains how you get your Ubuntu Touch device online using a USB cable and a computer with internet access.
This is useful if there is no available Wi-Fi connection or you don't have a data subscription on your device.

Steps
-----

1. On the Ubuntu Touch device: ``android-gadget-service enable rndis``
#. Prepare your device (Ubuntu Touch) and your computer:

2. On your computer: get your RNDIS IP address e.g:``hostname -I``
- Turn `Developer Mode` on in Ubuntu Touch.
- Connect your computer to the internet.
- Attach your device to your computer via USB.

3. On the Ubuntu Touch device:
#. On the *device*:

add a gateway: ``sudo route add default gw YOUR_COMPUTER_RNDIS_IP``
- Run: ``android-gadget-service enable rndis``
- Reboot the phone.

add nameservers: ``echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf``
#. On your *computer*:

refresh the DNS table: ``resolvconf -u``
- Get your RNDIS IP address:

4. On computer:
- Run: ``ip a``
- Look for an interface named ``usb0`` in the output:

Turn on IP forwarding: ``echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward``
::

Apply NAT: ``sudo iptables -t nat -A POSTROUTING -s 10.0.0.0/8 -o eth0 -j MASQUERADE``

5: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
link/ether 12:34:56:ab:cd:ef brd ff:ff:ff:ff:ff:ff
inet 10.42.0.1/24 brd 10.42.0.255 scope global noprefixroute usb0
valid_lft forever preferred_lft forever

- Your IP is: ``10.42.0.1``

#. On the *device*:

- Get your RNDIS interface: Run ``ip a``

::

31: rndis0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 12:34:56:ab:cd:ef brd ff:ff:ff:ff:ff:ff
inet 10.0.0.1/8 brd 10.255.255.255 scope global rndis0
valid_lft forever preferred_lft forever

- Your interface is: ``rndis0``

- Change your IP address: ``sudo ifconfig rndis0 10.42.0.2``
- Add your computer as default gateway: ``sudo route add default gw 10.42.0.1``
- Add a nameserver of your choice: ``echo "nameserver 1.1.1.1" | sudo tee -a /etc/resolv.conf``
- Open Morph Browser and test your internet connection!

#. If it's not working yet, on your *computer*:

- Turn on IP forwarding: ``echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward``
- Apply NAT: ``sudo iptables -t nat -A POSTROUTING -s 10.42.0.0/8 -o eth0 -j MASQUERADE``

- Make sure you replace ``eth0`` by the interface that connects your computer to the internet.

- NOTE: These steps are usually performed automatically by the NetworkManager on Ubuntu 22.04.

Known Issues
------------

- The Updates page in the System Settings displays: ``Connect to the Internet to check for updates.``
- After a while Teleports looses its internet connection and must be restarted.

References
----------

* Ask Ubuntu: https://askubuntu.com/questions/655321/ubuntu-touch-reverse-tethering-and-click-apps-updates
- `Ask Ubuntu`_
- RidgeRun_

.. _Ask Ubuntu: https://askubuntu.com/questions/655321/ubuntu-touch-reverse-tethering-and-click-apps-updates
.. _RidgeRun: https://developer.ridgerun.com/wiki/index.php/How_to_use_USB_device_networking

0 comments on commit f9a9aa5

Please sign in to comment.