USB Reverse Tethering No Root No ADB Android (all versions) & Linux - Quick Mode
This guide allows you to share the Internet connection of a Linux PC with your smartphone via a common USB cable that is also charging your phone. This is useful if you can not or want to use the WIFI on your smartphone and you do not want to consume traffic from your data plan. A good reason to limit the use of wireless connections on your phone is the electromagnetic pollution hitting your body. But that's another story.
The important thing about this guide (uncommon on the web with Linux machines) is that it is not required that your phone is rooted. Then, I repeat it, all works without Rooting your precious smartphone. Unfortunately, this involves that some apps (but not the most important) require the fictitious use of the data connection at least, because you can not install Xposed modules to workaround the stupid limitations of these apps. But this is the lesser evil.
This guide requires only the built-in Android usb tethering function and a Debian based Linux PC and so it works on all Android versions without even the need to install ADB (Android Debug Bridge) on Linux. The only limitation is that it only works for a single Android device at a time. If you want to use multiple devices simultaneously follow and adapts in an obvious way the guide here.
Initial quick configuration
Copy and paste the following in the terminal of your Debian based Linux machine which it is supposed to be connected to the Internet via the "eth0" interface (check your correct interface via "sudo ifconfig" and then change it below accordingly):
sudo apt-get update
sudo apt-get install openvpn
sudo ufw allow from 192.168.42.129
sudo openvpn --genkey --secret static.key
sudo cp static.key /etc/openvpn/static.key
cat <<EOT >> android.conf
ifconfig 192.168.7.28 192.168.7.29
keepalive 10 60
sudo cp android.conf /etc/openvpn/android.conf
cat <<EOT >> /etc/network/interfaces
#Tethering configuration allow-hotplug usb0
iface usb0 inet static
pre-up /usr/sbin/openvpn --config /etc/openvpn/android.conf --daemon
up iptables -t nat -A POSTROUTING -s 192.168.7.0/24 -o eth0 -j MASQUERADE
up sysctl -w net.ipv4.ip_forward=1
down /usr/bin/killall /usr/sbin/openvpn
down iptables -t nat -D POSTROUTING -s 192.168.7.0/24 -o eth0 -j MASQUERADE
down sysctl -w net.ipv4.ip_forward=0
cat <<EOT >> smart.conf
# Enables connection to GUI
management /data/data/de.blinkt.openvpn/cache/mgmtsocket unix
connect-retry 5 300
remote 192.168.42.128 13444 tcp-client
ifconfig 192.168.7.29 255.255.255.255
route 0.0.0.0 0.0.0.0 vpn_gateway
dhcp-option DNS 126.96.36.199
dhcp-option DNS 188.8.131.52
dhcp-option DOMAIN blinkt.de
#persist-tun also enables pre resolving to avoid DNS resolve problem
# Use system proxy setting
# Custom configuration options
# You are on your on own here :)
keepalive 10 60
echo "<secret>" >> smart.conf
sudo cat static.key >> smart.conf
echo "</secret>" >> smart.conf
Copy the file "smart.conf" which is in your Home folder into your smartphone memory. Install from Google Play Store the app "OpenVPN for Android" on your device. Finally open "OpenVPN for Android" and in global "settings" uncheck the option "Reconnect on network change". Then import from the top right icon the file "smart.conf" you had saved earlier. Save the new created profile and later from pencil icon go to "Routing" tab: there select "Use default Routing" in IPv4 menu and exit. Optionally create an "OpenVPN for Android" widget on your home screen that links to your profile. Reboot your linux machine. Finished.
To connect your smartphone to internet via lan connection of your Linux PC just connect your Android device via usb cable to the Linux PC, enable usb tethering in "settings -- Wireless and Networks -- Tethering" on your Android device, then temporarily enable your phone data connection (2G/3G/4G) and tap on your "OpenVPN for Android" widget (or on the profile name in "OpenVPN for Android" app). If you read "success" somewhere at the top (log screen), you're OK.
You can then disable phone data connection if you use Browsers such as Chrome or many other app such as WhatsApp.
Anyway some apps (as Gmail, Download etc.) check if a wireless connection (WIFI or 3G) is present at boot otherwise they will not start or work, so they require at least data connection enabled to work. Nevertheless all internet traffic is always routed over the usb connection and therefore your data plan is safe. Furthermore, for the same reason, your body is subjected to a considerably lower electromagnetic pollution. Enjoy!
Note: this tutorial assumes that the IP address of your smartphone in USB tethering mode is 192.168.42.129, as it should be. Check this by typing "netcfg" in "android terminal" app of PlayStore and eventually change it accordingly above, together with the 192.168.42.128 address of "usb0" interface.
Update: I have adapted this guide for Windows users here.