Build a Wi-Fi router
Create a Raspberry Pi-based Wi-Fi router as a secure option for use around the home.
With the release of the Raspberry Pi 4, the networking stack was greatly improved thanks to changes to the hardware, which meant that USB bus was no longer used to make it available to the operating system. In this project, we are creating our own Wi-Fi router using Raspberry Pi OS and RaspAP. Once the initial setup has been completed, the wireless router can be configured via a web interface – much like the products available from popular router manufacturers.
What’s the benefit of making this yourself? Well, the first reason is that cheaper routers aren’t kept updated for very long, possibly leaving security holes. Basing the router on Debian means that the base operating system is incredibly well tested and security updates are released on a regular basis. The web GUI also enables traffic usage graphs to be viewed, connections made to OpenVPN and WireGuard tunnels, the use of ad-blocking DNS services and much more. But enough introduction – let’s begin!
The project is completed in three stages. Stage one is to prepare the microSD card with the Raspberry Pi OS image and enable SSH access from first boot. Stage two is to install the RaspAP software, while the final stage is to configure the router and connect devices to it.
To prepare the image, first of all follow the instructions at the following web address to install the Raspberry Pi Imager tool: www.raspberrypi.com/ software/. Once installed, open it from the launcher and select Raspberry Pi OS (Other) > Raspberry Pi OS Lite (64bit) from the Operating System menu. Next, from the Storage menu, select the relevant microSD card (if multiple options appear in the list, make sure you don’t pick the wrong one because you’ll lose whatever is stored on it). Click on the settings cog and select the options to enable SSH with password authentication, set the username and password, and set the locale to the correct time zone and keyboard layout. Click on OK to confirm the options and then click on the Write button. Wait while the image is being downloaded and written to the microSD card.
When the image has been written to the microSD card, remove it from your device and plug into the Raspberry Pi, and connect the Pi to the power supply and wired network. The lights then flicker as the device boots up. Once booted, you can SSH to the Raspberry Pi from the terminal using ssh
$ sudo apt full-upgrade
$ sudo raspi-config
$ curl -sL https://install.raspap.com | bash
$ sudo reboot
Once you have rebooted the Raspberry Pi, the initial details need to be used to connect a device to the router. These details can then be changed from the web GUI.
IP address: 10.3.141.1
Username: admin
Password: secret
DHCP range: 10.3.141.50 — 10.3.141.255
SSID: raspi-webgui
Password: ChangeMe
Once connected, open a web browser and navigate to 10.3.141.1. Log in with the details above, then navigate to Authentication to change the login password and go to Hotspot > Security to change the details of the SSID being connected to. When we first connected to the new AP, a DHCP address was granted, but it was not possible to browse the web. To cure the issue, first of all edit the /etc/sysctl.conf
file as administrator and uncomment the line that reads net.ipv4.ip_forward=1 . Save the file and then run the following commands before rebooting the Raspberry Pi:
$ sudo iptables -t nat -A POSTROUTING -j
MASQUERADE
$ sudo iptables-save | sudo tee /etc/iptables/rules.v4 In this article, we have only had space to cover the very basics of how to get this tool up and running, so take your time and discover more about the software.