This document explains how to set a static IP address on an Ethernet interface using `nmcli`, assuming you are connected to the machine via SSH.
'enp2s0''192.168.0.31''192.168.0.1''8.8.8.8' and '1.1.1.1'sudo nmcli con add type ethernet ifname enp2s0 con-name static-ip autoconnect no ip4 192.168.0.31/24 gw4 192.168.0.1
sudo nmcli con mod static-ip ipv4.dns "8.8.8.8 1.1.1.1"
Note: This may temporarily disconnect the SSH session. Reconnect using the static IP:
sudo nmcli con up static-ip
Once confirmed that the static IP connection works:
sudo nmcli con delete "Wired connection 1"
sudo nmcli con mod static-ip connection.autoconnect yes
nmcli con show
ip addr show enp2s0
The machine will use the static IP '192.168.0.31' permanently, even after reboots, without relying on DHCP.