Altering the Android captive portal web page – en|crypted.at

In case you don’t need your Android telephone to at all times contact a Google server when switching networks, the next article could be helpful!
It’s fairly simple to modify the captive portal examine URL on an Android telephone. However first…
What’s a captive portal?
Ever been related to a public or resort WiFi? Likelihood is, for those who tried to hook up with it, your telephone notified you that you just needed to “Register to Wi-Fi community” – and that’s what a captive portal is: The web page that needs to be accepted earlier than with the ability to surf on the web. In some instances like in a resort, you may need to log in on that web page too. You’ll be able to learn extra about captive portals on Wikipedia.
However, why ought to I modify it?
Nicely, on Android 6 or greater, each time you turn networks, your telephone tries to entry the next URL:
http://connectivitycheck.gstatic.com/generate_204
As we are able to see, gstatic.com – Google’s servers. We’d not need Google to know our new IP tackle or after we switched between networks. So… Why don’t we simply self-host it? It’s fairly simple.
Self-hosting it
To self-host the web page, you simply want an online server and a few capability to return your individual HTTP standing code – we’ll want a “204 No Content material” right here.
Right here’s my PHP script:
<?php
header("HTTP/1.0 204 No Content material");
die();
After that, you may change the URL in your telephone.
Altering the URL
To vary the URL, open up a shell/terminal connection to your telephone. You are able to do this with a Terminal emulator (e.g. Termux) or with adb. In my case, I did it with adb and a USB cable.
To begin the adb session, join your telephone to your PC with a USB cable and enter adb shell
in your terminal. Settle for the dialog in your telephone.

It’s best to now be greeted with a shell: PhoneName:/ $
Change the URL with the next instructions:
settings put world captive_portal_http_url "http://<YOUR-URL>"
settings put world captive_portal_https_url "https://<YOUR-URL>"
Change <YOUR-URL>
with your individual hyperlink. Be sure that your net server doesn’t ahead http:// to https:// as a result of that might imply a 301 standing code as a substitute of 204! It’s best to begin seeing entry entries in your net server log as quickly as you reconnect to your wi-fi community.
My URLs
If you wish to, you may simply use my URLs – logging is disabled right here:
settings put world captive_portal_http_url "http://conntest.yxa.at/204.php"
settings put world captive_portal_https_url "https://conntest.yxa.at/204.php?https"
That’s it!
You’ve now modified your captive portal hyperlink in your Android machine.
You may wish to change the link in your Firefox browser too.