I want to build a Captive portal and an access point on a Ubuntu machine and redirect every incoming traffic to localhost. I started by redirecting all my incoming tcp traffic on every port to a simple login page locally served via an Apache Web Server. I then dropped all the forwarded packets. All this through iptables as shown below.
$IPTABLES -t nat -A PREROUTING -p tcp --dport 0:65535 -j DNAT --to-destination 192.168.6.1:80
$IPTABLES -t filter -A FORWARD -p tcp --dport 0:65535 -j DROP
$IPTABLES -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
When a client such as iPhone connects to the access point, opens up safari browser and enters any URL it is successfully redirected to login page (but not any google search from the address bar)
The place I am struck is forcing an auto browser pop up from iOS device when it connects to my access point. I know it tries to ping apple.com and some others like www.apple.com/library/test/success.html
for success response on connecting and if there's no desired response it opens up a miniature pop up browser. But I already blocked every traffic and redirected to login page(captive portal).
The places I think I am going wrong is maybe I should not block all the tcp ports, only some like 80 and 443, maybe I should block some UDP traffic. Is there something I should also alter in my login page. I read somewhere that iOS only pops up a browser when it gets a wispr XML response from the redirected URL.
Any help in this regard would be beneficial. I promise I would write a detailed blog post once this gets done.