3

I'm trying to create a wifi hotspot with my Raspberry Pi B+ that redirects the connected devices to a specific HTML page, hosted on the Raspberry. I can create the hotspot following this tutorial. Is there a way to force a HTML page load, like some routers do?

The plan is:

  1. The user will connect to the Raspberry Pi wifi hotspot.
  2. The user device will load a HTML page hosted on the Rasp.
  3. The user will download files through the links on the HTML page.

1 Answer 1

6

You could do that with iptables.

iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination localhost:80
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination localhost:80

This redirects all requests made via port 80 and 443 (i.e. opening any website) to be redirected to whatever is running on your hotspot's port 80.

3
  • So, I'll just need an Apache server running?
    – bodruk
    Jan 20, 2016 at 12:42
  • How do I disable this redirect?
    – bodruk
    Jan 20, 2016 at 13:16
  • 2
    With command: iptables -L --line-numbers you'll get line numbers for rules and then you can delete single line with iptables -D nat 1 for example. To delete all iptables rules you can use iptables -F
    – Bungee75
    Jan 22, 2016 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.