Why isn't my Galaxy S8 popping up my Captive Portal login page?


Question

I'm dealing with a Raspberry Pi 3 that is using hostapd to create its own wireless network.



When an Android client first connects to the network, it tries to grab the page http://connectivitycheck.gstatic.com/generate_204 to see if it's behind a client portal. My Raspberry Pi redirects this request to an instance of nginx that it is running, and returns a 302 redirect to my login page.



Because Android didn't get the response it was looking for (an HTTP 204), but got a 302 instead, from what I understand, it's supposed to popup my login page. I've seen this in action using other captive portal hardware.



In my case however, Android just shows a popup that says "Internet may not be available: Connect to another network or turn on Switch to mobile data".



Am I doing something wrong? Is there something specific Android is looking for in the login page before it will make it pop up?



Most of my testing is on my Galaxy S8. I tried it on a friend's S9, and that doesn't work either. Using a Windows 10 laptop though, the login page does popup.


Answer

After some digging, it appears it's working now.



When a client tries to access http://connectivitycheck.gstatic.com/generate_204, it needs to use DNS to resolve connectivitycheck.gstatic.com first. I had my dnsmasq setup to look like this:



interface=wlan0
dhcp-range=192.168.30.20,192.168.30.60,255.255.255.0,24h
address=/#/10.45.12.1


Where 10.45.12.1 is just a random IP I chose. It didn't really matter what that IP was, because as soon as the client resolves it to that IP, and tries to get /generate_204 from it, my iptables firewall rules would redirect all requests to nginx running on the Pi.



The only limitation I was aware of was that the IP couldn't be on the same LAN (192.168.30.0/24), or the Pi would try to use ARP to figure out its MAC address, and fail, without making the actual HTTP request.



It turned out that if the IP you are resolving everything to (in my case 10.45.12.1) is a LAN IP, Android won't popup the login page. No idea why.



The fix was to change from:



address=/#/10.45.12.1


to



address=/#/1.2.3.4


where 1.2.3.4 is any PUBLIC LAN IP (an IP outside of the '10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16' range). This fixed my problem. Hopefully it fixes someone else's as well.



NOTE: My setup does NOT require the client to ever have internet. They connect to the Pi, and get a page popup for configuration purposes. If you need the device to have internet, which would probably be a more common use case, you probably can't just resolve EVERYTHING to 1.2.3.4 like I do


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes