Steps to assign static IP address in CentOS Linux via command line?

Senior Systems Engineer asked:

How to configure so the Linux CentOS v8 VM I have with static IP address?

I have already set the networking parameter during the GUI installation, but after the reboot, it still reverting back with DHCP IP addressing?

Do I have to create a new interface file rather than modifying the below:

 cat /etc/sysconfig/network-scripts/ifcfg-ens192

Note: I cannot even restart the network service as mentioned in the various blog:

[[email protected] etc]# systemctl restart network
Failed to restart network.service: Unit network.service not found.

My answer:


By default, networking on CentOS 7 and 8 is managed by NetworkManager.

It uses a plugin called ifcfg-rh to read the old network service configuration files (used in CentOS 6 and previous versions) such as the one you mentioned and translate them into the appropriate NetworkManager configuration.

What has probably happened here is that the interface name has changed from what it was during installation. This often happens with virtual machines running under VMware products. It looks like you had the interface name ens192 at install time. You can use ip link to see the current interface name.

If the name differs, you can edit the file and change the interface name within, then reload NetworkManager.

[[email protected] ~]# systemctl reload NetworkManager 

While NetworkManager excels at managing networks for desktop/laptop systems, and certainly works for servers, it’s quite heavy for that purpose. I’ve lately begun switching my CentOS 8 servers to the much lighter systemd-networkd, which is a bit better integrated into the system, but doesn’t support desktop/laptop systems (particularly WiFi) as well. You might consider doing the same.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.