Tomorrows Technology Today

How To

Configure Static IP Address with nmcli

To quickly edit the IP address of a server or VM without editing text files for netconf or sysconfig, the nmcli tool can be used. Problem is the syntax is hard to remember. So you can use this short guide and replace the values with those in your network.

Find the interface of the server with

ip a

Set the static IP address, default gateway and DNS, in this example the interface is ens33 with sudo user

nmcli con mod ens33 ipv4.addresses "192.168.33.33/24" ipv4.gateway "192.168.33.1" ipv4.method manual
nmcli connection modify ens33 ipv4.dns "8.8.8.8,192.168.33.2"
sudo nmcli con mod ens33 ipv4.dns-search "mydomain"
hostnamectl set-hostname test.mydomain

restart the networking service to make the changes take effect. (Or reboot the server)

systemctl restart NetworkManager

for more detail on using nmcli check Redhat RHEL9 documentation

Leave a Reply

Your email address will not be published. Required fields are marked *