How to Set up a Raspberry Pi as a Wireless Access Point

The Raspberry Pi can connect to a Wi-Fi network using a USB dongle but using that same dongle you can also turn your Raspberry Pi into a wireless access point. Once set up correctly, this will allow other wireless devices to connect to your Pi and optionally you can route any traffic out through the Ethernet port and on to the internet (via the router from your ISP).

However, before looking at the steps needed to get this working, a word of warning. The configuration needed can be a little complex and if things don’t work as they should then troubleshooting the problem can be difficult. Also for this to work correctly, you need a WiFi USB dongle that can work as an access point. The best place to find information about your particular dongle and the Raspberry Pi is on the embedded Linux Raspberry Pi Wi-Fi adapters page.

To configure a hotspot requires several steps:

  • Configure the wireless adapter with a static IP address
  • Install and configure a DHCP server
  • Install and configure the access point daemon
  • Configure IP routing between the wireless and Ethernet

In this example, the wireless network will use the address range 192.168.42.n and the wired Ethernet will use the address range 192.168.1.n.

Configure the wireless adapter with a static IP address

Edit “/etc/network/interfaces” and add the static IP address information for wlan0. You can learn about static IP addresses in our SSH and static IP address tutorial.

Place a “#” sign in front of all the lines which mention wlan0 and wpa, except for “allow hotplug wlan0“. Then add the following lines to the file:

The bottom half of the file will now look something like this:


Now reboot.

Install and configure a DHCP server

Install the DHCP server:

You can safely ignore any errors about not being able to start the DHCP server at this point. Now edit its configuration file:

Add a “#” character in front of the “option domain-name” lines like this:

Remove the “#” sign in front of the “authoritative;” statement like this:

At the bottom of the file add the following lines:

Exit from nano with “Ctrl + X”.

Make the wireless adapter the default for the DHCP request:

Change “INTERFACES=""” to “INTERFACES="wlan0"

Exit from nano with “Ctrl + X”.

Restart the DHCP server:

Install and configure the access point daemon

Install hostapd:

Edit the hostapd configuration file and create a wireless network:

Add the following lines:

This will create a password protected network called MyPi on channel 6 with the password raspberry.

Tell hostapd where to find its configuration file by setting the default location:

Remove the “#” in front of “DAEMON_CONF” and alter the line to read:

Configure IP routing between the wireless and Ethernet

Edit “/etc/sysctl.conf” to enable IP forwarding:

Find the line which reads “Uncomment the next line to enable packet forwarding for IPv4” and uncomment the next line like this:

Run the following command to activate forwarding now:

Now turn the Pi into a router with the follow commands:

And save the routing tables into the file “/etc/iptables.ipv4.nat

Edit “/etc/network/interfaces“:

And add the following line to the end of the file. This line will restore the routing table whenever the Pi is booted:

You should now reboot your Pi and test the wireless access using a laptop, smartphone, tablet or other Wi-Fi enabled device.



Since this configuration is quite complex things can easily go wrong. If you run into trouble, double check all the configuration files. It is also worth power cycling the Pi as it is possible for the USB dongle to get into an undefined state.

You may have noticed that the "hostapd.conf" file had two "driver=" lines and one of them was commented out. If your USB Wi-Fi dongle uses the nl80211 driver then the above configuration should work OK. However if your dongle uses the rtl871xdrv which it does for adapters based on the Realtek RTL8188CUS chipset then there are some extra steps needed.

First install the iw package:

Now run the following command:

If the output of the command is "nl80211 not found" then you need to use the rtl871xdrv driver. However you will also need a special version of hostapd.

Adafruit has a pre-compiled version of hostapd for the rtl871xdrv driver. To install it use the following commands:

