Simple Raspberry Pi WiFi Extender

A Raspberry Pi WiFi Extender is a cheap and power efficient way of increasing the total range of your WiFi Network. A WiFi extender differs a fair bit from a WiFi access point.

Raspberry Pi WiFi Extender

The main difference being that instead of getting its network connection from Ethernet, it instead gets its network connection from a WiFi adapter.

For this reason, to complete this tutorial you will require two WiFi adapters, one of these must be access point capable.

You will face a fair bit of degradation in the speed of your network connection when connecting to the Wifi repeater. The main reason for this is that you must wait for the traffic to go over your initial Wi-Fi connection then be repeated from your Raspberry Pi for devices to connect to.

This tutorial can be combined well with our VPN Access Point tutorial, you can find the tutorial on how to set that up located directly after this tutorial. Basically, it will show how to setup a OpenVPN client and redirect all traffic through that client.

Please note however, this tutorial will require some slight changes, we will explain those changes needed at the end of this tutorial.

Equipment List

Below are all the bits and pieces that I used for this Raspberry Pi WiFi Extender tutorial, you will need two WiFi dongles to be able to complete this tutorial, at least one must be able to act as an access point.


Raspberry Pi 2 or 3

Micro SD Card or a SD card if you’re using an old version of the Pi.

Power Supply

Wifi dongle * 2 (The Pi 3 has WiFi inbuilt)


Raspberry Pi Case

Setting up the WiFi Extender

To setup our Raspberry Pi Wifi Extender we will need to utilize the dnsmasq package, this package handles most of the grunt work for this tutorial as it acts as both our DNS and DHCP server for our connections. We will also need to utilize the hostapd package, this is the package that will allow us to setup one of our Wi-Fi modules as an access point.

Remember for this tutorial you will need to have an active Wi-Fi router to connect to and an ethernet device you intend on bridging the Wifi connection to.

1. Before we get started installing and setting up our packages, we will first run an update on the Raspberry Pi by entering the following two commands into the terminal.

sudo apt-get update
sudo apt-get upgrade

2. With that done we can now install the two packages that we will be utilizing, run the following command to install dnsmasq and hostapd.

sudo apt-get install dnsmasq
sudo apt-get install hostapd

3. Before we get to far ahead of ourselves, we should setup the wlan0 connection that we plan on using. If you have already setup your wireless connection then you can skip ahead to step 5.

Otherwise open up the wpa-supplicant.conf file by running the following command on your Raspberry Pi:

sudo nano  /etc/wpa_supplicant/wpa_supplicant.conf

4. Within this file add the following, making sure you replace the ssid with the name of the network you want to connect to and replace the psk value with the password for that network.


Once you have entered your network name and network password you can save the file by pressing CTRL + X then Y and then press ENTER.

5. With the packages now installed and our WiFi setup we will now want to setup dhcpcd to try and give our Raspberry Pi a static IP address.

We can achieve this by modifying the dhcpcd.conf file with the following command:

sudo nano /etc/dhcpcd.conf

6. Within this file we need to add the following lines to the bottom, this will setup the wlan1 connection to how we want it.

interface wlan1
static ip_address=
static routers=

Now we can save and quit out of the file by pressing CTRL + X then pressing Y and then ENTER.

7. Now we need to restart our dhcpd service so it will load in all our configuration changes.

sudo service dhcpcd restart

8. Next, we need to adjust our hostapd configuration, to do this we need to begin editing the config file by running the following command on your Raspberry Pi.

sudo nano /etc/hostapd/hostapd.conf

9. In this file we need to write out the following lines, these basically setup how we want to interact with the wlan device. The only real lines you should worry about in this file is the ssid= line and the wpa_passphrase= line.

NOTE: You may have to change the driver= line to the best driver for your device, as some Wi-Fi devices have very specific driver requirements. Google will be helpful for looking up what driver you should be using.





Remember to change wpa_passphrase to your own password, make sure you set it to something secure so random people can’t just connect into your WiFi extender.

Now we can save and quit out of the file by pressing Ctrl + X then pressing Y and then ENTER.

10. With that done we should now modify our hostapd files in /etc/default/ and /etc/init.d/. These files are what hostapd will read to find our new configuration file that we created previously.

To begin editing the first of these two files run the following command.

sudo nano /etc/default/hostapd

11. In this file, we need to find the following line and replace it.



Replace with:


Now we can save and quit out of the file by pressing CTRL + X then pressing Y and then ENTER.

