Skip to content

Instantly share code, notes, and snippets.

@stdevPavelmc
Last active September 15, 2022 15:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stdevPavelmc/95772805e1cbc666781703a7af531cc4 to your computer and use it in GitHub Desktop.
Save stdevPavelmc/95772805e1cbc666781703a7af531cc4 to your computer and use it in GitHub Desktop.
How to use your Android Phone as a 3G/4G modem and save you mobile data

How to use your Android Phone as a 3G/4G modem and save you mobile data

Este tutorial tiene una versión en español

Why?

Maybe you has a plain data plan with your cell carrier and this don't care to you, but in Cuba the data plans are expensive and we need to squeeze even the last byte of data from it

Some times you face this scenario: You connect your Cell Phone to the mobile data and set it up as a WiFi hostspot to share the internet with your work PC or Laptop; this is Ok, but then you have a dual waste of bandwidth; yes, think about it:

You use Telegram (Desktop), Messenger (web), Facebook (web), Twitter (web/desktop), etc in your PC/Laptop because it's easy to write on the keyboard and because why not? but your Android apps are on and updating in your cell phone: if you send a picture it will be sent from the PC to the internet and then downloaded from the internet to your phone app, right? double waste of bandwidth.

Not to mention the Android & Apps background updates...

Some clever guy may say, just kill the app in the cell phone! yes, but no, they are on in the background...

Solution

Use a firewall, - Stop there mister! - (clever gyu again:) - firewall apps usually works creating a VPN and the WiFi sharing do not work! - yes you are right, but there is a catch 22 with this

Use the right firewall and cable tethering (not WiFi)

There is at least one Android app that works in a way we can exploit: No Root Firewall

Just go to the Play store or use any other mean to get and install a updated version of this app; why this one? well it has a secret:

Firewalling via DNS

Yes, the main action of No Root Firewall app is to deny the response for the DNS queries for the baned apps, fire the app, go to the tab named APPS block all apps but the No Root Firewall app itself (red crosses on the Mobile data column, left the Wifi column unchanged) start the firewall app and connect your mobile data

No traffic or app must notice the internet connection (see Final Words section below)

Connect to the PC/Laptop

Go and connect your Cell Phone to your PC, select Phone charge mode on your cell, go to Setting, Connections, Hotspot (the right way vary with your phone and Android version) and you must see an option for sharing the connection via USB, go an activate it

Your PC must see a new ethernet connection (wired connection) and setup it as a DHCP and all dynamically, no worry, no fuzz... go, try to use google in the browser, no joy, right?

Tweaking your network connection

Go to your OS network settings, select the newly USB connection created and do this (just directions and no pictures as per your OS and versions it will change)

  • Select IPv6: then disable it This step is important
  • Select IPv4:
    • Left the DHCP option activated
    • Switch to custom DNS and set at least two, I use the cloudflare ones 1.0.0.1 and 1.1.1.1 others may set the google ones 8.8.8.8 etc

Apply the config, go to your browser and search something on Google... it must work now, joy...

Congratulations

You are using your Cell phone as a plain old modem and all the consumed bandwidth will be from the PC/Laptop

Final words

Some caveats and comments:

  • Some times when you start the firewall app some apps appears to get connection and works even when you explicitly denied it, this is a side effect of a recent connection, as the firewall (appears to) works with the DNS and the apps has a recent connection it knows the IP and do not need to make any DNS resolution; the it can sneak trough the firewall for a while.
  • The previous mentioned "bug" has increased the bad reputation of the app (It does not work!, it's Crap!), but has a simple fix: always wait at least 5 minutes from the last full internet connection (in disconnected state) before turning on the firewall and then mobile data (the order is important)
  • This trick may also work with the Wifi hotspot & bluetooth and not just the cable tethering, but it will not work on all phones and with all Android versions, you have to test it, some users have reported that it's some time slow and buggy, the cable variant is 100% stable.
  • Depending on the Android version there is a catch, the USB tethering tends to change the MAC address of the device, so you may need to configure the network parameter every time you connect it for certain phones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment