28

When the device tries to connect to an access point or router, it has to sign in on the captive portal page with the message saying

"Sign in to Wi-Fi network".

How does the access point/router identify that a sign in is required for the device and what is the process behind it?

32

The detection url differs between different Android versions.

For Marshmallow, it uses connectivitycheck.gstatic.com/generate_204, check the code here AndroidXRef - Marshmallow 6.0.0_r1

For Kitkat, it uses clients3.google.com/generate_204 check the code AndroidXRef - KitKat 4.4.4_r1

  • actually this is much better answer and should be marked as the correct answer – Moataz Elmasry Dec 14 '16 at 14:18
  • I didn't want to hijack the answer by editing it, so I'll just leave a comment. It took me a while to realize that the detection URL triggers the notification if it cannot be reached. In addition, I needed my access point to respond to this request with some kind of content - in my case I returned a 200 code as well as the index page of my web server when /generate_204 is requested. Without content in the response, regardless of the return code, I would get a "Wi-Fi has no Internet access" notification. – ubomb Jan 19 '17 at 23:29
  • @ubomb Seems odd, since http://connectivitycheck.gstatic.com/generate_204 actually returns a 204 with no content, and obviously works. Maybe you just left out the Content-Length: 0 header. – Tamir Daniely Jun 17 '18 at 6:22
9

This technology is called "Captive portal". There are several implementations. As I know, Android tries to reach a file named generate_204 on one of the Google servers and if it is not possible, a notification in generated.

Further reading on Wikipedia: Captive_portal

  • Actually i know about captive portal. But i know the specific URL for check it. I want to know How it is work. Not what it is. – Sagar Vaghela Sep 15 '15 at 9:07
  • 1
    What do you mean - "how it is work"? Android sends a request, and if there is no positive response, it means that there is no connection to the internet, and notification is generated. That's how it works. – Άνδρας Sep 15 '15 at 9:11
  • Which is the specific URL on which android request. I have mention in question. – Sagar Vaghela Sep 15 '15 at 9:15
  • 2
    In your previous comment you said that you know the specific URL. I think it's https://www.gstatic.com/generate_204 – Άνδρας Sep 15 '15 at 9:28
  • 2
    The URL seems to be clients3.google.com/generate_204 . Information taken from this site for chromium which is probably the same for android. chromium.org/chromium-os/chromiumos-design-docs/… – benjamin Sep 15 '15 at 9:34
2

A captive portal is generally implemented by directing all traffic to a valid HTTP response (200). This HTTP response is what appears in the captive portal.

This can be done with tools like iptables or dnsmasq.

protected by Community Jun 29 '17 at 8:08

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.