Bookworm - Static IP address from CLI

January 8, 2024, 06:57

oops.se

## Static IP in Raspberry Pi OS "BookWorm" There is two ways to change the IP to static in Raspberry Pi OS "BookWorm", with CLI (nmcli) or a text GUI app (nmtui). This guide will only cover nmcli ## The nmcli way To get the current values, and write them down before proceeding: ip a - Shows the current IP adress. route -n - Shows the default gateway. nmcli device show | grep 'IP4.DNS' - Shows the current DNS Server. ## 1. To get the UUID for the connection you want to set a static IP to sudo nmcli con show ## 2. Replace <UUID> with the UUID from the command above in the following command:
sudo nmcli con mod <UUID> ipv4.addresses <Static IP>/<Subnet mask>
sudo nmcli con mod <UUID> ipv4.gateway <IP to gateway>
sudo nmcli con mod <UUID> ipv4.dns "<IP to DNS server>"
sudo nmcli con mod <UUID> ipv4.method manual

sudo nmcli con up <UUID>
And enter the values where there is a text enclosed in <>. ### Example:
sudo nmcli con mod 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e ipv4.addresses 192.168.111.21/24
sudo nmcli con mod 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e ipv4.gateway 192.168.111.1
sudo nmcli con mod 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e ipv4.dns "192.168.111.1"
sudo nmcli con mod 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e ipv4.method manual

sudo nmcli con up 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e