Previous versions of Raspberry Pi Os (previously Raspbian) uses dhcpcd to configure static IP address. From the version 12 onward they defaulted to Network Manager instead. The official documentation unhelpfully suggests using your router to give it a static IP, but in various homelab use cases you might want the device to come up with a correct IP even if the DHCP server or something else failed upstream to the Raspberry Pi.
Many are familiar with Network Manager's GUI configuration, but its command line tool nmcli may be a new acquaintance.
After the default installation you will have a network configuration called "Wired connection 1" and it uses DHCP. We are going to replace that with static example IP of 192.168.123.50, using router .1 and the Google public DNS 8.8.8.8. Note that you either need to be root or sudo the following commands:
nmcli con mod "Wired connection 1" ipv4.address "192.168.123.50/24" ipv4.gateway "192.168.123.1" ipv4.dns "8.8.8.8" ipv4.method manual
Unless it gives you an error, you can activate this new configuration by:
nmcli con up "Wired connection 1"
The actual configuration is stored under /etc/NetworkManager/system-connections and can be edited with a standard text editor.
No comments:
Post a Comment