For setting up the Raspberry Pi as an access point we will be using most of the steps from the Setting up a Raspberry Pi as a WiFI access point guide but with some changes for our project.

First we install the software onto the Raspberry Pi that will act as the 'hostap' (host access point) 

sudo apt-get install hostapd isc-dhcp-server

Set up DHCP server

Next we will edit /etc/dhcp/dhcpd.conf, a file that sets up our DHCP server - this allows wifi connections to automatically get IP addresses, DNS, etc.

Run this command to edit the file

sudo nano /etc/dhcp/dhcpd.conf

Find the lines that say

option domain-name "";
option domain-name-servers,;

and change them to add a # in the beginning so they say

#option domain-name "";
#option domain-name-servers,;

Find the lines that say

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.

and remove the # so it says

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.

Then scroll down to the bottom and add the following lines

subnet netmask {
	option broadcast-address;
	option routers;
	default-lease-time 600;
	max-lease-time 7200;
	option domain-name "local";
	option domain-name-servers,;

Save the file by typing in Control-X then Y then return


sudo nano /etc/default/isc-dhcp-server

and scroll down to INTERFACES="" and update it to say INTERFACES="wlan0"

Or whatever the name of your wifi adapter is!

close and save the file

Set up wlan0 for static IP

If you happen to have wlan0 active because you set it up, run sudo ifdown wlan0
There's no harm in running it if you're not sure.

Next we will set up the wlan0 connection to be static and incoming. Run sudo nano /etc/network/interfaces to edit the file

Find the line auto wlan0 and add a # in front of the line, and in front of every line afterwards. If you don't have that line, just make sure it looks like the screenshot below in the end! Basically just remove any old wlan0 configuration settings, we'll be changing them up

Depending on your existing setup/distribution there might be more or less text and it may vary a little bit

Add the lines

iface wlan0 inet static

After allow-hotplug wlan0 - see below for an example of what it should look like.  Any other lines afterwards should have a # in front to disable them

Save the file (Control-X Y )

Assign a static IP address to the wifi adapter by running
sudo ifconfig wlan0

We will get an error message since we do not have a device connected to wlan0 at the moment.

Configure Access Point

Now we can configure the access point details. 

Create a new file by running sudo nano /etc/hostapd/hostapd.conf

Paste the following in, you can change the text after ssid= to another name, that will be the network broadcast name.

The password can be changed with the text after wpa_passphrase= 

To enable a password remove the # in front of the 5 lines that have wpa in them


I have found that it will load the correct drivers if you comment out the line driver=rtl871xdrv

Save as usual. Make sure each line has no extra spaces or tabs at the end or beginning - this file is pretty picky!

Now we will tell the Pi where to find this configuration file. Run sudo nano /etc/default/hostapd

Find the line #DAEMON_CONF="" and edit it so it says DAEMON_CONF="/etc/hostapd/hostapd.conf"
Don't forget to remove the # in front to activate it!

Then save the file

Likewise, run sudo nano /etc/init.d/hostapd and find the line


and change it to


Update hostapd

 I have added this step as required since I could not get it to work with the usb wifi module until I did this.

Before we can run the access point software, we have to update it to a version that supports the WiFi adapter.
First get the new version by typing in


to download the new version (check the next section for how to compile your own updated hostapd) then


to uncompress it. Move the old version out of the way with

sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.ORIG

And move the new version back with

sudo mv hostapd /usr/sbin

set it up so its valid to run with

sudo chown root:root /usr/sbin/hostapd

sudo chmod 755 /usr/sbin/hostapd

Finishing up!

Now it is time to set it up as a 'daemon' - a program that will start when the Pi boots.

To set the daemon services to run every time on boot enter these commands.

sudo update-rc.d hostapd enable
sudo update-rc.d isc-dhcp-server enable

This guide was first published on Dec 09, 2016. It was last updated on Mar 08, 2024.

This page (Configure Access Point) was last updated on Mar 08, 2024.

Text editor powered by tinymce.