In this tutorial, I will be showing you how you can set up a Static IP Address on CentOS 6.5. Once logged in to your server as the root user. The first thing we are going to be doing is to stop the Network manager from trying to automatically handle the network for us. This will stop all of our settings been overridden at a later date. To do this, we can type
service NetworkManager stop
After this, we will permanently turn this off and stop it been enabled again on startup.
chkconfig NetworkManager off
Once we have done this, we can go through and edit the configuration file for the network adapter so that we can tell it which address to use.
In this file, you should see something like the following:
DEVICE="eth0" BOOTPROTO="dhcp" HWADDR="00:0C:29:C2:97:CD" IPV6INIT="yes" NM_CONTROLLED="yes" ONBOOT="yes" TYPE="Ethernet" UUID="95befdbb-d66f-4565-8f4a-d62292304ec6"
The thing we need to change in this is to set the BOOTPROTO to static instead of dhcp. This should look like this.
Once we have done this, we can set up our new IP at the bottom of the file. To do this, you will need to add the following three lines but make sure to put in the information which is appropriate to your network configuration.
IPADDR=10.0.0.109 #The new ip you would like to use GATEWAY=10.0.0.1 #The ip of your router NETMASK=255.255.255.0 #The subnet mask which is normally 255.255.255.0
The completed file should look like this
Once you have done this, you can save and close the file using Ctrl + O and Ctrl + X.
In this, we just need to add the following:
GATEWAY=10.0.0.1 #Your gateway
Once you have done this, saved and closed the file, we can go to add the name servers we would like to use to resolve dns. The file we will need to edit is
You can clear the current file and enter the following
nameserver 188.8.131.52 #Your first nameserver nameserver 184.108.40.206 #Your second nameserver
You can add as many nameservers as you would like. Again, save and close this file. Once we have done all this, everything should be done. We can now restart our network interface to make sure our changes have been taken into account.
service network restart
If you go ahead and restart your server, you should see that everything is still working and using the details you used. If this is not the case, please make sure you follow the first few steps to disable the NetworkManager.