0

I have set up hostapd and dnsmasq to run on my Raspbian RPi3. This works great.

I also have apache2 running on this RPi with a web site.

How do I now make it so that everyone who connects to my RPi AP gets redirected to the default page of the web site running on the RPi?

user856232
  • 1,073
  • 2
  • 14
  • 40
  • I've never actually done this, so I'm not confident enough to make this an answer, but I think what you're looking for is a "captive portal", such as nocat or wifidog. – jasonharper Apr 26 '17 at 20:40
  • That should work for my needs. Please repost as an answer so I can mark it so... – user856232 Apr 27 '17 at 01:03

1 Answers1

0

You can achieve this in two ways:

The first is using IPTABLES rule to redirect all traffic to your server on port 80

sudo iptables -t nat -A PREROUTING -d 0/0 -p tcp --dport 80 -j DNAT --to-destination 111.222.333.444:80

You will need to install iptables-persistent to keep this rule after reboot/shutdown.

The second one is using an dnsmasq option on /etc/dnsmasq.conf:

From dnsmasq man: Add domains which you want to force to an IP address here. The example below send any host in doubleclick.net to a local webserver.

address=/doubleclick.net/127.0.0.1

You can also use a wildcard to redirect all traffic from all sources/domains to your webserver.

address=/#/127.0.0.1