ESP32-C3 Captive Portal with DNS Redirection and Auto Popup Implementation #11558
Replies: 1 comment
-
Even if DNS redirection’s doing its thing, the captive portal popup still won’t show up unless you’re handling those OS-specific endpoints right-stuff like /generate_204, /hotspot-detect.html, and /ncsi.txt. You’ve gotta hit those with proper 302 redirects, or the device just won’t care. Also, make sure your DNS response looks legit-standard formatting, AA bit set-otherwise the client might just ghost it. Setting up a catch-all route for random URIs is a smart move too, it catches curveballs and makes things smoother across different devices. Fire up Wireshark or something to make sure the phone’s actually hitting those known probe URLs, and double-check that your HTTP headers are all in place. Every little bit counts. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When I connect to the Wi-Fi Soft AP, it prints the received DNS requests as expected as you can see below. However, the webpage does not automatically pop up on my smartphone.
I believe it should work because the code sends a DNS response with the predefined IP address “192.168.4.1” using sendto(sock, response, pos, 0, (struct sockaddr *)&client_addr, addr_len);. The DNS request is caught and answered correctly, but the browser does not open the page automatically.
BTW, the web server and HTTP handlers seem to be functioning properly because when I manually enter “192.168.4.1” in the browser, the HTML page defined in the code is displayed.
I would really appreciate your help with this.
I (23669) dns_redirect: Received DNS request for: connectivitycheckgstaticcom
Response size: 512
Response position: 63
I (23679) dns_redirect: Received DNS request for: wwwgooglecom
Response size: 512
Response position: 48
I (23749) dns_redirect: Received DNS request for: mtalkgooglecom
Response size: 512
Response position: 50
Beta Was this translation helpful? Give feedback.
All reactions