Using a Raspberry Pi 4B with OpenWRT as a WiFi extender offers a flexible and powerful solution to extend your wireless network. OpenWRT provides extensive customization options and supports a wide range of hardware, making it an ideal choice for advanced networking configurations. By using Alfa WiFi adapters, you can enhance the range and stability of your extended network compared to the built-in Broadcom chip.
Before you begin, ensure you have the following:
The first step is to install OpenWRT on your Raspberry Pi 4B. Follow these steps to get started:
Download the appropriate OpenWRT firmware image for your Raspberry Pi 4B from the OpenWRT website. Make sure to select the correct version for your device (bcm27xx).
1. Go to the OpenWRT website and download the latest firmware version for your Pi4. At the time this article was created, the only option was a snapshot version, so that’s what I am going to download here. The link that will take you to a download: OpenWRT Download Link
Use Raspberry Pi Imager or balenaEtcher to flash the downloaded image to your MicroSD card.
Insert the MicroSD card into your Raspberry Pi 4B and power it on. Connect your computer to the Raspberry Pi via an Ethernet cable.
After booting the Raspberry Pi with OpenWRT, you need to configure it to connect to your network.
By default, OpenWRT assigns the IP address 192.168.1.1 to the Raspberry Pi. Configure your computer's Ethernet interface to be in the same subnet (e.g., 192.168.1.2) and access the OpenWRT web interface (LuCI) by navigating to http://192.168.1.1 in your web browser. If there is no root password defined on this device, use the "passwd" command to set up a new password in order to prevent unauthorized SSH logins.
Connect your Raspberry Pi to the internet. Since the firmware image may not include the web interface, the LuCi package, connect to the Raspberry Pi's terminal via SSH. To install necessary packages, you first need to update the package lists:
opkg update
opkg install luci
After installing LuCI, you can access the web interface. If you intend to use the Raspberry Pi as a Wi-Fi extender, you might also need to install the relayd package:
opkg install relayd
opkg install luci-proto-relay
Configure the Alfa WiFi adapters to connect to your existing network and to create a new wireless network for extended coverage.
Use the command iwconfig to identify the wireless interfaces. The Alfa adapters should appear as wlan0 and wlan1 (or similar).
Configure one of the Alfa adapters (e.g., wlan0) as a client to connect to your existing WiFi network. In the LuCI interface, go to Network > Wireless and configure the wlan0 interface to connect to your existing network's SSID. Make sure to set the country code in the latest Raspberry Pi OS. Then you can go back to OpenWrt where the new country code will be used. Starting with Raspberry Pi 3 B+, the on-board WiFi won't even start if there is no country code.
Configure the other Alfa adapter (e.g., wlan1) as an access point to create a new wireless network. In the LuCI interface, create a new wireless network associated with the wlan1 interface. Set the SSID and password for this new network. For additional security, set up a new password in order to prevent unauthorized SSH logins.
To set up the Raspberry Pi as a WiFi extender, you need to configure the network interfaces and firewall settings.
Create a bridge interface to bridge the client and access point interfaces. This allows devices connected to the extended network to communicate with the main network.
wlan0 (client) and wlan1 (access point) interfaces in the bridge.Configure the DHCP server on the bridge interface to assign IP addresses to devices connected to the extended network.
Configure the firewall to allow traffic to flow between the main network and the extended network.
Setting up a Raspberry Pi as a WiFi extender can sometimes present challenges. Here are some common issues and how to troubleshoot them:
opkg install kmod-usb-core kmod-usb-net kmod-usb-rtl8812au (or the appropriate driver for your adapter).Alfa WiFi adapters are popular choices for extending WiFi networks due to their range and sensitivity. Here's a brief overview of some models and compatibility notes:
When using Alfa adapters, ensure they are properly powered. Some adapters may require an external power source or a powered USB hub to function correctly with the Raspberry Pi.
Here are a few additional tips to enhance your WiFi extender setup:
Here is a summary of the steps to set up your Raspberry Pi 4B with OpenWRT as a WiFi extender:
This table illustrates an example configuration for the network interfaces.
| Interface | Description | IP Address | Protocol |
|---|---|---|---|
| wlan0 | Client (Connects to existing WiFi) | N/A (DHCP Client) | DHCP Client |
| wlan1 | Access Point (Creates new WiFi) | 192.168.2.1 | Static |
| br-lan | Bridge Interface | 192.168.2.1 | Static |
This video tutorial guides you through building a custom router using a Raspberry Pi 4 and OpenWRT. It covers the installation and configuration process, providing a visual aid to complement the written instructions. While the video focuses on setting up a router, the initial steps of installing and configuring OpenWRT are directly applicable to setting up a WiFi extender.
Yes, but Alfa adapters generally offer better range and performance. The built-in WiFi can be used, but the configuration steps remain similar.
It's recommended to use the latest stable version of OpenWRT for Raspberry Pi 4B. Snapshot versions may contain newer features but might be less stable.
Ensure your computer is on the same subnet as the Raspberry Pi (192.168.1.x). If you still can't access it, try reinstalling the LuCI package via SSH.
Use the opkg update command followed by opkg install to install the appropriate kmod package for your adapter.
Yes, this setup can be configured as a travel router. It can very easily be set up as a wireless router, a wired router, a travel router and all of these can be easily configured to optionally use OpenVPN clients.