user856232
user856232

Reputation: 1123

Raspberry Pi 3 using Hostapd and dnsmasq how to set default web page on connect

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?

Upvotes: 0

Views: 1405

Answers (1)

Juliano Piassa
Juliano Piassa

Reputation: 18

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

Upvotes: 0

Related Questions