Static IP address on Raspberry Pi 4

January 11, 2024, 13:32

andrejzika

Hello, Im strugling to set up a static IP address on my raspberry pi 4. when I open dhcpcd, It is completely empty. Ive heard that i might have to use Network Manager but im not sure how. Can anybody help me with this problem?

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.1.1
sudo nmcli con mod 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e ipv4.dns "192.168.1.1"
sudo nmcli con mod 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e ipv4.method manual

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