I'm trying to set up a 'captive portal' type pi webserver. Once someone connects to my Raspberry Pi I'd like them to be redirected to a locally hosted webpage. The pi doesn't have an internet connection - so it's closer to something like the PirateBox.
So I've been following a whole host of different tutorials on creating 'captive portals' on linux / pi - and have most of it working. Well, I have the DHCP working and I can serve pages with lighttpd (or node) and if hit the correct IP address you get re-directed to the default page.
However, the bit I can't get is iptables to redirect all incoming traffic to a single IP address. I've tried countless different ways with no joy - so I feel like I might be missing something else.
wlan0 is my wifi
192.168.42.1 is the pi's address
Here's one of the many attempts I've made to get it working:
Code: Select all
sudo iptables -t mangle -N internet sudo iptables -t mangle -A PREROUTING -i wlan0 -p tcp -m tcp --dport 80 -j internet sudo iptables -t mangle -A internet -j MARK --set-mark 99 sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp -m mark --mark 99 -m tcp --dport 80 -j DNAT --to-destination 192.168.42.1
Many thanks for any suggestions!