We all have heard the name of tethering, right? It’s the method using which an Android device can work as the source of internet connection to a system. It’s super useful for situations when your system doesn’t have a Wi-Fi adapter (rare case, of course) or for some other reasons, you need your phone’s connectivity on your desktop/laptop/notebook etc.
Reverse tethering, as the name suggests, is the opposite of tethering. In this scenario, the Android phone is there to enjoy the internet connectivity from the desktop/laptop. Previously, it was super difficult as we had to undergo a seriously complex procedures using iptables, bridged connections etc. Thanks to the hard work of a developer, there’s an easy tool for Linux systems to reverse tether without any of those complexities. The tool has a nice, difficult name – Gnirehtet.
Important – Before going further, make sure that your Android has root unlocked. This is a must or much of the tool’s functionalities won’t work. Rooting an Android device, in many cases, will cause warranty void and other possible issues like bricking the phone. Check out your phone model on XDA Developers forum for a reliable method to root.
Preparing the system
It’s time to setup Gnirehtet. First, we need the essential Android tools. Run the following command –
sudo apt install android-tools-adb android-tools-fastboot
sudo apt-get install android-tools-adb android-tools-fastboot
sudo zypper in android-tools-adb android-tools-fastboot
sudo dnf install android-tools-adb android-tools-fastboot
- Arch Linux
sudo pacman -S android-tools-adb android-tools-fastboot
- Generic Linux instructions
If your system isn’t listed above, you have to get the compressed package of the command line tools only. Then, extract the folder to a suitable place and add the path to the system’s environment variable.
Check out your ADB version –
It’s finally time to get the tool. Run the following command –
Note that there’s also a Java version, but it’s not recommended. It will cause higher CPU and memory usage and may not work properly.
After downloading, extract the archive.
unzip gnirehtet-rust-linux64-v2.2.1.zip OR unzip gnirehtet-java-v2.2.1.zip
Switch the working directory to the Gnirehtet directory.
Configuring Android for reverse tethering
At first, from the Android device, go to Settings >> Developer options and enable “USB Debugging”.
Connect the device via USB and run the command on Linux terminal –
su - OR sudo -s adb start server
Once your device is unlocked, return to the terminal and run this command –
Start the terminal and run the following commands –
su - OR sudo -s ./gnirehtet autorun
You’ll get this notification in the Android phone. Allow the connection.
You’ll notice this icon at the top.
Sometimes, the USB port may disconnect without warning or you may have to disconnect it as well. In that case, reconnect the device via USB and run these commands –
cd ~/gnirehtet sudo ./gnirehtet restart
If you want to stop the reverse tethering connection, run this command –
cd ~/gnirehtet-* sudo ./gnirehtet stop
Sometimes, this command won’t kill the reverse tethering programs properly. You have to run the following commands for properly killing the tool –
pidof ./gnirehtet sudo kill -9 <process_number>