Installing OpenWrt on the Raspberry Pi 5

OpenWrt is one of the most popular router software solutions for rolling out your own router on one of many thousands of devices and wouldn’t you know, the Raspberry Pi 5 is included in that list. 

Whilst not officially supported, it’s available via its SNAPSHOT release system, and we’ve given it a good look to see what’s required to install OpenWrt on the Raspberry Pi 5.

Note!

This guide will assume that you have an RJ45 Ethernet connection for your internet service ready to go, either because it’s delivered directly to your property via Ethernet, or if you have a PPPoE style service, because you have a compatible router in bridge mode. We will not be covering PPPoE (or other more in-depth) configurations as part of this tutorial. 

We’re also assuming that you want to use this immediately as your main router, as OpenWrt will give itself 192.168.1.1 as the IP so adding this to an existing network will require additional steps that don’t fall within the scope of this piece.

If you're not using one of our PCIe HATs for your secondary NIC/WAN port, your device name may not be the one we shared below, and the additional packages in the build may not be required.

What you’ll need

To get started, you’ll need the following:

Preparing the Raspberry Pi 5 for OpenWrt

As we’re not installing OpenWrt on top of an existing operating system, preparation is minimal. All you need to do is assemble your Raspberry Pi 5 and HAT, then connect all the necessary cables. 



The onboard NIC on the Raspberry Pi 5 will operate as the “LAN” port, with the additional port on your HatNET! used as the “WAN” connection, so connect the RJ45 Ethernet cable that your internet comes in from (either to your building, or from a router in bridge mode) to the Ethernet port on the HatNET! Pi HAT.

Downloading OpenWrt for Raspberry Pi 5

As I mentioned earlier, OpenWrt is currently only offering a SNAPSHOT build for the Raspberry Pi 5 as it’s not yet fully supported in an official release. 

This isn’t the end of the world, however, as the SNAPSHOT release has proven itself to be rather stable and suitable for daily use. 

The first step is to head to the OpenWrt Raspberry Pi 5 SNAPSHOT page and then click the Customize installed packages and/or first boot script option. 

We need to add a couple of additional packages here to make sure everything works as expected whilst using the Pineboards HatNET! 1G, so add r8169-firmware,  kmod-r8169, and pciutils to the list of packages in the Customize.. section. These packages install the network interface drivers, and a PCI utilities package so that you can check your NVMe drive (if you’re using one). 



Now, press Request Build and wait for your image to be built. Within a couple of minutes, it will confirm that it’s ready, and then you can download the Factory image with either ext4 or squashfs filesystems.

Installing OpenWrt

The image is now ready to be flashed to either your NVMe SSD, or microSD card. 

We’d generally recommend balenaEtcher for this for ease, and you simply need to open the program, find the downloaded OpenWrt image file in your Downloads folder, and select the NVMe/microSD card you wish to write the image to. 



Once that process is completed, you can install the NVMe SSD (I’m using the Pinedrive 2242 256GB model, naturally) into the HatNET’s M.2 slot, or insert the microSD card into the slot on the Pi 5.

Initial Configuration

On first boot you’ll have a web interface available at http://192.168.1.1 and SSH listening on the default port 22. The username for both will be root with no password by default. 

You’ll first want to configure the WAN port. You can do this by going to Network -> Interfaces -> Add new interface… from the main navigation. 

Name the interface wan (lower-case is important!), select DHCP client and choose eth1 as the device before pressing Create interface. Save and apply your changes, and you’re ready to reboot the system. This can be done from System -> Reboot in the Web UI quickly, or by typing reboot in your SSH terminal. 



When your system boots again, you should then have both LAN and WAN ports, and in theory, a working internet connection being served by your Raspberry Pi 5! You can confirm this by going to the Network -> Interfaces page from the navigation and seeing if your WAN interface has an IP address.

Enabling Wi-Fi Access Point

We have wired networking up and running, but what if you want to live wirelessly? 

Whilst we shouldn’t expect big things from the onboard Broadcom Wi-Fi chip, it is possible to set up an access point in OpenWrt on the Raspberry Pi 5 and, luckily, it’s quite simple! 

Head to Network -> Wireless from the navigation and select Add on the right-hand side on the Cypress CYW43455 802.11ac/b/g/n overview. You’ll be presented with all the configurable options for your wireless access point, so set everything as required, and you’re good to go.

Securing OpenWrt

By default, OpenWrt has no password set for the default root user, and whilst on a local network that might not always be critical, it’s best to set a password and take a few steps to keep things secure. 

For this, we’ll point you in the direction of their own documentation on securing your OpenWrt installation as you can then pick and choose which pieces are relevant to your set-up because, as they note, it’s hardened well by default and, for most users, setting the root password will be sufficient.

Conclusion

At this point, you should have a fully functioning router running on your Raspberry Pi 5. Congratulations! It’s a great feeling when you roll out something like this for the first time as you’re taking a piece of readily available hardware and putting it to use in a meaningful way. 

Is a Raspberry Pi 5 overkill for a router like this? Most probably! During testing, I saw minimal CPU usage whilst routing a full 1Gbit internet connection, and maximum RAM usage was around 120MB. This does make the new, cheaper 2GB Raspberry Pi 5 a solid choice, though there are plenty of add-ons for OpenWrt such as Docker integration, so if you want to run some key apps like network ad-blocking, or a small playground for your home lab, then the additional RAM will come in handy!

Back to blog