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:

Setting Up the Raspberry Pi

With the components ready, it's time to set up the Raspberry Pi. I'd recommend following these steps:

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:

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:

  1. Reboot the Pi to ensure settings take effect.

  2. Start the hostapd service with sudo service hostapd start.

  3. Start DNSMasq with sudo service dnsmasq start.

  4. Enable IP forwarding by running sudo sysctl net.ipv4.ip_forward=1.

  5. 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:

With some tweaking, a Raspberry Pi makes an excellent DIY WiFi range extender for hard to reach areas!