31

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?

3 Answers 3

35

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

2
  • 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
    Commented Jan 19, 2017 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. Commented Jun 17, 2018 at 6:22
10

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

6
  • 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. Commented Sep 15, 2015 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. Commented Sep 15, 2015 at 9:11
  • Which is the specific URL on which android request. I have mention in question. Commented Sep 15, 2015 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 Commented Sep 15, 2015 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
    Commented Sep 15, 2015 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .