How to Configure Static IPv4 Address on AlmaLinux, Rocky Linux, and CentOS using nmcli

A static IP address is an IP address that doesn't change over time. IP (internet protocol) addresses are numerical signifiers that allow data packets to be sent and received from our networks and devices.

Identify the Network Interface

Determine the name of your network interface. You can use the ip a or ifconfig command to list available interfaces.

Common names for interface include ens3, eth0, enp3s0 and many more,

ip a


root@vps ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    inet brd scope global noprefixroute ens3
       valid_lft forever preferred_lft forever
    inet6 2604:0456:0145::1/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
[root@vps ~]# 

from the above output, the network interface is ens3.

Create the Interface Configuration File

Now that we know our Interface Name, we will navigate to /etc/NetworkManager/system-connections/ directory, where all the NetworkManager's configuration files would be placed.

Create a new .nmconnection file for your network interface. You can use a text editor, For example, nano or vi, to create a file for the ens3 interface,

cd /etc/NetworkManager/system-connections/

nano ens3.nmconnection

In the editor, add the following content, replacing the placeholder values with your actual network configuration:



Note: Replace "interface" ens3 with the actual interface name that is on your server.
Replace "address" with the actual IP address that is assigned to your server.
Replace "gateway" with the actual Gateway address assigned to the server.

You can find the IP address information from CrownPanel, Refer our wiki on How to View Network Information in CrownPanel.

For DNS, you can use the standard Google IP address or from CloudFlare,

  • Google:,
  • CloudFlare:

Save and exit from the file.

Restart Network Service

Once the configuration file has been updated with the required IP information, we will go onto restart the NetworkManager for the changes to take effect.

systemctl restart NetworkManager

Now, your system should use the static IP address specified in the .nmconnection file for the specified network interface.

This concludes our topic of configuring Static Network Interface on the AlmaLinux, Rocky Linux, and CentOS Stream 9 using NetworkManager.