12. Now we need to edit the second configuration file, this file is located within the init.d folder. We can edit the file with the following command:

sudo nano /etc/init.d/hostapd

13. In this file, we need to find the following line and replace it.



Replace with:


Now we can save and quit out of the file by pressing CTRL + X then pressing Y and then ENTER.

14. With hostapd now setup we need to move onto setting up dnsmasq, before we begin editing its configuration we will move the default one to a new location. We can do this with the following command:

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig

15. Now that the original configuration file is moved out of the way we can begin by creating our own new configuration file. We will create and edit the new file with the following command:

sudo nano /etc/dnsmasq.conf

16. To this file add the following lines, these lines basically tell the dnsmasq service how to handle all the connections coming through.

interface=wlan1       # Use interface wlan1  
listen-address=   # Specify the address to listen on  
bind-interfaces      # Bind to the interface
server=       # Use Google DNS  
domain-needed        # Don't forward short names  
bogus-priv           # Drop the non-routed address spaces.  
dhcp-range=,,12h # IP range and lease time  

Now we can save and quit out of the file by pressing CTRL + X then pressing Y and then ENTER.

17. Next, we need to configure our Raspberry Pi so that it will forward all traffic from our wlan1 connection over to our wlan0 connection.

First we must enable it through the sysctl.conf configuration file, so let’s begin editing it with the following command:

sudo nano /etc/sysctl.conf

