30

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?

Sagar Vaghela
  • 403
  • 1
  • 6
  • 9

3 Answers3

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

Manu
  • 3,094
  • 7
  • 22
  • 40
RyanDH
  • 476
  • 4
  • 4
  • 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 06: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

Άνδρας
  • 1,113
  • 1
  • 8
  • 16
  • 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 09: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 09:11
  • Which is the specific URL on which android request. I have mention in question. – Sagar Vaghela Sep 15 '15 at 09: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 09:28
  • 2
    The URL seems to be http://clients3.google.com/generate_204 . Information taken from this site for chromium which is probably the same for android. https://www.chromium.org/chromium-os/chromiumos-design-docs/network-portal-detection – benjamin Sep 15 '15 at 09:34
  • @Alex.S: I am not sure if it's relevant to ask this here, but I couldn't find a suitable place. Question is: As you said 'There are several implementations' of captive portal. Some returns a redirect URL with a HTTP status code as 200/3XX/511 and some returns HTML page as such. These are known to me, but I wanted to know if you did find any link describing the types/methods of captive portal implementation. Are you aware of any test suites to verify if the captive portal detection covers all types of portals. – Vivek Maran Oct 04 '17 at 13:26
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.

Jude Osborn
  • 121
  • 2