nmcli for WiFi on Raspberry Pi OS 12 'Bookworm'

If you haven't already, check out my full video on the Raspberry Pi 5, which inspired this post.

Raspberry Pi 5 at an angle

Raspberry Pi OS 12 'Bookworm' is coming alongside the release of the Raspberry Pi 5, and with it comes a fairly drastic change from using wpa_supplicant for WiFi interface management to everything network-related running through nmcli, or NetworkManager.

nmcli is widely adopted in Linux these days, and it makes managing WiFi, LAN, and other network connections much simpler.

I thought I'd jot down my notes using nmcli for some Pi testing, mostly for my own reference. There are tons of guides with hundreds of examples to choose from, but these are some of the commands I find myself running frequently:

# Quick status of all interfaces
nmcli dev status

# Detailed overview of all interfaces
nmcli

# Get a list of all WiFi SSIDs
nmcli d wifi list

# Disconnect from a WiFi network
nmcli con  # Get the NAME of the WiFi connection
nmcli con down "connection_name_here"

# Connect to a WiFi network on a specific WiFi interface
sudo nmcli d wifi connect "ssid_here" password "password_here" ifname wlan1

nmcli commands often require root privileges, so add sudo before the command if you get a warning like "[XYZ] failed: Not authorized to [do XYZ]."

For debugging WiFi issues, iw is always handy as well:

# Show detailed information about a specific WiFi interface
iw dev wlan0 info

# Show WiFi link details (signal strength, bitrates)
iw dev wlan0 link

And of course, if you're using the GUI on the Raspberry Pi, they have a handy little WiFi connection menu you can use.

Alternatively, there's a more user-friendly console front end for NetworkManager, nmtui (which should also be present on Pi OS):

nmtui Network Manager Terminal User Interface on a Raspberry Pi

Comments

Have you tried nmtui? It's a curses-based interface to NetworkManager, and comes with NetworkManager on most platforms.

`nmtui` is great given networkmanager is installed, makes configuring wifi dead simple, no extra commands to remember.

One of the nice raspios features currently is dropping a wpa_supplicant.conf file into your image and having it autoinstall on first boot, which makes the pi come up on your network headless and completely hands-off. How are they making this firstboot network configuration happen with nmcli replacing wpa_supplicant.conf ?

No idea how they are doing it but NetworkManager of course supports profiles: you can create a network connection on any machine NetworkManager ist running, then grab the generated config below /etc/NetworkManager/system-connections/ and throw it onto any other machine you like (NetworkManager ist smart enough to deal with differing interface names so it's really plug&play and works out of the box).

There's a reason we switched to NetworkManager almost 7 years ago on Armbian [1] but as others already suggested instead of fiddling around with nmcli using nmtui is the way to go.

[1] https://github.com/armbian/build/issues/493

yes - I'm well aware of the NetworkManager borg and where it writes under the hood. My question was how (if) RaspiOS will support the no-keyboard-needed dropping in of wifi credentials moving forward. They have a wonderful feature now that many folks depend on. They shouldn't just remove it in the new os without providing a comparable feature day-one moving forward, regardless of how they do it.

This is also how I use the Raspberry Pi. I don't have a single Raspi connected to a monitor. So I always need a way to get the Raspi headless into the wifi.

Looks like it possible by something along this (I have not tested it yet):
1. generate a netplane yaml configuration file on /boot
2. edit /boot/firstrun.sh to generate and apply the network configuration

Hi Jeff. Do you have any idea how to hash or encrypt the wifi password stored in .nmconnection file? I tried both lite and desktop version of the bookworm OS and it seems like the password is store in plain text. I also tried dump the hash string from wpa_passphrase to .nmconnection file and it did not work as well. I'm not sure if this is something supported by NetworkManager. Appreciate if you can try it out when you are free.

It's worth pointing out that this change effectively killed booting up pre-configured Raspberry OS by including to the SD card ssh, users, wpa_supplicant.conf and dhcpd.conf files to configure the network interfaces[1][2] during first boot. My whole setup is based on automatically writing these files to the SDCard, and then when the Pi comes online, automatically ssh:ing in and running deploy.sh. While I applaud the demise of wpa_supplicant.conf, I cannot believe that the folks at rPi removed this essential (for me anyways) functionality without introducing a reasonable alternative.

[1] https://forums.raspberrypi.com/viewtopic.php?t=357623
[2] https://github.com/raspberrypi/bookworm-feedback/issues/72

Is there any way with the new network manager to delay boot up until the network is up???

Hi Jeff.. BOOKWORM NTPSEC service (Server/client) takes a while to sync with the clock after a system boot... I wonder if the NTPSEC service is starting before the NETWORK service has completed bringing up the ethernet port (and goes into an error hold). The sync problem on boot has been a problem for NTPSEC for a while.. There used to be a way to delay system boot until the ethernet port was up and stable... that has gone away with the new NETWORK SERVICE ... Any Ideas?

Oh, this must be why ‘ssh user@hostname’ still works on the 32bit Raspian but must now be ‘ssh [email protected]’ on the Raspberry Pi OS 12. Sheesh.