NOOB2ROOT

Field Guide Platform

NetworkManager (nmcli)

The tool that manages network connections on Raspberry Pi OS. I use its command line, nmcli, to give the Pi a static IP and stop the router overriding its DNS.

#What it is

NetworkManager owns the network configuration on current Raspberry Pi OS releases (it replaced dhcpcd from the Bookworm release onwards). nmcli is its command-line front end. Each network setup is a named connection profile, and the wired one is usually called Wired connection 1.

#Why I use it

A DNS server has to live at an address that never changes, because every device in the house is told to use that address. nmcli sets that up in a couple of commands, and the setting survives reboots.

#The commands I actually use

nmcli -t -f NAME,DEVICE con show          # find the connection name
ip route | grep default                    # find the router (gateway)

sudo nmcli con mod "Wired connection 1" \
  ipv4.method manual \
  ipv4.addresses 192.168.1.213/24 \
  ipv4.gateway 192.168.1.254 \
  ipv4.dns "1.1.1.1"
sudo nmcli con up "Wired connection 1"

sudo nmcli con mod "Wired connection 1" ipv6.ignore-auto-dns yes   # ignore router's IPv6 DNS
sudo nmcli radio wifi off                  # one interface, one IP

#Gotchas I hit

  • Pick an address outside the router's DHCP pool, or reserve it, or the router will eventually hand the same IP to something else.
  • The router's IPv6 DNS sneaks in. Many routers advertise themselves as a DNS server over IPv6, which shows up as an fe80:: line in /etc/resolv.conf. ipv6.ignore-auto-dns yes stops it.
  • Wired plus Wi-Fi means two IPs on the same network, and whichever one a device happens to learn about is the one it uses. Turn Wi-Fi off on a wired Pi.
  • Guides that tell you to edit /etc/dhcpcd.conf are for older releases. On a current Pi, that file does nothing.

← All Field Guide entries