Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Captive portal without internet on Android

Good day. I need Captive Portal on the WiFi hotspot that will work without internet and popup a notification or open a login page automatically. I am using Mikrotik with RouterOS 6.27. I created hotspot and then added a RegExp in DNS like

.* = HOTSPOT_IP_ADDRESS

It works fine in Windows and iOS since their captive portal detection is based on getting the response from some website. Afaik - any response. But for Android it must be some special response, with empty content or status code 204 - I am still not sure.

I tried to emulate google pages which give 204 or empty response and did redirection to my server with this emulation pages but it did not help Android to show notification.

So I need help to make captive portal notification in Android without internet.

Thanks.

like image 783
Taras Avatar asked Apr 24 '15 19:04

Taras


1 Answers

Everytime your phone gets associated to the APs it will send an initial test URL request. It's a feature of Android to detect that it is trapped and offer to take the user to the splash page so the user can login and release from the trap.

Just make sure that Android's test URL file is allowed to pass the walled garden.

For reference, default Android 4.0.1 AOSP test URLs is http://clients3.google.com/generate_204, which always returns a 204 response code. Even if DNS has been interfered with since in that case a 200 code will be returned instead of the expected 204.

Also, there are some variations with fetching http://www.google.com/blank.html, which will return a 200 code with zero-length response body. So if you get a non-empty body this would be another way to figure out that you are behind a walled garden.

like image 51
Ciro Pedrini Avatar answered Oct 29 '22 23:10

Ciro Pedrini