This tutorial describes how to setup a stand alone Access Point using systemd-networkd
.
Configuring networking using systemd-networkd
requires multiple steps, and it is easy to get things wrong.
The following scripts simplify the process and enables swapping between Access Point and normal networking.
There are other tutorials which offer additional features and/or automatic detection but at the expense of additional complexity.
Before running the scripts below follow the Simplified Systemd-Networkd setup and verify that networking is working as before.
I have changed most of my Pi to Systemd-Networkd and this offers similar functionality to the dhcpcd
setup (except this will disable the Networking tool on the Desktop Panel).
- Step1 installs necessary files.
- The second script activates the Access Point.
Reboot REQUIRED!
All script MUST be run by root or with sudo.
This should result in an Access Point RaspberryPiNet @ address 10.1.4.1
If you have Ethernet this should continue to operate as before except static IP Addresses will require different settings.
SetupAccessPoint.sh
#! /bin/sh
# Script to install files for stand alone Access Point using systemd-networkd
# NOTE this does NOT swap networking systems - see separate script to activate
# This script MUST be run by root or with sudo
# 2022-07-20
echo "Install files for stand alone Access Point using systemd-networkd"
echo "Before use change country & psk"
echo "This setup for Frequency:2.412 GHz (Channel 1)"
if [ `whoami` != root ]; then
echo "This script MUST be run by root or with sudo"
exit
fi
# Setup wpa_supplicant as Access Point
cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
country=AU
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="RaspberryPiNet"
mode=2
frequency=2412
key_mgmt=WPA-PSK
proto=RSN WPA
psk="PASSWORD"
}
EOF
# Create a network configuration for Access Point
cat > /etc/systemd/network/03-wlan0.network <<EOF
[Match]
Name=wlan0
[Network]
Address=10.1.4.1/24
DHCPServer=yes
MulticastDNS=yes
EOF
ActivateAccessPoint.sh
#! /bin/sh
# Script to Activate Access Point using systemd-networkd
# Assumes network configuration files and wpa_supplicant.conf file have been setup
# This script MUST be run by root or with sudo
# Reboot REQUIRED!
# 2022-07-20
echo "Activate Access Point using systemd-networkd"
if [ `whoami` != root ]; then
echo "This script MUST be run by root or with sudo"
exit
fi
rm /etc/systemd/network/03-wlan.network
systemctl enable systemd-networkd
systemctl enable [email protected]
To revert to normal networkin re-run the the Simplified Systemd-Networkd setup procedure.
hostapd
andsystemd
and a Raspberry Pi Ltd. tutorial - pick 1 and try it!