Friday, July 18, 2014

Static IP Configuration on CentOS 6.5

The reason I wanted to share this post is configuring static IP on CentOS seems to trouble many centos users. Probably, when you configure static IP, network may not work as you expected, sometimes no internet access, sometimes no IP address  on eth0 etc..

First, "watch-out whether it is a CentOS Desktop version or Server version".? because they are runs at different run-levels, where;
  • Desktop ver runs on run-level 3
  • Server ver runs on run-level 5 

Second, watch-out the configuration on  
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:AA:BB:CC:DD 
NM_CONTROLLED=no ------------------------------------ specify not to controlled by "NetworkManager"
ONBOOT=yes ---------------------------------------------- specify to bring up the interface(eth0) at boot
IPADDR=192.168.1.10
NETMASK=255.255.255.0

NOTE By default, "NetworkManager" service is run at run-level 5
 
As you can see, we explicitly tell the system not to control the network interfaces by "NetworkManager" service. Due to this, when you set this configuration on CentOS Desktop, network will not starts as there is no services to control network interfaces.

Now you may think that, Ok, lets change the configuration as NM_CONTROLLED=yes. Of course, this will make NetworkManager to bring the interface(eth0) up and  to have an IP address assigned on it. But the problem is that the system still doesn't know the gateway IP address, which could be locates at $ vi /etc/sysconfig/network

I think now you already scene, "well if the NetworkManager cannot bring up the network right with all the configuration, we need another service that will do the job right"

Yes, there is and that service is "network". But what happened behind the seen is that this service, by default, is not started at run-level 5(as you are in Desktop version).

Lets tell the system to start the "network" service at run-level 5.
$ sudo chkconfig --level 5 network on

Apart from that, make sure 

GATEWAY IP address in set at$ vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain

GATEWAY=192.168.1.1   

DNS server address in set at
$ vi /etc/resolv.conf
nameserver 8.8.8.8

!!!!! - that's all. reboot the system and check your system - !!!!!
   
   

No comments:

Post a Comment