silly05
Posts: 13
Joined: Mon Nov 19, 2018 6:45 pm

bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Thu Oct 12, 2023 6:06 pm

In previous Raspberry pi OS (through Bullseye) I used the file /etc/wpa_supplicant/wpa_supplicant.conf to set up all Wi-Fi ssid and passwords. I mostly operate from the console either using the lite version of the OS or just configure it to no boot to the desktop. Maintenance is done over SSH connections.

I also used /etc/dhcpcd.conf to configure my ethernet interface to be a static ip.

What is the replacement for these? I understand there was a change to NetworkManager and I can find some command line tools to do an ad-hoc connection, but I have not found documentation for how to use configuration files to drive this and I also have not found how to do a static ip.

User avatar
kerry_s
Posts: 6609
Joined: Thu Jan 30, 2020 7:14 pm

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Thu Oct 12, 2023 6:20 pm

the recommended way to preconfigure is to use rpi-imager and the advanced menu.

network manager can be configured using nmtui in cli.
Attachments
20231012_08h19m16s_grim.png
20231012_08h19m16s_grim.png (27.66 KiB) Viewed 11981 times

bls
Posts: 3330
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Thu Oct 12, 2023 6:50 pm

kerry_s wrote:
Thu Oct 12, 2023 6:20 pm
network manager can be configured using nmtui in cli.
And the nmcli command. Also see https://networkmanager.dev/docs/api/latest/ for everything Network Manager
Pi tools:
Quickly and easily build customized exactly as-you-want SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure IPSEC/IKEV2 VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

silly05
Posts: 13
Joined: Mon Nov 19, 2018 6:45 pm

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Thu Oct 12, 2023 7:03 pm

I'm looking for something that could be set up with configuration files. I build many systems so it will be somewhat impractical to go through gui-like tools to configure every new machine. previously I just had to copy/paste text files.

I appreciate the answers though - I didn't know about that tool and maybe I can reverse engineer something by checking to see what it does.

bls
Posts: 3330
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Thu Oct 12, 2023 7:18 pm

silly05 wrote:
Thu Oct 12, 2023 7:03 pm
I'm looking for something that could be set up with configuration files. I build many systems so it will be somewhat impractical to go through gui-like tools to configure every new machine. previously I just had to copy/paste text files.

I appreciate the answers though - I didn't know about that tool and maybe I can reverse engineer something by checking to see what it does.
Have a look at https://github.com/gitbls/sdm The network plugin accepts nm configuration and connection files as arguments that the plugin stuffs into the correct directories in /etc/NetworkManager

You won't even need to copy/paste files, sdm will do all that for you. And a LOT more.
Pi tools:
Quickly and easily build customized exactly as-you-want SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure IPSEC/IKEV2 VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

lukami
Posts: 2
Joined: Thu Oct 12, 2023 11:35 pm

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Thu Oct 12, 2023 11:54 pm

Apparently nmconnection files for NetworkManager replaced the wpa_supplicant.conf. Nevertheless, they can be just as easily set up offline.

Create a file in /etc/NetworkManager/system-connections/ called MYSSD.nmconnection with this content (change MYSSD and MYWIFIPASSWORD):

Code: Select all

[connection]
id=MYSSD
uuid=
type=wifi
interface-name=wlan0
autoconnect=true

[wifi]
mode=infrastructure
ssid=MYSSD

