Having weak WiFi signal in parts of your home or office can be frustrating. While you can buy commercial WiFi extenders, making your own DIY WiFi extender with a Raspberry Pi is inexpensive and can give you better performance.
What You'll Need
Building a Raspberry Pi WiFi extender is a straightforward project with just a few components needed:
-
Raspberry Pi - Any Raspberry Pi model will work, but a Raspberry Pi 3 B+ or newer is recommended for best wireless performance. The Raspberry Pi acts as the brains of the WiFi extender.
-
MicroSD Card - You'll need a microSD card with Raspbian (the official Raspberry Pi OS) installed. An 8GB Class 10 card is sufficient.
-
USB WiFi Adapter - This will connect your Raspberry Pi to the existing WiFi. Choose an adapter that supports monitor mode and wireless extensions. Popular options include the Alfa AWUS036NHA and TP-Link TL-WN722N.
-
Ethernet Cable - To connect the Raspberry Pi to your wired devices. Cat 5e or Cat 6 Ethernet cable is preferred.
-
Power Supply - A 5V micro USB power supply, at least 2.5A, is required to power the Raspberry Pi.
-
Case (optional) - Having a case isn't strictly necessary but helps protect the Pi. Many affordable cases are available.
Setting Up the Raspberry Pi
With the components ready, it's time to set up the Raspberry Pi. I'd recommend following these steps:
-
- Flash the Raspbian OS onto the microSD card. Use Raspberry Pi Imager or Etcher to install Raspbian Buster Lite.
-
- Insert the microSD into the Pi and connect it to power to boot it up.
-
- Connect to the Pi via SSH since Raspbian Lite runs a command line interface only. On Windows, use PuTTY.
-
- Run
sudo raspi-config
to expand the filesystem and enable SSH.
- Run
-
- Update the system with
sudo apt update && sudo apt full-upgrade
. Reboot.
- Update the system with
-
- Configure the wireless interface by editing /etc/network/interfaces. Set the Pi to connect to your existing WiFi network.
-
- Reboot to ensure the Pi connects to the WiFi router successfully. Check with
ifconfig wlan0
and pinging the router.
- Reboot to ensure the Pi connects to the WiFi router successfully. Check with
Installing Software for a WiFi Extender
With Raspbian set up on the Pi, we can now install the software components to turn it into a WiFi extender:
Hostapd - The WiFi Access Point Daemon
The most important piece is hostapd (Host Access Point Daemon). This allows the Raspberry Pi to act as a WiFi access point that wireless devices can connect to.
Install it with:
sudo apt install hostapd
Hostapd requires some configuration which we'll cover next.
DNSMasq - A Lightweight DHCP and DNS Server
With hostapd, the Pi will act as a WiFi access point. DNSMasq provides vital DHCP and DNS services to the devices connected to the Pi's access point. Install with:
sudo apt install dnsmasq
IPTables - Routing Between Networks
IPTables provides routing and NAT (Network Address Translation) capabilities so that connected devices can access the wider network. Install with:
sudo apt install iptables
Some IPTables configuration is needed as well.
Configuring the Raspberry Pi WiFi Extender
With the main software components installed, the next step is configuring them to work together to create the WiFi network.
Configuring Hostapd
Hostapd requires a configuration file at /etc/hostapd/hostapd.conf to set up the access point.
Here are key parameters to include:
-
interface - Set to the Pi's wireless interface, typically wlan0.
-
ssid - The name of the WiFi network.
-
channel - The WiFi channel to use, between 1-13. Pick the least congested channel.
-
wpa and wpa_passphrase - The WiFi password for connecting to the network. Use a strong password.
-
bridge - Bridges the wireless interface wlan0 to the Ethernet eth0.
After creating the hostapd configuration file, edit /etc/default/hostapd to enable it:
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Configuring DNSMasq
DNSMasq also requires some configuration to allocate IP addresses and set the DNS server.
Edit /etc/dnsmasq.conf to uncomment or add these lines:
interface=wlan0
dhcp-range=192.168.200.50,192.168.200.150,12h
domain=YOURDOMAIN
address=/YOURDOMAIN/192.168.200.1
This enables DHCP, sets a pool of IP addresses to assign, and sets the Pi as the DNS server.
Configuring IPTables
IPTables routes traffic between the wireless network and wired Ethernet interface.
Add these rules to /etc/iptables.ipv4.nat:
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
This masks (NATs) traffic going over the Ethernet connection.
Save and exit the files after making changes.
Bringing Up the WiFi Extender
Once fully configured, we can bring up the Raspberry Pi DIY WiFi extender. Follow these steps:
-
Reboot the Pi to ensure settings take effect.
-
Start the hostapd service with
sudo service hostapd start
. -
Start DNSMasq with
sudo service dnsmasq start
. -
Enable IP forwarding by running
sudo sysctl net.ipv4.ip_forward=1
. -
Apply the IPTables rules with
sudo iptables-restore < /etc/iptables.ipv4.nat
.
After a minute or two, the Pi should be broadcasting the new WiFi network. Connect your devices to test it out. The extended network should route traffic back through the Pi's Ethernet connection.
Optimizing the WiFi Extender
To optimize the DIY WiFi extender, try these tweaks:
-
Experiment with hostapd settings like WiFi channel and transmission power to improve coverage.
-
Use a directional antenna with the Pi's USB WiFi adapter to better reach the main router.
-
If needed, attach a second USB WiFi adapter to dedicate one for connecting devices.
-
Adjust DHCP IP ranges in dnsmasq to reduce conflicts with main network.
-
Set a static IP address on the Pi wired connection if issues with rebooting.
-
Update to the latest hostapd and dnsmasq versions for performance fixes.
With some tweaking, a Raspberry Pi makes an excellent DIY WiFi range extender for hard to reach areas!