Set static IP address for Cent OS 6

After default CentOS 6.x installation the OS tries to get the IP address via DHCP, so if you want to set a static IP for your machine you need to set it manually by editing the eth0.

Login to the OS and edit the eth0:

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

It should be something like this:

DEVICE=”eth0″
BOOTPROTO=”dhcp”
HWADDR=”00:2C:X4:44:5C:EV”
NM_CONTROLLED=”yes”
ONBOOT=”no”
TYPE=”Ethernet”
UUID=”2cb817v1-2513-4cf7-9d56-44a0ef25d3b2″

Hit the “Insert” key to enable editing and change it like this:

DEVICE=”eth0″
BOOTPROTO=”static”
HWADDR=”00:2C:X4:44:5C:EV”
NM_CONTROLLED=”yes”
ONBOOT=”yes”
TYPE=”Ethernet”
UUID=”2cb817v1-2513-4cf7-9d56-44a0ef25d3b2″
IPADDR=xxx.xxx.xxx.xxx
NETMASK=255.255.255.xxx
GATEWAY=xxx.xxx.xxx.xxx

Now to save these changes hit the “Escape” key and write:

:wq

You need to set the name server too, so enter the command:

vi /etc/resolv.conf

hit the “Insert” key and write these:

nameserver 4.2.2.4
nameserver 8.8.8.8

once again hit the “Escape” and :wq

You need to restart the networking as the last step:

service network restart

Your machine is connected to the Internet.

Note:

xxx.xxx.xxx.xxx means your choosen Ip
4.2.2.4 and 8.8.8.8.8 are Google public DNS servers.
We have tested this method on  VMware machines for both 32 and 64 bit OS.

Privacy Preferences
When you visit our website, it may store information through your browser from specific services, usually in form of cookies. Here you can change your privacy preferences. Please note that blocking some types of cookies may impact your experience on our website and the services we offer.