How to Configure Static IP Address on CentOS 6.2 Linux Server

After you have installed CentOS 6.2 linux server, the network configuration will be like this.

    DEVICE="eth0"
    HWADDR="xx:xx:xx:xx:xx:xx"
    NM_CONTROLLED="yes"
    ONBOOT="no"
    

The system will no get the ip automatically and the network interface will not auto start even after the server rebooted. Follow this steps to set static ip and set it auto start once rebooted in CentOS 6.2 :

1. Configure eth0:

    [root@centos6 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
    
    DEVICE="eth0"
    HWADDR="00:0C:29:67:51:B1"
    NM_CONTROLLED="yes"
    ONBOOT="yes"
    IPADDR=192.168.1.44
    BOOTPRO=static
    NETMASK=255.255.255.0
    

2. Configure Default gateway:

    [root@centos6 ~]# vi /etc/sysconfig/network
    
    NETWORKING=yes
    HOSTNAME=centos6.2
    GATEWAY=192.168.1.1
    

3. Restart Network interface:

    [root@centos6 ~]# /etc/init.d/network restart
    

or

    [root@centos6 ~]# Service network restart
    

4. Configure DNS server:

    [root@centos6 ~]# vi /etc/resolv.conf
    
    nameserver 8.8.8.8
    nameserver 192.168.1.1
    
3 comments
  1. vol123
    vol123
    April 1, 2012 at 10:10 pm

    Exellent!!! Thanks alot )

    Reply
  2. Xplorer4x4
    Xplorer4x4
    April 2, 2012 at 5:44 pm

    Thank you for the useful guide. Much appreciated! However, if I may make a suggestion. Usually I use nano, but it seems it is not built in to CentOS6.X so I was not familiar with Vim and assumed CTRL+X would work. May I suggest a quick mention of using ESC then typing :X and hit enter?

    Reply
Leave a Reply

Your email address will not be published. Required fields are marked *

SiteGround.com

A world leading hosting company that provides fully-managed innovative and secure solutions, suitable for hosting small to medium-sized websites

Built on the best available technologies combined with Google Cloud for strong redundancy and application availability. Backed by skilled experts to address web security threats, a devops team to create advanced custom security solutions, and 24/7 sysadmins to watch over the platform. This powerful, hands-on approach makes your sites faster, safer, and easier to manage. Starting from only $3.95/mo.

TRY FREE

* up to 30 days money back guarantee