Thursday 11 August 2011

CentOS: Manual IP network configuration

Just installed my first CentOS 6.0 test server. In order to save bandwidth, I downloaded the minimal installation ISO which produced a Linux system that was able to boot correctly, but provided none of the standard system-config-... tools. So in order to continue installation, I had to setup IP information for the systems network card by manually editing files. This is a summary of the steps I followed.

  1. Go to /etc/sysconfig/network-scripts/ and edit file ifcfg-eth0. Then, make sure you provide the following keys
             DEVICE=eth0
             HWADDR=00:1f:29:c3:22:16
             BOOTPROTO=static         
             NM_CONTROLLED=yes
             ONBOOT=yes
             IPADDR=10.5.0.6
             NETMASK=255.255.255.0
         
  2. Open file /etc/sysconfig//network and add information for host name and default gateway like this :
             NETWORKING=yes
             HOSTNAME=barbara.shelman.int
             GATEWAY=10.5.0.1
        
  3. The DNS servers are defined in /etc/resolv.conf. Typically the file looks like this:
             nameserver 10.5.1.1
             nameserver 10.5.1.2
         
  4. Network manager should pick up the changes immediately. In case it does not, restart the netwrok service like this :
             /etc/init.d/network restart
        

This is the minimal setup that worked for me. After I was able to set up my yum proxy and begin installation of CentOS packages, I was able to run system-config-network, which changed many of the previous entries. For example the gateway information in now stored in ifcfg-eth0, along with the DNS information. The previous setup however, is what go me started.

5 comments :

Unknown said...

Thanks for the post Thanassis. I infrequently spin up minimal CentOS installs and always need to do a search for the commands to start up the networking.

Your post is succinct and to the point. Bookmarked and a copy put into my Evernote repo for future use. Much appreciated!

Unknown said...

Thanks for the post Thanassis. I infrequently spin up minimal CentOS installs and always need to do a search for the commands to start up the networking.

Your post is succinct and to the point. Bookmarked and a copy put into my Evernote repo for future use. Much appreciated!

Girish KG said...

Thanks a lot for the time saving help guide, I wasted almost 6 hours before reaching here. CentOS is rocking after your help. Thanks again.

-Girish from India

Girish KG said...

Thanks a lot for the time saving help guide, I wasted almost 6 hours before reaching here. CentOS is rocking after your help. Thanks again.

-Girish from India

Unknown said...

But how do you get information on what to type in "IPADDR="?