Install software

Next up we install the software onto the Pi that will act as the 'hostap' (host access point) You need internet access for this step so make sure that Ethernet connection is up!

sudo apt-get update
sudo apt-get install hostapd isc-dhcp-server

(You may need to sudo apt-get update if the Pi can't seem to get to the apt-get repositories)

(text above shows udhcpd but that doesnt work as well as isc-dhcp-server, still, the output should look similar)

Also install a nice iptables manager with

sudo apt-get install iptables-persistent

You'll get two 'config' screens, say Yes to both

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

Configure Access Point

Now we can configure the access point details. We will set up a password-protected network so only people with the password can connect.

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=


If you are not using the Adafruit wifi adapters, you may have to change the driver=rtl871xdrv to say driver=nl80211 or something

If you are using the Raspberry Pi 3's internal WiFi adapter, comment out the driver=rtl871xdrv line altogether:

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


Configure Network Address Translation

Setting up NAT will allow multiple clients to connect to the WiFi and have all the data 'tunneled' through the single Ethernet IP. (But you should do it even if only one client is going to connect)

Run sudo nano /etc/sysctl.conf

Scroll to the bottom and add


on a new line. Save the file. This will start IP forwarding on boot up

Also run

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

to activate it immediately

Run the following commands to create the network translation between the ethernet port eth0 and the wifi port wlan0
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

You can check to see whats in the tables with

sudo iptables -t nat -S
sudo iptables -S

To make this happen on reboot (so you don't have to type it every time) run
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

The iptables-persistent tool you installed at the beginning will automagically reload the configuration on boot for you.

Update hostapd (maybe)

If you are running Raspberry pi kernel 4.4.13-v7+ or greater (check your kernel vesion with uname -a), you do not need to do this step.

If you are using the Raspberry Pi 3 built-in WiFi or are not using RTL8192-like WiFi adapter, then skip this step!

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

First test!

Finally we can test the access point host! Run

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

To manually run hostapd with our configuration file. You should see it set up and use wlan0 then you can check with another wifi computer that you see your SSID show up. If so, you have successfully set up the access point.

If you get this warning

Configuration file: /etc/hostapd/hostapd.conf
Line 2: invalid/unknown driver 'rtl871xdrv'
1 errors found in configuration file '/etc/hostapd/hostapd.conf'
Failed to set up interface with /etc/hostapd/hostapd.conf
Failed to initialize interface

It could mean that either you are not using a RTL871Xdrv WiFi adapter (e.g. Pi 3 internal wifi) and should comment out the driver=rtl871xdrv line in the hostapd config OR you are using that chipset and you need to download our recompiled hostapd binary

If it does work, you should get something like this:

And see a new access point created:

You can try connecting and disconnecting from the Pi_AP with the password you set before (probably Raspberry if you copied our hostapd config), debug text will display on the Pi console but you won't be able to connect through to the Ethernet connection yet.

Cancel the test by typing Control-C in the Pi console to get back to the Pi command line

Removing WPA-Supplicant

Depending on your distro, you may need to remove WPASupplicant. Do so by running this command:

sudo mv /usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service ~/

and then rebooting (sudo reboot) and retrying running hostapd

Finishing up!

OK now that we know it works, time to set it up as a 'daemon' - a program that will start when the Pi boots.
Run the following commands

sudo service hostapd start
sudo service isc-dhcp-server start

you can always check the status of the host AP server and the DHCP server with

sudo service hostapd status

or sudo service isc-dhcp-server status

To start the daemon services. Verify that they both start successfully (no 'failure' or 'errors')
Then to make it so it runs every time on boot

sudo update-rc.d hostapd enable
sudo update-rc.d isc-dhcp-server enable
Last updated on 2016-09-13 at 01.32.49 AM Published on 2013-06-12 at 04.30.11 PM