Share Your Ubuntu’s WiFi with Android using Gnirehtet

Are you tired of not being able to use both Wi-Fi and hotspot simultaneously on your Ubuntu device? While this may not be an issue when you're at home, it can become problematic when you're in a cafe, airport, or hotel where the internet is restricted to one device per user. However, there's a solution to this problem. I recently discovered an app called Gnirehtet that allows you to share your laptop's Wi-Fi with your Android device. Let's see how it works.

What is Gnirehtet?

Gnirehtet is an open-source app developed by Genymobile, the creators of the popular ScrCpy app. It utilizes the Android Debug Bridge (ADB) to establish a connection between your laptop and Android device via a USB cable. The app uses a feature called reverse tethering, which was introduced in Android 5.0. In simple terms, it sends your Android device's web requests to the webserver through your laptop, making the webserver believe that the request is coming from the laptop itself. Essentially, it uses your laptop as a proxy.

Installing ADB on Ubuntu

Before you can use the Gnirehtet app, you need to install ADB on your Ubuntu device. To do this, open the terminal and enter the following command:

sudo apt-get install adb

Once ADB is installed, you can proceed to download the Gnirehtet app for Linux. There are two variants available: Linux and Rust. It is recommended to choose the Rust variant as it does not require setting up a Java runtime environment.

After downloading the zip file, extract it. Inside the folder, you will find two files: a compiled Rust file and an APK file. The APK file needs to be installed on your Android device. You can either send the APK file to your device and install it manually or use the Gnirehtet command to automatically install it.

Setting Up Gnirehtet

Before running the Gnirehtet command, make sure to enable USB debugging on your Android device. Connect your Android device to your laptop using a USB cable and navigate to the extracted Gnirehtet folder in the terminal. Run the following command:

./gnirehtet install

This will install the Gnirehtet client app on your Android device.

To start sharing your Wi-Fi connection, run the following command on your computer:

./gnirehtet run

You will also receive a prompt on your Android device to accept the VPN creation by Gnirehtet. This is because Gnirehtet transfers data from your Android device to your laptop through a VPN channel.

Multiple Android Devices

Gnirehtet also supports multiple Android devices. To use this feature, connect all the devices to your laptop and find their device numbers using the following command:

adb devices

Next, use the device number to start sharing the internet with a specific Android device:

./gnirehtet run <device number>

Please note that Wi-Fi functionality is also possible with ADB, but it still requires the initial setup using a USB cable. For simplicity, we have focused on the USB method in this article.

If you encounter any issues or have any questions, feel free to let us know in the comments below.

Also Read: How to Quickly Create Keyboard Shortcuts in Ubuntu