Set a static IP address with nmtui on Raspberry Pi OS 12 'Bookworm'
Old advice for setting a Raspberry Pi IP address to a static IP on the Pi itself said to edit the /etc/dhcpcd.conf
file, and add it there.
But on Raspberry Pi OS 12 and later, dhcpcd
is no longer used, everything goes through Network Manager, which is configured via nmcli
or nmtui
. If you're booting into the Pi OS desktop environment, editing the IP settings there is pretty easy.
But setting a static IP via the command line is a little different.
First, get the interface information—you can get a list of all interfaces with nmcli device status
:
$ nmcli device status
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected Wired connection 1
lo loopback connected (externally) lo
wlan0 wifi disconnected --
In my case, I want to set an IP on eth0
, the built-in Ethernet.