If you have any questions about turning your Pi into a wireless access point, please ask below and we will try our best to help!


  1. This is a great tutorial, given the advancing ac standards and availability, is there a different stepthru for 802.11ac wifi usb adapters?

  2. i have a question……if there is two USB dongle , “from wireless to wireless AP” is possible?

    1. That is a good question, if you give it a try I think we would all be interested to hear what happened. Gary.

      1. I already tried this in os x (macbook air), it works. (just using “internet sharing”)
        But macbook is too big for that use. sorry for my poor english, have a good day.

  3. Thank you for this really nice setup guide. I did follow all the steps an everything works like a charme. My question is: I would like to access a connected hdd through wifi without connecting the pi to ethernet. As soon as I unplug the ethernet connection I cann still connect through wifi but I am not able to see all the samba shares on the pi.

    How can I do this?

    Thanks alot and have nice day,


    1. Tom, so you are trying to configure your Pi as a wireless access point and simultaneously grant access to the Pi’s services, in this case Samba… Hmmm… I have never tried that and I am not sure it is possible, but I would need to do some research.

      1. hi Gary,

        Great tutorial, I would love to be able to access the HDD’s , any idea already if this is possible ?


  4. Thanks for this excellent tutorial!!

    I’ve tried following everything very carefully, but still get a failure under “advanced IEEE 802.11 management: hostadp”. I needed to download the adafruit rt1871xdrv hostapd, and moved it as suggested. I tried changing the driver in the hostapd.conf file to rt1871xdrv or to 0, but still get the fail, any suggestions?

    1. Hi Matt!

      The driver’s name is “rtl871xdrv” , not “rt1871xdrv” (without quotation marks). The third character is a small “L” not a “1”.

      I ran into the same problem as you did. All along I was writing “rtl1871xdvr” because I was so used to seeing the “RTL” sequence being followed by 4 numbers.

  5. Thank you for the tutorial!

    For some reason, however, I keep running into a big ol’ fail when I try to start up the DHCP server. Do you have any suggestions re: why this might be happening?

    Thank you!

  6. Hi, I have my system set up, everything seems to be working, however, when I connect to the network from an external client, the IP address it is assigned is in the order of rather than (+- 20 addresses) like it is set in the dhcpd.conf. Could this be a reason why the client can’t connect properly? I ran hostapd in debug mode and it hangs after the WPA handshake, which led me to probe this issue. It seems like hostapd is running fine but the dhcpd side of things is letting the side down. Any clues?

    1. The address are a private address that are not allowed to exist on internet. Usually you only uses part of it, like or That is the original network has been divided into 256 different networks and I mentioned two here. I usually avoids using and as that is used by so many other that it could be a problem in some (rare) cases…

      The address is link local address, which is kind of privat address as it isn’t allowed to exist on internet. But this one is automaticly generated by any machine on a LAN that doesn’t get any private or public IPv4 address. This is used when you connect to machines together without an DHCP server (like not connected to your broadband router/firewall/NAT). With this link local address they can still communicate with each other using this address.

      So do you have set up your dhcp-server correctly? Check the logs in /var/log/ (like these files /var/log/{messages,syslog,dmesg}) for indication that the server has started properly or error messages because it failed to start.

  7. Hi,
    I have run this tutorial and double checked my setup. Windows laptop sees the network but when I attemp to connect it says it is unable to connect. Windows diagnostic on the network can’t find anything wrong. I have tried pinging IP addresses listed and there is no response. I have tried rebooting Windows and the Pi and no response. I am using an Adafruit Raspberry pi approved wifi dongle. Please help.

  8. I think this tutorial missing something. Can someone tell me how to install Linux onto the SD card? I don’t see the step for this

    1. Please see our Beginner Guide:

      Thanks, Gary.

  9. What steps would be necessary to get the RasPi to serve web pages at the the same time ?

    And not to pass through.

  10. Great tutorial..
    Especially mentioning the difference with USB Wi-Fi dongles “rtl871xdrv” and “nl80211”. It also solved my struggles to fix the stuffs from past 04-05 days..

    @Gary Sims
    Thank you….. :) :)

  11. Hi,
    Thank for the great tuto!, but I have the same problem as Hobbs. I see the connection, but can not connect me …

    Thanks for you help.

  12. Hi again,
    In the first part, it lacks the Gateway line visible on the screenshot. Hobbs, I do not know for you, but now for me it works very well.

    I hope I have helped.

    See you soon and thank you again

  13. Hey I tried to run the rtl871xdrv driver version of hostapd but now it tells me access denied. Help.

  14. It worked, but there’s a big problem so it is really useless now. Problem is; I have a 802.11n wifi dongle which means it does support Wireless N mode which is better than G mode. In this code, hw mode is g, so I typed “n”, instead of “g” for hw_mode in hostapd.conf file. Now it is not working.
    Is there a way to run it in “n” mode? When I connect to my modem with dongle without any manual configuration, it has strong connection even outmost place in my home and has a great speed that I can instantly send files etc. But when I use this access point with g mode, even xterminal works extremely slow and no connection to outmost place in my home.

  15. Thank you so much for such an AWESOME tutorial! :D

    Works like a charm!

    The one that would be very nice to add is a little warning note on the spelling of the driver “rtl871xdrv”, since it is very easy to misread it as “rt1871xdrv”, or even “rtl1871”.

  16. If you are having issues getting hostapd to run and get and error run it with this command

    sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf

    This will show errors where starting the service will only give a FAILED status.

  17. Hi, I’m having a hard time getting this to work with two wifi dongles. I have two TL-WN725N that is based on the RTL8192CU hostapd file.

    I have wlan0 as the receiver of the wifi signal from my home router, and wlan1 as the access point.

    The problem is that once I get the AP started via hostapd -B /etc/hostapd/hostapd/conf for wlan1, wlan0 disconnects from the home network–preventing me from connecting to the internet after logging in successfully to wlan1.

    Please help as there are no guides on the internet for creating a wireless AP with two adapters/dongles. Thanks!

  18. Hi,
    I am trying to use iw command and keep getting the “nl80211 not found” error.
    I have compiled & installed rl5370sta driver and blacklisted rt2800usb,rt2x00lib and rt2x00ussb (I want to use the specific driver as it implements some stuff I need).

    how can I run iw using the compiled driver.

    iwlist and iwpriv works fine with my compiled driver (no error messages)


  19. Got it working. I have 2 questions:
    1: On the Pi I assigned wlan0 a static ip address to the same network the gateway is on but with a 192. . .5 rather than 192. . . 1 that the gateway is assigned. How do I modify it so that when a client connects it obtains the ip address from dhcp on the existing gateway/router rather than the Pi?

    2: Is it possible to use the “encrypted version” of the passphrase rather than “in the clear” passphrase in the /etc/hostapd/hostapd.conf file? I tried it but I got something really weird.


  20. Hi there,
    If have a Realtek RTL 8191S WLAN adapter, and I installed it with the Adafruit pre-compiled version of hostapd. But I have an error on Starting advanced IEEE 802.11.
    Is the RTL 8191S not compatible?
    Can somebody help me?

  21. i am getting the following error when trying to configure the ipv4 fowarding.

    sudo sh -c “echo 1 /proc/sys/net/ipv4/ip_foward”
    cannot create proc/sys/net/ipv4/ip_foward: Directory nonexistent

    also cannot configure the iptables:
    sudo iptables -A FOWARD -i eth0 -o wlan0 -m state –state RELATED, ESTABLISHED -j ACCEPT
    iptables: No chain/target/match by that name.

    please help.

    1. I notice you have spelled forward without the R, i.e. foward, several times, could that be the problem???

  22. i am now encountering another issue with the isc-dhcp server when i try to start it.

    sudo service isc-dhcp-server start
    [FAIL] Sarting ISC DHCP server: dhcpd [….] check syslog for diagnostics. … failed!

  23. Hello,

    hostapd is currently 404’ing while trying to install it from apt-get
    Is there any way to get it for raspi?

  24. Thanks, it worked from the first time.
    Nicely written step by step guide.

    Hint: I configured the DNS addresses of my internet provider, instead of,;

Comments are closed.