Welcome to a tutorial on How to configure static IP address on CentOS 8/7 Linux. Have you been trying to find out an easy way to setup static IP Address on CentOS 8.7?, If so, then this guide is for you.

When working on servers, static IP address configurations is a must do a thing, regardless of the kind of server you’re administering.

ifconfig vs ip usage guide on Linux

To configure static IP address on CentOS, you can use any of the following methods:

  1.  Directing editing network configuration file under /etc/sysconfig/network-scripts/ directory.
  2.  Using nmcli network configuration command line tool
  3. Using nmtui network configuration tool
  4. Making static IP address configuration using ip and ifconfig commands.

We’ll look at all these methods in the next sections of this guide. Please note that the ip and ifconfig method doesn’t persist against reboots. It’s the only used when you need to test settings before you can commit them to a file.

Method 1: Configure Static IP Address by editing network configuration file

Suppose you have a server with a network interface named eth0 and would like set static network configurations for it, a file to create will be /etc/sysconfig/network-scripts/ifcfg-eth0, with its basic contents similar to below:


The most common configuration parameters with explanations are:

BOOTPROTO=<protocol> –> where <protocol> is one of the following:
none — No boot-time protocol should be used.
bootp — The BOOTP protocol should be used.
dhcp — The DHCP protocol should be used.

IPADDR=<address> –> where <address> is the IP address.
DEVICE=<name> –> where <name> is the name of the physical device.
DNS{1,2}=<address> –> where <address> is a name server address to be placed in /etc/resolv.conf
GATEWAY=<address> –> where <address> is the IP address of the network router
MACADDR=<MAC-address> –> Where <MAC-address> is the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:F
NETMASK=<mask> –> Where <mask> is the netmask value.
ONBOOT=<answer> –> Where <answer> is one of the following:
yes — This device should be activated at boot-time.
no — This device should not be activated at boot-time.
PEERDNS=<answer> –> Where <answer> is one of the following:
yes – Modify /etc/resolv.conf if the DNS directive is set. If using DHCP, then yes is the default.
no – Do not modify /etc/resolv.conf.
USERCTL=<answer> –> where <answer> is one of the following:
 yes  – Non-root users are allowed to control this device.
no – Non-root users are not allowed to control this device.

If you have NetworkManager service running, you’ll need to instruct the network service that network manager doesn’t manage this interface (eth0). This is done by adding the line;


Then you can stop NetworkManager service. For CentOS 7/8, this can be done using:

sudo systemctl stop NetworkManager

After saving the changes, the shut down the interface and bring it back:

sudo ifdown eth0 && sudo ifup eth0

Check current configurations using ip command:

$ ip addr show

If you would like to use ifconfig command but not installed, install it using:

sudo yum -y install net-tools

Then check your ip address information using ifconfig command.

$  ifconfig -a

Method 2: Configure Static IP using nmcli

NetworkManager is a daemon that sits on top of libudev and other Linux kernel interfaces and provides a high-level interface for the configuration of the network interfaces.

On the other hand, nmcli is a command-line tool used to control NetworkManager and reporting network status. It can be utilized as a replacement for nm-applet or other graphical clients. nmcli can create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status.

nmcli can do so much network configurations, let’s consider only basic ones here. Make sure NetworkManager service is running before trying to configure networking using nmcli tool.

$ systemctl status NetworkManager

If the service is not running, then start it:

$ sudo systemctl start NetworkManager

To control status of network interface with nmcli, pass down|up before NIC name. This will shut down interface or bring up an interface that was down.

sudo nmcli connection down eth0
sudo nmcli connection up eth0

Create network and configure static IP Address with nmcli

This example will show you how to create a new network called eth0 and configure it with an IPv4 address using nmcli.

Show current connections:

$ nmcli con show

Delete connection with same name before recreating. Use network name or network UUID shown from previous command:

$ nmcli con delete eth0

Create a network with name eth0

$ nmcli con add type ethernet ifname eth0 con-name eth0 \
  autoconnect yes ip4 gw4

Connection 'eth0' (804ce9b1-c5e1-42ff-b1a9-7a92e08e44a7) successfully added.

Configure DNS and make network configurations always be manual for this network interface.

nmcli con mod eth0 ipv4.method manual 
nmcli con mod eth0 ipv4.dns ""

Restart the network:

sudo nmcli con down eth0 && sudo nmcli con up eth0

View network configurations using show command with nmcli:

$ nmcli con show eth0

To delete the connection, use:

$ nmcli con del eth0
Connection 'eth0' (804ce9b1-c5e1-42ff-b1a9-7a92e08e44a7) successfully deleted.

Method 3: Making static IP address configuration using ip and ifconfig commands.

There is an existing guide on how to configure static IP address using ip and ifconfig commands available on:

Using ip and ifconfig to configure Linux networking.

Wrapping Up.

We have covered complete steps of How to configure static IP address on CentOS using manual modifications of network configuration files and using nmcli command line tool. Other tools are available like nmtui though deprecated and not recommended. Hope this was informative and thank you for viewing.

If you have freshly installed CentOS server, I recommend reading: Top Things to do after fresh installation of CentOS 7 minimal

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.



Please enter your comment!
Please enter your name here