1

I have an RPi3 with Raspbian. I have installed hostapd, dnsmasq, and LAMP.

I have built a web site on this device that all works as I want.

I would like to force any use that attaches to the wifi ap of this device to always browse to the home page of the web site.

The local AP IP address is 192.168.30.1. There is a default index.php page.

How can I make it so that if someone on their phone or computer connects to this wifi and then opens their browser it will always show my home page?

I don't need to have them then log in and be able to access the internet. I just want all addresses to resolve to the local web server.

It can't be the same page on the server because there are several pages that get browsed to in the site.

It is fine to tell them other pages on other sites they try to manually browse to just are not available (404 or whatever).

The main thing is that I don't want them to have to type 192.168.30.1 into their browser to start them browsing. I want that to be automatic somehow.

I did try setting the dsnmasq config address=/#/192.168.30.1

That helps make it so they can't break out of the box, but it doesn't help starting them off when they first open their browser.

1 Answer 1

1

There are two approaches here, but both have problems.

  1. The user may not have a homepage set up that actually connects to anything, so they will simply get their local start page (e.g. in Firefox this is simply a search bar, not a page from the Internet). Getting the user to navigate to your page is going to be a problem if you can't tell them what to type in the address bar.
  2. Almost anything they do once connecting (e.g. open their e-mail/Facebook etc) is going to be a HTTPS connection, and even typing into their browser's search bar will connect to Google/Bing/whatever using HTTPS. You will not be able to do anything with HTTPS traffic, as if you try to change it to your own site the user will receive a big red warning that something is wrong or their connection security is broken (which it is).

You will have to hope that users connect to something using HTTP and intercept them with something like this. Even if you do manage to intercept normal HTTP traffic using iptables rules or something similar, HTTPS is rising very fast thanks to LetsEncrypt and other factors, so this is only going to be less and less useful as time goes on.

Finally, even if you do redirect them only to your own page and not provide Internet, then phones, tablets and even laptops will think this is just a wifi log in page. If you don't let the device see the Internet after a short amount of time, they will think the "login" has failed, and disconnect from your AP as a "bad network", meaning you can't serve the page to them any more.

You need to get them to type in the address I'm afraid.

Your Answer

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

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