[Networking] praclika:
My simplified solution

I thought about how to simplify my solution.

I search which IP addresses use my phone by default.

So only need to setup this gateway IP and a DNS Server on PC's side.

This is an only for Linux guide. I do not guarantee that work in all cases. My phone is Android 4.4.2 device and I use Arch Linux on my PC.

If you have Windows, you only have to follow the instruction which your phone writes in the first step. In this case you have to choose your Windows version from the phone's menu!

1. Plug the phone into your PC.

Turn on USB internet mode.

You have to choose Windows PC internet..., not simple USB tethering option. In this example I choosed Windows 8 from this menu. If you choose other Windows version, your phone will have other gateway and device IP address. Please replace in the commans 192.168.137.1 to your gateway IP!

This contains the IP-s depending on choosen Windows version:

Windows XP, Windows Vista

Gateway IP

: 192.168.0.1

rndis0 (your device name can differ) IP

: 192.168.0.100

Windows 7, Windows 8

Gateway IP

: 192.168.137.1

rndis0 (your device name can differ) IP

: 192.168.137.100

If these don't work, you can watch the gateway IP in phone's Terminal Emulator with these commands:

a) su

b) ip route list

You have to watch this line: default via 192.168.137.1 dev rndis0

If you want to watch the phone's IP use "ip a" command instead of "ip route list". You don't need this. You only need the gateway IP.

2. Open a terminal in your PC

3. ip a

This command will list devices. Device name is not the same as in your phone.

In this example the device is "enp".

You have to change in this commands "enp" to your device!

If you don't know which device is your phone, use "ip a", before you plug the phone. You will see the difference between plugged + enabled USB internet option, and unplugged.

4. sudo ip link set enp up

5. sudo ip addr add 192.168.137.1/24 dev enp

Don't forget to change gateway IP and device name to yours!

6. sudo su

7. echo 1 > /proc/sys/net/ipv4/ip_forward

8. If you don't have dnsmasq, install it!

You have to edit /etc/dnsmasq.conf. You can do this for example with this command: "nano /etc/dnsmasq.conf", Save: Ctrl+O, Exit: Ctrl+X.

/etc/dnsmasq.conf has to contain only this line:

listen-address=192.168.137.1

9. systemctl start dnsmasq

If you don't have systemd, you can use this command: "dnsmasq"

10. iptables -t nat -F

11. iptables -t nat -A POSTROUTING -j MASQUERADE

This will work with unrooted devices too, which have USB internet option, except from if your default gateway and nameserver IP differs, because in this case you can't use "ip route list" command to watch your own.

Try to edit /system/etc/resolv.conf if you have DNS problem. I wrote it in my previous guide! You can edit /system/etc/resolv.conf only with root access. If you use Linux with working dnsmasq and right setup, DNS problem can't happen. If you use Windows and don't have root access on your phone, try to setup a DNS server on your Windows machine with the gateway IP.

If my guide doesn't work try to unplug the phone, restart PC and phone and repeat my instruction.

If my guide works for you and after this setup you unplug and replug your phone without rebooting your PC, you can get it working again with these steps:

1. Enable USB internet option again, after plugging the phone

2. Use this 2 commands on your PC:

sudo ip link set enp up

sudo ip addr add 192.168.137.1/24 dev enp