Home » Linux » Raspberry Pi » Raspberry Pi Wifi Access Point Airplay Server

Building a Raspberry Pi 4 WiFi Access Point + Airplay Server

This tutorial will detail how to build a wireless access point using a Raspberry Pi 4 with hostapd. I’ll also set up an Airplay server using shairport-sync so that my access point can play music.

There are a number of tutorials for setting up a Raspberry Pi as an access point, but many are outdated or don’t work – this one does!

The Setup

I want to set up my Pi as an access point – supplying internet via ethernet cable and broadcasting a wireless network.

I’ll be using this with a pair of powerline ethernet adapters to bring wifi anywhere I need it – in the house, or out in the shed.

Install Raspberri Pi OS

First, the Pi needs an operating system. I installed Raspberry Pi OS lite 64 bit using the Raspberry Pi OS Imager.

Enable SSH

Next, I connected the Pi to a screen and keyboard, logged in, and enabled SSH.

Connect to the Wired Network

The Pi only needs an ethernet connection at this point. Plug in to your network, and leave WiFi unconfigured.


Update your system.

sudo apt update
sudo apt upgrade

Setting Up Wireless Acesss Point

Install packages

sudo apt install dnsmasq hostapd iptables

Configure Static IP

interface wlan0
static ip_address=
nohook wpa_supplicant

I’m using a static IP address of on the wireless network for my Raspberry Pi access point. Once the network is set up, you can SSH to it at this address.

Configure dnsmasq as DHCP Server

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
sudo nano /etc/dnsmasq.conf

Add the following lines to the file:

interface=wlan0      # Use the wireless interface - wlan0

Configuring hostapd as a WiFi access point

Create and edit the file /etc/hostapd/hostapd.conf:

sudo nano /etc/hostapd/hostapd.conf

Add the following to the new file:



The last 2 lines need to be edited with your desired network name and passphrase.

The system must now be made aware of this new configuration file.

sudo nano /etc/default/hostapd

Uncomment the line beginning with #DAEMON_CONF, and edit it with the path to the above configuration file:


Now that hostapd has a valid configuration file, it needs to be enabled:

sudo systemctl unmask hostapd
sudo systemctl enable hostapd

Set up Routing

Edit the file /etc/sysctl.conf and uncomment the following line:


Then, masquerade outbound traffic for eth0:

sudo iptables -t nat -A  POSTROUTING -o eth0 -j MASQUERADE

iptables rules are not permanent, so they must be saved:

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Edit the file /etc/rc.local and add the following line above “exit 0”:

iptables-restore < /etc/iptables.ipv4.nat

This will load the saved rules when your Pi boots.

Check everything is running

Check that hostapd and dnsmasq are running by issuing the following command:

sudo systemctl status hostapd
sudo systemctl status dnsmasq

If there are any errors, go back and check through your configuration files to make sure they match the above steps.

Reboot and connect!

Reboot your Pi:

sudo reboot

And you should be able to connect to your new hotspot!

As your Pi has a static IP on the wireless network you can now disconnect your screen and keyboard and simply SSH to it when you need to fix something.

Setting Up Airplay

shairport-sync is a program which emulates an Apple airport service, allowing you to stream music to it from your Apple devices. Install it by running:

sudo apt install shairport-sync

Now you need to configure the audio path on the Raspberry Pi. It’s generally set to “auto” but you need to force it to go to the 3.5mm jack. Run raspi-config:-

Raspberry Pi’s are a bit finnicky about their audio output. It’s supposed to be automatic, but I’ve found it’s a bit unreliable in which output it chooses to use.


sudo raspi-config

… and set the audio output to use the 3.5mm headphone jack.

Next, set the volume for the headphone jack to full volume (actual volume will be controlled via Airplay from your mobile device):

amixer -q -M sset Headphone 100%

I was still having trouble getting audio output on the 3.5mm plug. I figured it was due to the Pi trying to output audio via HDMI (again, the auto output option isn’t too bright).

I’m not entirely sure why setting these options helped, but after setting these options I was getting audio out of the headphone jack. Edit the file /boot/config.txt and edit/uncomment the following lines:


Reboot, and you should have a dual-purpose wireless access point and Airplay server. Neat!

I’ll be strapping my Pi to a robust speaker and taking it out to the shed where there’s a weak signal and a dire need for some loud music.

Photo of author
I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

Leave a Comment