I have an old iPad which has been dropped so many times that a piece of wire fell out the side, and I think that wire was the WiFi antenna. The iPad can only connect to WiFi when itās close to the access point or when the signal is very strong. I figured out that my young daughter could still use it in the kitchen, far from the router, if I put a WiFi repeater in the kitchen. As it turns out, this also extends WiFi to the back patio, which is an added bonus.
I originally used an old Raspberry Pi 1B for this, and thatās still what Iāve mainly been using. Itās a good use for old hardware. It runs headless, with 2 USB wifi dongles, and sits under a cupboard just like lots of other modern appliances.Ā But Iāve also tried this out with models 2B and 3B. The model 3B has an internal wifi interface, so you only need to add one extra USB dongle. The original wifi dongles did not have antennas, and that limited their range, so Iāve recently upgraded to the ones with antennas, as shown in the picture above.
This page was started in the summer of 2018, when I used Raspbian Stretch on a Raspberry Pi 1B, but the most recent revision was in December 2020 and Iāve made some improvements.1Ā I originally used instructions from user Dryfire117 on pastebin2.Ā Ā I later found useful instructions on the Raspberry Pi website.3Ā After going through the process several times and experimenting with variations I have been able to simplify things in several ways. For one thing, you can use either WiFi or wired ethernet for the upstream connection.
Iāve broken this up into several separate pages, because some of these steps are useful for related projects that Iāll be reporting on later, and because I think itās just easier to follow and understand when itās broken into separate parts like this. Here are the key steps:
1. Setup a new SD card
After flashing a new image on an SD card, boot it up and perform the āusualā set of configuration steps, as describe in āRaspberry Pi Initial Configurationā or your other favorite source.
2. Configure Network
We need to configure two networks, the ālocalā network managed byĀ hostapdĀ to be a WiFi Access Point (AP), and the āupstreamā network connection to the internet. The upstream connection can either be wired or also via WiFi.Ā The steps required to set this up have grown to the point that they have been put into a separate page, āNetwork Configuration for a WiFi Access Point.ā
3. Install and configure hostapd
When I originally started doing this, you had to buildĀ hostapdĀ from source code to get the nl20211 driver, but newer versions of Raspbian now include that driver by default, making things a bit easier. There are still a number of steps required to configureĀ hostapd.Ā Follow the instructions in the article āConfiguringĀ hostapdĀ on Raspberry Pi.ā
4. Set up DHCP server
The DHCP daemon is what assigns IP addresses to the computers that join your private network. Follow the instructions in the article āDHCP Daemon on Raspberry Pi.ā
5. Configure NAT routing
Everything so far sets up an access point. Now we also need to configure the routing tables to perform Network Address Translation (NAT) and add a default route. Follow the instructions in the article āRaspberry Pi Access Point Routing Tables.ā
6. Add DNS servers (optional)
The fileĀ /etc/resolv.confĀ contains the names of Domain Name Service (DNS) servers, but on Raspberry Pi this file gets overwritten at each reboot. It will probably contain the IP address of your upstream router, but nothing more. It is useful to have more nameservers for redundancy, in case one of them has a problem. Also, I now have aĀ piHoleĀ DNS server on my local network, and Iād like to have anything on my internal network use that. The simplest way to do this is to edit the fileĀ /etc/resolvconf.confĀ and add a line like this:
name_servers=192.168.1.29 1.1.1.1 8.8.8.8
- Take a look atĀ /etc/resolv.confĀ after a reboot to confirm that these made it into the list.
7. Add Monitoring (Optional)
Since this device will run headless it can be useful to have a status display provided by a web page. This is easily done by adding a web server, either Apache or NGINX, which is described well on the Raspberry Pi website.4Ā In either case the main web page for the server lives in the directoryĀ /var/www/html/. You could make a simple HTML web page in the fileĀ index.html, or something more dynamic as a PHP script calledĀ index.phpĀ (such asĀ this).
8. Save Everything
Itās useful to have a list of all the files youāve modified to make this all work, so that you can go back and make checks or changes, so that you can make backup copies, and so that you can easily deploy the same files to another machine. I put the list into a file calledĀ wifipi_files.txt:
/etc/network/interfaces /etc/network/interfaces.d/ /etc/default/hostapd /etc/hostapd/hostapd.conf /etc/default/isc-dhcp-server /etc/dhcp/dhcpd.conf /etc/resolvconf.conf /var/www/html/index.php
It is then simple to make a tar archive (tarball) containing just these files, using the commandtar -czP --files-from=wifipi_files.txt -f wifipi.tgz
TheĀ -PĀ flag preserves the full file path when the file is saved in the tarball. To deploy these files on another machine simply copy the tarball to the other machine and (as root or using sudo) give the commandtar xzf wifipi.tgz
to extract them into place.
Source: RASPBERRY PI WIFI ACCESS POINT