8
November
2024
Using a smartphone to access the Internet from Linux OS
17:02

Using a smartphone to access the Internet from Linux OS

8 November 2024 17:02

Any PC can be connected to the Internet via a USB cable and a smartphone.

First case - PC without Internet

At work, I needed to take the characteristics of several computers without an OS using lshw in a warehouse. In the BIOS I selected boot from a USB drive and launched antiX Linux from a flash drive. I needed the lshw utility to view the PC configuration. Apt requires Internet access to work (sudo apt update && sudo apt install lshw && sudo lshw). The solution is obvious - an Android smartphone and “USB modem” mode. No operating system settings are required, since the smartphone is the only network card, traffic is automatically switched to the smartphone gateway and Internet access on the personal computer works.

The second case is that you need a different Internet provider

I decided to simulate the situation: I urgently need to access the Internet, for example, to create a request for repairs, but the Internet via cable from the provider is not available. Of course, you can use the Android application, but you can connect a smartphone that works as a second network card. The problem is that the traffic goes through the first network card where the Internet fails. This problem can be solved using Network Manager, the icon of which is located on the panel next to the clock.

1) Connected the smartphone with a cable to the USB socket
2) Enabled the "USB Modem" mode in the smartphone (Settings - Network and Internet - Access point and tethering mode - USB modem- Enable).

3) In Linux, in the Network Manager applet, I disabled the first (main) network card. Traffic will automatically switch to the smartphone - network card No. 2.

otkl

The Internet has appeared, no actions are required in the Terminal.

exp2

A check on whaitsmyip or a similar site showed that the IP address of the fixed Internet provider changed to the IP address of the mobile operator:

exp

Wi-Fi in the smartphone must be turned off, otherwise traffic will go through the gateway according to the “old” scheme without the smartphone.

Third case - you need to change the default gateway using Terminal

ip route list

ip route | grep default

sudo ip route delete default

sudo ip route add default via 192.168.42.129 dev usb0

where 192.168.42.129 is the IP address that the smartphone gives itself in “USB modem” mode.



Related publications