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.

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

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!