#include #include #include const byte DNS_PORT = 53; IPAddress apIP(172, 217, 28, 1); DNSServer dnsServer; ESP8266WebServer webServer(80); String responseHTML = "" "CaptivePortal" "

Hello World!

This is a captive portal example. All requests will " "be redirected here.

"; void setup() { WiFi.mode(WIFI_AP); WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0)); WiFi.softAP("DNSServer CaptivePortal example"); // if DNSServer is started with "*" for domain name, it will reply with // provided IP to all DNS request dnsServer.start(DNS_PORT, "*", apIP); // replay to all requests with same HTML webServer.onNotFound([]() { webServer.send(200, "text/html", responseHTML); }); webServer.begin(); } void loop() { dnsServer.processNextRequest(); webServer.handleClient(); }