How to configure a static CentOS 8 network address from the command line

CentOS 8 is here and it's chock full of new features and improvements. One feature that has not changed all that much is the configuration of a static network address. Although Ubuntu migrated to the much more user-friendly netplan tool, CentOS is still using the old-school method.

If you don't happen to know how to manually configure a network address, switching it from DHCP to static, I'm going to show you how.

SEE: Hiring kit: Network administrator (TechRepublic Premium)

What You'll Need

All you'll need to make this work is the following:

How to locate the device name

The first thing we must do is locate the device name to be configured. Do this with the command:

This should reveal the name of your network interface (Figure A).

Figure A

How to backup your configuration file

Next, we're going to backup the original configuration file with the command:

Where NAME is the name of your network interface.

How to create a new configuration

Now we create a new configuration file with the following command:

Where NAME is the name of your network interface.

In that file, paste the following:


Save and close the file.

Restart the network manager with the command:

Your static IP address has been applied

How to configure DNS servers

Because we're using a static IP address, we might also want to use static addresses for DNS resolution (which is why we added PEERDNS=no to the configuration file). To configure DNS servers, issue the command:

In that file, add your static DNS addresses below the last line like so:

Save and close the file.

And that's all there is to configuring a static IP address in CentOS 8.

Also see