[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=MYWIFIPASSWORD

[ipv4]
method=auto

[ipv6]
method=auto
Restrict the file's access rights because NetworkManager requires it to be only accessible by root:
sudo chmod -R 600 /etc/NetworkManager/system-connections/YOURSSD.nmconnection
sudo chown -R root:root /etc/NetworkManager/system-connections/YOURSSD.nmconnection

With this file you should be able to automatically connect to your WiFi network during the first boot.

vinceskahan
Posts: 18
Joined: Thu Apr 10, 2014 2:30 am

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Sat Oct 14, 2023 9:42 pm

And how exactly would we get that file into our images if we burn them on Macs using BalenaEtcher ?

Note to others - I did open an issue on this being deprecated out and not replaced day-one with a working alternative mechanism...
---
Linux user since April 1992 when it came on 5.25" floppies and you had to compile things yourself...

wellings
Posts: 1
Joined: Sat Oct 14, 2023 10:01 pm

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Sat Oct 14, 2023 10:08 pm

Unbelievable. I lost 2-3 hours working through various headless PI tutorials (which I've used with success in the past) for them not to work, only to find this thread.

The fact that 'nmcli' is the way to go for static IP configuration should be obvious *somewhere*. Maybe I missed it in the documentation. The fact that dhcpcd is basically *missing* and /etc/network/interfaces doesn't appear to work is frustrating. 100s of old articles now obsolete without any obvious guidance on this.

Anway, thankfully I found this thread and I now have a static IP config that works.

bjtheone
Posts: 2745
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Sun Oct 15, 2023 12:07 am

vinceskahan wrote:
Sat Oct 14, 2023 9:42 pm
And how exactly would we get that file into our images if we burn them on Macs using BalenaEtcher ?

Note to others - I did open an issue on this being deprecated out and not replaced day-one with a working alternative mechanism...
rpi-imager is available for MacOS, and allows full configuration at time of image creation. Day one, working, tada....

Just built a Bookworm install, and preconfigured my WiFi networks without any issues.

lukami
Posts: 2
Joined: Thu Oct 12, 2023 11:35 pm

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Sun Oct 15, 2023 12:51 am

vinceskahan wrote:
Sat Oct 14, 2023 9:42 pm
And how exactly would we get that file into our images if we burn them on Macs using BalenaEtcher ?

Note to others - I did open an issue on this being deprecated out and not replaced day-one with a working alternative mechanism...
The same way the wpa_supplicant.conf was updated in the past. I first write the image to an SD card and then update the SD card's content with this file. My solution is for the OP's question about what to use instead of wpa_supplicant.conf.

tsgsh
Posts: 3
Joined: Wed Mar 16, 2022 11:47 pm

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Mon Oct 23, 2023 11:50 pm

lukami wrote:
Thu Oct 12, 2023 11:54 pm
Apparently nmconnection files for NetworkManager replaced the wpa_supplicant.conf. Nevertheless, they can be just as easily set up offline.
Full quote below
A little trial and error shows that it's necessary to generate a uuid for the nmconnection definition below (format 11111111-2222-3333-4444-555555555555), I don't believe NetworkNanager will accept a connection defined without it. You also need to unblock rfkill, which placing wpa_supplicant.conf on the boot partition did implicitly. You can also set the 802.11 country code for completeness/legality with a call to

Code: Select all

raspi-config nonint do_wifi_country <cc>
which in turn calls

Code: Select all

iw reg set <cc>
I stripped back the firstboot.sh created by rpi-imager and added the raspi-config command to get

Code: Select all

#!/bin/bash
# Stripped back version of the Bookworm firstrun.sh generated by the Raspberry Pi Imager
# also calls raspi-config to set Wifi country, which in turn calls iw on Bookworm
set +e
rfkill unblock wifi
for filename in /var/lib/systemd/rfkill/*:wlan ; do
    echo 0 > $filename
done
raspi-config nonint do_wifi_country GB
# edited to remove a bug in rpi-imager that is a hangover from Bullseye
# rm -f /boot/firstrun.sh
rm -f /boot/firmware/firstrun.sh
exit 0
(Note: There is some crda documentation that references NetworkManager using wpa_supplicant, and therefore (in theory) the country= entry in wpa_supplicant.conf would apply, but crda is obsolete with Bookworm and NetworkManager may no longer use wpa_supplicant, so I didn't test this.)
lukami wrote:
Thu Oct 12, 2023 11:54 pm
Apparently nmconnection files for NetworkManager replaced the wpa_supplicant.conf. Nevertheless, they can be just as easily set up offline.

Create a file in /etc/NetworkManager/system-connections/ called MYSSD.nmconnection with this content (change MYSSD and MYWIFIPASSWORD):

Code: Select all

[connection]
id=MYSSD
uuid=
type=wifi
interface-name=wlan0
autoconnect=true

[wifi]
mode=infrastructure
ssid=MYSSD

[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=MYWIFIPASSWORD

[ipv4]
method=auto

[ipv6]
method=auto
Restrict the file's access rights because NetworkManager requires it to be only accessible by root:
sudo chmod -R 600 /etc/NetworkManager/system-connections/YOURSSD.nmconnection
sudo chown -R root:root /etc/NetworkManager/system-connections/YOURSSD.nmconnection

With this file you should be able to automatically connect to your WiFi network during the first boot.
Last edited by tsgsh on Tue Oct 24, 2023 9:12 pm, edited 1 time in total.

User avatar
scruss
Posts: 5619
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Tue Oct 24, 2023 12:03 pm

bjtheone wrote:
Sun Oct 15, 2023 12:07 am
rpi-imager is available for MacOS, and allows full configuration at time of image creation. Day one, working, tada....
Imager is neither scriptable nor accessible, while files in /boot were both.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

jedahan
Posts: 2
Joined: Wed May 14, 2014 11:18 pm

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Tue Oct 24, 2023 3:55 pm

I dug into the source code a bit, to figure out what rpi-imager is actually doing

https://github.com/raspberrypi/rpi-ima ... 705C9-L749

So here, its still writing wpa_supplicant, but its also adding to a cloud-init definition.

cloud-init is https://cloudinit.readthedocs.io/en/latest/index.html

I have not looked into how cloud-init gets invoked on the pi on firstboot, but i've also found that rpi-imager does have a cli class:

https://github.com/raspberrypi/rpi-imag ... rc/cli.cpp

Running the following shows a very barebones help

Code: Select all

/Applications/Raspberry\ Pi\ Imager.app/Contents/MacOS/rpi-imager --help

Code: Select all

/Applications/Raspberry Pi Imager.app/Contents/MacOS/rpi-imager [--debug] [--version] [--repo <repository URL>] [--qm <custom qm translation file>] [--disable-telemetry] [<image file to write>]
-OR- /Applications/Raspberry Pi Imager.app/Contents/MacOS/rpi-imager --cli [--disable-verify] [--sha256 <expected hash>] [--debug] [--quiet] <image file to write> <destination drive device>
The help doesn't mention some of the options I see in the code:

Code: Select all

QCommandLineOption firstRunScriptOption("first-run-script", "Add firstrun.sh to image", "first-run-script", "");
QCommandLineOption userdataOption("cloudinit-userdata", "Add cloud-init user-data file to image", "cloudinit-userdata", "");
QCommandLineOption networkconfigOption("cloudinit-networkconfig", "Add cloud-init network-config file to image", "cloudinit-networkconfig", "");


So my guess is we could copy the template (also found in https://cloudinit.readthedocs.io/en/lat ... -config-v2)

Code: Select all

network:
    version: 2
    ethernets:
        eth0:
            optional: true
            dhcp4: true
    # add wifi setup information here ...
    wifis:
        wlan0:
            optional: true
            access-points:
                "YOUR-SSID-NAME":
                    password: "YOUR-NETWORK-PASSWORD"
            dhcp4: true
I have no idea if we need to also copy the logic for wpa_supplicant.conf and `cfg80211.ieee80211_regdom`. Maybe github.com/maxnet or github.com/63BeetleSmurf would know more.

Honestly, it seems cloud-init is not too far off from /etc/network/interfaces xD

I hope someone with more time can make a patch to a) the cli to show all options b) update the docs c) test that this all works.

jedahan
Posts: 2
Joined: Wed May 14, 2014 11:18 pm

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Tue Oct 24, 2023 4:48 pm

Digging more, `/boot/custom.toml` seems to be applied on firstboot only. I asked if it can be enabled to be applied on every boot, so that people can do something like https://cloudinit.readthedocs.io/en/lat ... every-boot

edit: request https://github.com/RPi-Distro/raspberry ... /issues/82

bjtheone
Posts: 2745
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Tue Oct 24, 2023 8:21 pm

scruss wrote:
Tue Oct 24, 2023 12:03 pm
bjtheone wrote:
Sun Oct 15, 2023 12:07 am
rpi-imager is available for MacOS, and allows full configuration at time of image creation. Day one, working, tada....
Imager is neither scriptable nor accessible, while files in /boot were both.
True. However the ask seemed to be how to I create images from a Mac, with WiFi configuration. Given that rpi-imager is available, and allows the appropriate creation (at least it does from Linux since that is how I built my test images and I assume the functionality is the same) you can create images from a Mac with pre-configurated WiFi.

If you want to do something funky and at a larger scale I suggest you are going to understand the requirements and built the production scripts to tweak and image cards in bulk.

tsgsh
Posts: 3
Joined: Wed Mar 16, 2022 11:47 pm

Re: bookworm - what in place of wpa_supplicant.conf and dhcpcd.conf

Tue Oct 24, 2023 9:17 pm

scruss wrote:
Tue Oct 24, 2023 12:03 pm
bjtheone wrote:
Sun Oct 15, 2023 12:07 am
rpi-imager is available for MacOS, and allows full configuration at time of image creation. Day one, working, tada....
Imager is neither scriptable nor accessible, while files in /boot were both.
If you want it scriptable and just using the /boot/firmware partition then (its mountpoint has changed in Bookworm), write a yourssid.nmconnection file and firstrun.sh (examples above) to /boot/firmware and modify the latter to include:

Code: Select all

mv yourssid.nmconnection /etc/NetworkManager/system-connections
nmcli conn reload
The firstrun.sh and .nmconnection examples I posted yesterday work*. I've built a Zero W, a 3A and a 4B (without WiFi), the last with an arm64 image without issues. The two line modification just above is untested, so it comes with a YMMV warning, but it's only a minor increase in complexity over what was available in Bullseye. It'll be quicker than waiting for an official solution to turn up.

* Edited today to fix a minor bug in firstrun.sh that I copied from the one generated by rpi-imager that doesn't account for the fact that the mount point has moved to /boot/firmware.

PS. uuidgen on MacOS provides a 128 bit hex string in the right format to include in the .nmconnection file (not shown in the example).

Return to “Raspberry Pi OS”