📜 ⬆️ ⬇️

Reverse tethering (get internet on android from linux pc)

Since I have a slow Internet 3g in the place of using the phone, it was decided to try to use the Internet from the computer, on the phone. I was surprised that this is not possible with standard tools. I decided to make it non-standard. So, we will need:
1. busybox
2. root
3. GScript Lite, or terminal emulsion. GScript is better, since it allows you to make a label on the slave table so that it does not soar all the time with the script.
4. Ifconfig utility can be useful, there are many options for android, choose the one that is similar to Linux ... I mean full (but this utility is for reference only, for example, if the name of the network interface that you created to communicate with the computer changes).

Do it like this:
1. We interface the phone with the computer ... well, it's clear here and complete instructions.
2. On the phone, go to the settings-> more-> Modem Mode-> "Shared Internet via bluetooth" and set the checkbox.
2. We climb into the bluetooth applet and select "parameters" (this is on the computer). I use ubuntu so there is an applet, for other distros there are other options and you yourself know where to click.
3. In the parameters we see our phone (we matched it). Go to it and select "Use as a network device (PAN / NAP)". It’s better to do it once, NetworkManager, it remembers each time separately and doesn’t erase past ones, so I have a list there, twenty items from my phone’s copies. Later, the script roll straight, of course. You can look in the direction of blueman, he can do the same.
4. We climb into NetworkManager and, lo and behold, our phone is there, clicked on it.
5. In the phone, if item 2 is completed, an alert will come “will it allow the access point to connect?”. Allow.
6. PROFIT1 !!! The network has risen. I get on my computer address 192.168.44.39, on the phone 192.168.44.1
7. On the computer, we run this (I have been in the starting scripts for a long time, for households):
#!/bin/sh modprobe ipt_MASQUERADE iptables -F; iptables -t nat -F; iptables -t mangle -F echo 1 > /proc/sys/net/ipv4/ip_forward iptables -A FORWARD -s ip__(192.168.44.1) -j ACCEPT iptables -A FORWARD -d ip__(192.168.44.1) -j ACCEPT iptables -t nat -A POSTROUTING -o ____(wlan1    ppp0  eth0) -s ip__(192.168.44.1) -j MASQUERADE 

We launched NAT so that packets from the phone, which came to us, send further to the Internet. I mean, they became the gateway.
8. We write the following in the GSCript or terminal (on the phone):
 busybox route add -net default gw ip__(192.168.44.39) _____(btn0) 

btn0 is just the name of the network interface that is connected to the computer on the phone.
This command requires root access on the phone.
9. PROFIT2 !!! We have a working Internet on the phone, via the computer, via bluetooth.

Now I have a shortcut on the desktop of my phone for setting the default gateway (GSCript). I create a network with a phone, and then I launch a shortcut. The Internet plows, it takes a few seconds to get to the browser or someone else there in the guts, it seems that the Internet is already there. It remains only to make a script on a computer, so that the network can be lifted from the same button, or find a software for an android that can do this with the same button from the phone. From the phone it will be more convenient. That's all.

')

Source: https://habr.com/ru/post/152080/


All Articles