The process of configuring your network settings in CentOS is a bit different from certain Linux distributions. By default, when you first install CentOS, NetworkManager is installed. We are going to go through the process of applying a static IP with it.
NetworkManager in CentOS
NetworkManager allows you to manage your interfaces with relative ease. While this may not seem ideal in an server environment, it is best fitted for a Linux desktop. Also you can configure your network settings with a GUI in the shell which makes it feel easier to configure.
While in shell, run this command to open up the GUI configuration:
You are now given a few options. In order for us to configure a static IP Address, we are going to select Edit a connection and press enter.
Here you will find a list of active network interfaces. As you can see, only one is active and selected by default. Hit enter to proceed.
You will need to navigate up/down using the arrows keys on the keyboard. Go to where is says show across from IPv4 CONFIGURATION and hit enter to show. Where it says Automatic change it to Manual. Next to Addresses, navigate to <Add…> and hit enter to input your desired IP address. Do the same for Gateway and DNS servers.
Afterwards, navigate all the way down to where it says <OK> and hit enter, <Back>, and then Quit to close. Restart NetworkManager.
systemctl restart NetworkManager
Run ip addr to make sure.
If you don’t want NetworkManager, go here to learn more.