Jump to content


- - - - -

Set a Static IP Address

CentOS 6.5

  • Please log in to reply
No replies to this topic

#1 Wilson18



  • root
  • 112 posts
  • LocationUniversity of Birmingham

Posted 28 May 2014 - 09:48 PM

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. 

nano /etc/sysconfig/network-scripts/ifcfg-eth0

In this file, you should see something like the following:



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=      #The new ip you would like to use
GATEWAY=       #The ip of your router
NETMASK=  #The subnet mask which is normally

The completed file should look like this

[attachment=80:network config.PNG]


Once you have done this, you can save and close the file using Ctrl + O and Ctrl + X.

We are now just going to add the gateway to another network config file just to make sure the system knows where to send the data when connecting to the web. 
nano /etc/sysconfig/network

In this, we just need to add the following: 

GATEWAY=  #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

nano /etc/resolv.conf

You can clear the current file and enter the following

nameserver #Your first nameserver
nameserver #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 
Once you have restarted the network, you can check to see if the network is using the new address. If you type in ifconfig, it should look something a little like this: 
We can then also ping google to make sure we have network connectivity and that our namesevers are working.
ping google.com

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.


List what you read?

Check me out on: YouTube, Twitter, Facebook, Google+

Also tagged with one or more of these keywords: CentOS 6.5