Wired Android Internet access without Wifi or 4G connections

My wife Silvia has been doing a systematic study about biological effects of wireless technologies on human health for some time now. Some publications are controversial, but we like to take the precautionary principle. More information about her studies is available at the website http://celularesaude.org/.

She is also collaborating with the SlowPhone moviment, and they are gathering really interesting information and promoting live events with prominent scientists in this area, such as Dr. Magda Havas and MSc. Sheena Symington.

More information about SlowPhone can be found at their YouTube channel:

www.youtube.com/Slowphone

In that context, she asked me for some way to use our smartphones at home in “Airplane mode”, but still with Internet access, which means, a wired connection. First, note that there are some proprietary / commercial solutions on the market, such as Ethernet Adapters for Android and Apple devices. However, it is possible to build your own solution using low cost hardware, or simply using your PC, so no hardware purchases are needed.

One of the best solutions I found is based on the Open Source Software gnirehtet (https://github.com/Genymobile/gnirehtet). You can download and use it to share your computer Internet connection with your phone over a USB cable, or you can build a “little box” that acts as a wired router for Android devices.

For this “little box” project, we decided to integrate such a tool on a Raspberry Pi low cost single board computer (https://www.raspberrypi.org/products/raspberry-pi-4-model-b/), which costs about 35 US dollars or less and is easily available in many parts of the world.

Uniting these tools, we can create a small box that can be connected to the Internet using Ethernet cable and providing reliable and high speed Internet access to one (or several) Android device(s) simultaneously. You just have to plug the phone, and it will have Internet access on Airplane mode. We have also tested it with 3 simultaneous phones accessing Internet through the same “little box”.

By the way, you may remember the tethering technology, which allows you to share your mobile phone Internet connection (4G/GSM) with your computer. What we do here is reverse tethering, where the mobile phone uses another wired connection instead of sharing its connection.

Finally, using Voice Over Wifi (VoWi-Fi) technology, it is possible to make and receive phone calls with your operator mobile phone number without any wireless connection active! But there is a trick for that, at the end of this text….

If you are interested, here is how to prepare build such “little box” for you:

Procedures:

1. Get a Raspberry Pi and a SD Card

We have tested the system with Raspberry Pi models 1, 2, 3 and 4 (must be model B). Any will serve. You will also need a SD Card of at least 8GB that will be erased / formatted to load the embedded Linux that we will prepare for this application. You can also buy a case for the Raspberry Pi, or build a case with a 3D Printer.

Raspberry Pi options:

https://www.raspberrypi.org/products/

Raspberry Pi Pico and Raspberry Pi Zero cannot be used for this project.

2. Download the Operating System (OS) for the Raspberry Pi Computer

Using a computer with a SD Card reader, go to the website:

https://www.raspberrypi.org/software/operating-systems/

Download Raspberry Pi OS. We have used:

Raspberry Pi OS Lite
Release 4th March 2021

3. Write Operating System (OS) image to the SD Card

Detailed instructions here:

https://www.raspberrypi.org/software/

For Linux users, just insert the SD Card on your PC and run these commands (after the download):

unzip 2021-03-04-raspios-buster-armhf-lite.zip
sudo dd if=2021-03-04-raspios-buster-armhf-lite.img of=/dev/mmcblk0

Be careful and verify that /dev/mmcblk0 is really your SD Card device, otherwise you might lose important information!

4. Turn on the Raspberry Pi with a network cable connected and login

Remove the written card from your PC and insert it on a Rapberry Pi computer module. To set up the system, you will need a monitor and keyboard. Later these accessories won’t be necessary anymore.

Power on the Raspberry Pi with the written card and wait for the login prompt. If the Raspberry Pi is powered with an Ethernet cable, it will automatically connect to the Internet using DHCP (automatic network configuration). Use the keyboard to access the Raspberry Pi terminal with this login and password:

Login: raspberry
Password: pi

If the login is successful, you will see a command prompt like this:

pi@raspberry:~$

After logging in, let’s start installing the required software.

5. Install RUST Language

The main component of this project is gnirehtet, which uses RUST Programming Language. So, we will install this language on the Raspberry Pi. Detailed explanation to install RUST is available here:

https://www.rust-lang.org/tools/install

One quick and direct way to install RUST, is by issuing this command:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Then, press 1 – Proceed with installation.

After some minutes, you will see:

“Rust is installed now. Great!”

6. Download required packages

Now we have to install some required software for our system. Still using the keyboard and the terminal (dark screen), run the following commands:

sudo su -

apt-get update

apt install adb

apt install git

Now, download gnirehtet source code with the following command:

git clone https://github.com/Genymobile/gnirehtet.git

7. Build the program

Before building the program, it is necessary to logout (exit) the current terminal session and login again. This will allow the environment to be prepared for the building process, specially due to RUST language installation. To logout, you can type exit and ENTER, or simply press Ctrl+D. Do it twice, until you see the login prompt again asking for login and password. After that, type the username and password again, and be sure to be logged in before issuing the following commands.

sudo su -

source /root/.cargo/env

cd /home/pi/gnirehtet/relay-rust

cargo build

After several “Downloaded” and “Compiling” messages, a “Finished” message will appear. If you got to here, congratulations, you have gnirehtet compiled and ready to use.

Now let’s test it!

8. Copy files to a common place

For easier testing, copy the built gnirehtet to a directory.

cd /home/pi/gnirehtet

cp relay-rust/target/debug/gnirehtet .

You also need to download the Android application that is automatically installed on the device to allow the reverse tethering to be setup automatically. You can build this App yourself, but for easier setup, you can use this prebuilt application by downloading it with wget download tool.

wget http://bipes.net.br/aroca/gnirehtet.apk

You can use the ls command to check if this file is present in the directory (folder).

9. Test gnirehtet

Enable Developer Options on the Android device

A few minutes ago we installed the program adb (Android Debug Bridge). Such tool is used to debug Android devices, and the process of reverse tethering need to issue commands using adb. In that way, USB debugging must be enabled on your Android device so we can proceed. This is done by going on the Android configuration menu, then clicking several times until you “become a developer” (More instructions here: https://developer.android.com/studio/debug/dev-options).

Enable USB debugging on the Android device

After enabling developer options, then we need to enable USB debugging. You will see this option on the new menu “Developer Options” that will appear on the configurations meno of your Android device.

After that, go back to the Raspberry Pi terminal and run:

./gnirehtet autorun

Turn on airplane mode of your Android device, and connect it to the the Raspberry Pi using a USB cable. Note that a data transfer USB cable must be used (cables for charging only will not work).

A message will appear on the phone asking to authorize USB debug. Permit it. You should now have full Internet access on your Android device using the USB cable, where data is routed by the USB cable and then by the Ethernet cable via the Raspberry Pi board.

And the magic is done!

Note that all these steps just need to be done once, as we were preparing our system. From now on, each time you want to use it, simply plug the cables (Ethernet to Raspberry, Power to Raspberry and USB between Raspberry and Android device and use!

Moreover, the system supports several phones / Android devices simultaneously using Internet shared by the Raspberry Pi!

10. Configure the system for automatic initialization on reboot

One last thing we have to do is configure the Raspberry Pi to automatically run gnirehtet when powered on. To configure automatic execution on initialization, edit the file /etc/rc.local, locate the last line, which will have the text exit 0, and before the last line add 2 lies as follows:

#(rc.local file will have several instructions - keep all of them)

cd /home/pi/gnirehtet

./gnirehtet autorun &

exit 0 #(this is the last line of rc.local - keep untouched)

If you never edited a file on Linux, use the nano file editor, by simply typing:

sudo nano /etc/rc.local

After doing the modifications and saving the file, turn off the Raspberry Pi, by uplugging the power adapter, and power it again. Finally, check if the system will work automatically after power on.

After these steps, you can move the device around your house and use where you prefer. No more keyboard or monitor needed!

10. Making and receiving phone calls on airplane mode

As mentioned, Voice Over Wifi (more details here: VoWi-Fi and here: Wi-Fi Calling (VoWi-Fi) ) technology allows Android Smartphones to make and receive phone calls using your operator mobile phone number over Wifi Network. Obviously, Wifi network relies on the TCP/IP protocol stack, so we can use our rever tethering system described here!

Unfortunately, there is a trick for that to work. VoWi-Fi check if you are connect to a WiFi network, a verification that is unnecessary, but implemented on the devices. The trick is to “lie” to your phone, telling that it is connected to a WiFi network, while the true is that it is connected to a wired connection!

In order to do that trick, one possible solution is to run FakeWifi application (https://repo.xposed.info/module/com.lemonsqueeze.fakewificonnection), which will simulate a WiFi connection, while, in fact, we are using a wired connection.

Final remarks

Everything we have done here, can be done on your computer also (Windows, Linux or MAC), so you can share your computer Internet connection with your Android device using a free USB port on your computer.

We have built three devices as described here and we are using this technology for about 4 months now (since December/2020). The system has been working reliably since then!

Finally, our many thanks and congratulations to the guys of GenyMobile (https://github.com/Genymobile/) for developing and sharing this awesome open source software: gnirehtet.

6 thoughts on “Wired Android Internet access without Wifi or 4G connections

  1. tachyon1

    I can’t figure out why you wouldn’t just use a USB ethernet adapter.
    With older phones you need a USB OTG splitter or hub to power the phone and the USB NIC.
    On a newer phone you can use the USB-C port directly to a USB-C ethernet adapter or laptop hub.
    I do this regularly. In fact I often combine this setup with a USB keyboard and mouse and HDMI monitor and use Samsung DeX for a full work environment with a wired network connection.

    Reply
    1. Rafael Aroca Post author

      Hello! Not all Android phones support DeX and USB to ethernet adapter is not easy to find/buy here in Brazil. As I had several Raspberry Pi boards at home, the solution was “free” for me. Of course, if you have easy access to these adapters, it is quite easier.

      Reply
      1. tachyon1

        DeX isn’t the point. DeX is not necessary in order to use a USB ethernet adapter. It was just an example of what you can do once you have one.
        As for being available, I’m fairly certain you have ebay and Amazon in Brazil both of which offer USB Ethernet adapters for under 15 dollars (US).
        Your solution is definitely a good example of making do with what you have on hand but I was pointing out that it’s not necessarily the simplest solution. In other words for someone else who has neither a Pi nor a USB Ethernet adapter already on hand, the latter is probably the better choice to put the effort into acquiring.

      2. Rafael Aroca Post author

        Sure, I agree 🙂 Anyway, if anyone has an unused Raspberry Pi, this might be a good option. Moreover, we can use it to provide access to up to 4 phones at once from the same Ethernet cable.

        best regards!
        Rafael

  2. ifq777

    Hi,

    Is it true that VoWifi via reverse tethering is working for you in reality and not just in theory?

    If so, would you please describe your Android phone setup as fully as possible: what phone model do you use, what Android version, Xposed, FakeWifi and gnirehtet versions, do you switch on airplane mode, do you use root, do you use any custom ROM, etc,etc. Thank you very much.

    The reason I’m asking is that people are reporting various problems with VoWiFi for this reverse tethering setup under different conditions.
    For example:
    – FakeWifi may work for Android 9 but not for Android 10/11.
    – VoWifi stops working if user enables Airplane mode because WiFi network interface is shut down but VoWifi expects it with a specific name, yet FakeWifi interface name is not the same,
    – VoWiFi IpSEC protocol ignores FakeWiFi for some reason,
    – etc.

    Reply
    1. Rafael Aroca Post author

      Just in theory, sorry. I did not have time to test VoWifi on a real device. As I tested VoWifi over real wifi and it worked, I assumed it would work with FakeWifi.

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s