I have a WiFi hotspot setup using Hostapd and Dnsmasq. Everything works great, but I'm trying to trigger the sort of Terms and Conditions page you might see at a hotel or coffee shop after you connect to their captive portal. Most modern devices will automatically bring up this Terms and Conditions page immediately after connecting to one of these captive portal networks, which is what I'd like to happen after connecting to my hotspot.
As I understand it this is usually detected by the device by checking to see if a specific website returns a predictable response. For instance Google seems to test a connection to
http://clients1.google.com and if it gets any response other than "generate204" it should trigger the captive portal agreement page. I've found two ways to redirect all traffic (and presumably these specific domains) to a web server running on my device...
One by adding the following line to
and the other by using
iptables. This triggers from a script on boot:
iptables -t nat -A PREROUTING -d 0/0 -p tcp --dport 80 -j DNAT --to-destination 10.0.0.1
Both succeed in redirecting all traffic to
10.0.0.1 (which is the correct address for the local web server) when manually entering a url into the browser, but the page doesn't open automatically upon connecting to the access point.
I've also tried manually adding entries for specific google URL's like:
/etc/dnsmasq.conf with no luck. I've run out of ideas, any suggestions.