What do we want?

I was in a need for a Raspberry Pi (RPi) acting as an access controller for one of our sawing machine in our private club workshop. As we do not have any network in our workshop, but wanted to easily be able to connect with the RPi anyways, I figured it would be nice to set the RPi, which is a Model B+ with WiFi included, up as an autonomous access point that we can connect to with a laptop if need be.

I found a ton of information on how to set up the RPi as an access point, but that was either with internet access, bridging the ethernet port to wifi, or it seemed to be pretty outdated and not working entirely.

After some messing over the weekend I finally found a setup that works.


These instructions have been proven working with an fresh installation and the following setup:

  • Raspberry Pi Model 3B+
  • Raspian Stretch Lite 2018-11-13

Steps needed

Making sure everything is up-to-date

After ssh-ing into the RPi (to be able to do so, make sure to put an empty file named ssh onto the boot-partition of the SD card),

ssh pi@raspberrypi

we first want to make sure that the system is up-to-date:

sudo apt-get update
sudo apt-get upgrade

Installing additional required software

After that, we install the following required packages, stop them right afterwards, as we need to make some additional configurations on them first and do a restart:

sudo apt-get install dnsmasq hostapd
sudo systemctl stop dnsmasq
sudo systemctl stop hostapd
sudo reboot

Setting up a static IP

Our goal is to connect to the RPi that works as an access point in the end, so first things first the wireless adapter of the RPi needs to have a fixed IP. Most instructions, including (1) and (2) will do so by editing /etc/dhcpcd.conf. But I found out that doing so will end up in a configuration with the dhcpserver of the RPi not working, because it keeps failing to start the dhcpcd service at boot time with the following message:

dnsmasq: failed to create listening socket for Cannot assign requested address

It seems as though that is because at the time the system tries to start the dnsmasq service, the wifi adapter isn't up already, so the fixed IP configured in that manner isn't available. I found an entry on stackexchange.com proposing to fix the IP with /etc/network/interfaces instead (3) -- which has proven to be working for me.

So, my /etc/network/interfaces now actually looks like this:

 # interfaces(5) file used by ifup(8) and ifdown(8)

 # Please note that this file is written to be used with dhcpcd
 # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

 # Include files from /etc/network/interfaces.d:
 source-directory /etc/network/interfaces.d

 auto wlan0
 iface wlan0 inet static

Setting up the dhcp server with dnsmasq

As /etc/dnsmasq.conf contains tons of boilerplate code that we won't need, we are making a backup of the original file and create a new one as our productive configuration

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

with the following content of /etc/dnsmasq.conf:

interface=wlan0      # Use the required wireless interface - usually wlan0

Setting up the access point with hostapd

The access point functionality is set up in /etc/hostapd/hostapd.conf, which has to be created first

sudo vi /etc/hostapd/hostapd.conf

with the follwing content:


That will make an access point of the RPi using its wlan0 interface to broadcast a new wireless network with the ssid of MyNet, the password MyPassword with a WPA2 PSK encryption on channel 7.

Note that if you want to hide / not broadcast the ssid of our new wireless, you have to set ignore_broadcast_ssid=1 -- something we choose to do in our case as the network really only is supposed to be used to configure our RPi.

Next, we need to open /etc/default/hostapd and find the line that says DAEMON_CONF="" to change it to DAEMON_CONF="/etc/hostapd/hostapd.conf". This tells hostapd where its configuration file is located.

What about routing and masquerading?

As I said in the beginning, most instructions found online assume that we want to bridge an existing internet connection on the ethernet port eth0 of the RPi to our new wifi access point. In this specific use case, we do not want that, so we are leaving out those steps.

Starting the services

We stopped hostapd and dnsmasq right after installing the packages because we needed to do some configuration on them, so now that we have finished that, we need to start those services permanentely again:

sudo systemctl start hostapd
sudo systemctl start dnsmasq

Reboot and connect

Last but not least we can now restart the RPi and connect with the new wireless network. If everything works as expected, we should now get an IP address of the dhcp pool we configured above and can ssh into our RPi with

ssh pi@

Used online resources

  • (1) https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md
  • (2) https://frillip.com/using-your-raspberry-pi-3-as-a-wifi-access-point-with-hostapd/
  • (3) https://unix.stackexchange.com/questions/410833/i-am-not-able-to-start-dnsmasq-on-boot

Previous Post Next Post