18. Within this file you need to find the following line, and remove the hashtag (#) from the beginning of it.



Replace with:


Now we can save and quit out of the file by pressing CTRL + X then pressing Y and then ENTER.

19. Now since we are impatient and don’t want to wait for it to enable on next boot we can run the following command to activate it immediately:

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

20. With IPv4 Forwarding now enabled we can configure a NAT between our wlan0 interface and our wlan1 interface. Basically, this will forward all traffic from our access point over to our ethernet connection.

Run the following commands to add our new rules to the iptable:

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE  
sudo iptables -A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT  
sudo iptables -A FORWARD -i wlan1 -o wlan0 -j ACCEPT

Note: If you get errors when entering the above lines simply reboot the Pi using sudo reboot.

21. Of course iptables are flushed on every boot of the Raspberry Pi so we will need to save our new rules somewhere so they are loaded back in on every boot.

To save our new set of rules run the following command:

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

22. Now with our new rules safely saved somewhere we need to make this file be loaded back in on every reboot. The most simple way to handle this is to modify the rc.local file.

Run the following command to begin editing the file:

sudo nano /etc/rc.local

23. Now we are in this file, we need to add the line below. Make sure this line appears above exit 0. This line basically reads the settings out of our iptables.ipv4.nat file and loads them into the iptables.


exit 0


iptables-restore < /etc/iptables.ipv4.nat

Now we can save and quit out of the file by pressing CTRL + X then pressing Y and then ENTER.

24. Finally all we need to do is start the two services and enable them in systemctl. Run the following two commands:

sudo service hostapd start
sudo service dnsmasq start

25. Now you should finally have a fully operational Raspberry Pi Wireless Access Point, you can ensure this is working by using any of your wireless devices and connecting to your new access point using the SSID and WPA Passphrase that was set earlier on in the tutorial.

To ensure everything will run smoothly it’s best to try rebooting now. This will ensure that everything will successfully re-enable when the Raspberry Pi is started back up. Run the following command to reboot the Raspberry Pi:

sudo reboot

Setting up the Raspberry Pi WiFi Extender with a VPN

This tutorial is fully compatible with our VPN Access Point tutorial. However there is one small change you will have to make in step 13, rather than using the commands showcased there, run the commands below.

Basically the main change you will see here is that instead of redirecting the traffic from wlan0 through the tunnel we will be redirecting the traffic from our wlan1 connection to the tunnel.

sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
sudo iptables -A FORWARD -i tun0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan1 -o tun0 -j ACCEPT

The rest of the VPN Access Point tutorial can be done without any other changes.

Hopefully by now you should have a fully operational Raspberry Pi WiFi Extender. If you come across any issues or have some feedback related to this tutorial, then please don’t hesitate to leave a comment below.


  1. Avatar for Brianna Ifft
    Brianna Ifft on

    I had to add the following in step 6 to get this to continue to work on a reboot:

    nohook wpa_supplicant

  2. Avatar for squints
    squints on

    There is a slight issue in step #16. In the /etc/dnsmasq.conf file, adding bind-interfaces causes a conflict, since it’s already bound to the IP in the interfaces= part of the config file. This will cause the service to fail at boot with the error “failed to create listening socket for Cannot assign requested address”. However, removing or commenting the “bind-interfaces” line works perfectly.

  3. Avatar for Ian Stone
    Ian Stone on

    I got this message right at the end of the process:

    Failed to start hostapd.service: Unit hostapd.service is masked.

    Any ideas?

    1. Avatar for Emmet
      Emmet on

      Hi Ian,

      Please try running the following command. This command should remove the mask thats been applied to the hostapd service.

      sudo systemctl unmask hostapd


  4. Avatar for Mereh
    Mereh on

    I’m a little confused, do I need to have two wifi dongles? what if I can connect to my WiFi without it, do I still need them? (for pi3). Thanks.

    1. Avatar for Emmet
      Emmet on

      Hi Mereh,

      You need two available WiFi points for your Raspberry Pi.

      So in the case of a Raspberry Pi 3 this will be the inbuilt one and a seperate dongle.


  5. Avatar for vihari
    vihari on

    i dont have dongles. i would like to use pi3 inbuilt wifi.
    will the above guide work ?

    1. Avatar for Gus
      Gus on

      Hey Vihari,

      You require two wifi adapters for this tutorial, the Raspberry Pi 3’s inbuilt WiFi can be one of the ones used for the extender.


  6. Avatar for mrlock
    mrlock on

    if anyone has a problem with dnsmasq: failed to create listening socket for Cannot assign requested address

    check your /etc/network/interfaces (wlan0 is the adapter that connect to the internet, wlan1 is the adapter that act as the hotspot and provide internet by routing packet to/from wlan0)

    allow-hotplug wlan0
    iface wlan0 inet dhcp
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

    allow-hotplug wlan1

    –sometimes dnsmasq failed at startup due to wlan0 is not quick when connecting to the wifi. running sudo dnsmasq fixes this problem

  7. Avatar for Dan
    Dan on

    I had to reverse wlan0 and wlan1 in the instructions because the wifi dongle I had that was capable of AP mode made itself wlan0.

    I followed all the instructions and I didn’t get any warnings or error messages, but it still wasn’t working. I found hostapd was silently failing to start and not giving any troubleshooting info so I ran it manually from the command line and it told me that my AP dongle wasn’t capable of [DSSS_CCK-40], so I removed that from the hostapd.conf file. It ran perfectly after that.

    FYI I used an Alfa AWUS036NEH as the access point interface when I was setting it up.

  8. Avatar for digicosmos
    digicosmos on

    Thank you. I followed your tutorial on a RPi running Jessie and it worked!! Couldn’t get it to work on the latest Stretch though, even though I changed the name of wlan1 to something else. It seems that dhcpcd changed the way it works in Stretch and I can no longer set up static IPs in /etc/network/interfaces. Any idea how to get it to work?


  9. Avatar for Ray
    Ray on

    I have mostly followed this tutorial but am struggling to get the routing to work.
    If anyone can help that would be marvelous 🙂

  10. Avatar for Mike
    Mike on

    I’m having a problem after step 9. I’m getting “ifdown: interface wlan1 not configured Cannot find device “wlan1″ Failed to bring up wlan1”. Any suggestions wlan1 does not show up after entering ifconfig. I am new to this so it may be something very obvious. Any suggestions?

    1. Avatar for J
      J on

      I have the same issue Mike. Did you find a solution?

    2. Avatar for Mike
      Mike on

      No. I haven’t

    3. Avatar for Nandor Tobias
      Nandor Tobias on

      OK. I’ve figured it out. (At least for my case.)
      Check the “ingredients”: “Wifi dongle * 2 (The Pi 3 has WiFi inbuilt)”
      I’m using a RPi Zero W. No wifi dongle attached (yet).
      My assumption that as soon as the wifi dongle is attached it will work like charm…

  11. Avatar for Andrew
    Andrew on

    Great tutorial. I’ve been using a similar device with Raspbian 8. Does this one work with Raspbian 9?

  12. Avatar for Wade
    Wade on

    I have been waiting for this one! I travel often and use hotel wifi’ that require log in – i usually use my laptop as well as another external USB dongle to retrans the hotel wifi and not need to log in each time. Can this be done with the Pi – love your thoughts

Leave a Reply

Your email address will not be published. Required fields are marked *