Access Point on Raspberry Pi

RPI3 has build-in WiFi, RPI2 can be easily extended with WiFi adapter. Such adapter can be configured to connect to access point or act as access point itself.

There is the good instruction on the Raspberry Pi website[1] on how to create access point. Just in case it would not work, there is an extended version with troubleshooting.

Before configuring the device, make sure that you have latest software and packages:

$ sudo apt-get update
$ sudo apt-get dist-upgrade

Install required software packages:

  • dnsmasq - package that provides DHCP server and DNS cache
  • hostapd - authenticates wireless clients
$ sudo apt-get install dnsmasq hostapd

The packages are started automatically, but as they are not configured yet, it is better to turn them off:

sudo systemctl stop dnsmasq
sudo systemctl stop hostapd

The wireless interface is need to be configured. By convention, there are a few networks devoted to private use[2], among them 192.168.x.x. In fixed networks, where the assumption can be made about the network structure, the network addresses can be specified statically. For that make sure that corresponding wlan interface settings are configured in the file /etc/network/interfaces:

allow-hotplug wlan1
iface wlan1 inet static
  metric 100
  address 192.168.5.1
  netmask 255.255.255.0
  network 192.168.5.0

where wlan1 is the wireless interface (second adapter) I would like to connect. In case of only one adapter installed, the interface name is wlan0. 192.168.5.1 is the address and 192.168.5.0/255.255.255.0 defines the address space of the network.

Now rename the existing dnsmasq configuration:

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

and create the new one that specifies the interface and the IP address range:

interface=wlan1
dhcp-range=192.168.5.50,192.168.5.200,255.255.255.0,48h

Normally, DHCP client gets the settings and reconfigures the interface IP address and other properties. This is need to be avoided (as DHCP serviec will be provided by the interface itself) by adding to the file /etc/dhcpcd.conf instruction:

denyinterfaces wlan1

Preparation is done so now the access point itself can be configured. For this create the file /etc/hostapd/hostapd.conf with the following configuration settings:

interface=wlan0
ssid=VISIBLE_ACCESS_POINT_NAME_CHANGE_PLS
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=SECTRET_PASSWORD_CHANGE_PLS
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Set the option DAEMON_CONF in the file /etc/default/hostapd. Uncomment it if necessary. Strangely enough, it does not with quoted path, as set in the official guide.

DAEMON_CONF=/etc/hostapd/hostapd.conf

Now start the services:

$ sudo service hostapd start
$ sudo service dnsmasq start

The access point should appear in the list of available WiFi networks and connecting to it with the specified password should be successful.


  1. SETTING UP A RASPBERRY PI AS AN ACCESS POINT IN A STANDALONE NETWORK, https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md ↩︎

  2. IPV4 PRIVATE ADDRESS SPACE AND FILTERING, https://www.arin.net/knowledge/address_filters.html ↩︎