Skip to content

Managing WiFi using systemd-networkd

This guide demonstrates how to configure WiFi using systemd-networkd.

Enabling and disabling WiFi

To enable WiFi, run:

networkctl up wlan0

To disable WiFi, run:

networkctl down wlan0

Configuring WiFi client mode

Scan for available networks:

iw dev wlan0 scan | grep SSID

Create the network configuration:

cp /lib/systemd/network/80-wifi-station.network.example \
  /etc/systemd/network/80-wifi-station.network

Append route metrics to /etc/systemd/network/80-wifi-station.network:

[DHCPv4]
RouteMetric=9
[IPv6AcceptRA]
RouteMetric=9

Create /etc/wpa_supplicant/wpa_supplicant-wlan0.conf:

ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
ap_scan=1
fast_reauth=1

Add your network credentials:

wpa_passphrase <SSID> <PASSWORD> >> \
  /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

Bring up the interface and restart the services:

networkctl up wlan0
systemctl restart systemd-networkd.service
systemctl restart [email protected]

Check that wlan0 received an IP address:

ifconfig wlan0

To make the WiFi connection persistent, enable the wpa_supplicant service:

systemctl enable [email protected]

Debugging

The following commands may help when the interface fails to connect:

journalctl -u [email protected]
journalctl -u systemd-networkd.service
wpa_cli