You have installed CentOS and now you’d like to either change the IP address or add additional LAN cards (NIC). There are a couple of ways to configure the network card using the command line but only some commands will take immediate effect on kernel.
Configure network with immediate effect
Using a single command line to configure the network
# ifconfig eth0 192.168.0.10 netmask 255.255.255.0
[or]
# ip addr add 192.168.0.10 dev eth0
Configure network with setup or netconfig
If you are using netconfig (or) setup utility it will only overwrite the /etc/sysconfig/network-scripts/ifcfg-eth0 file. Then , after that u have to restart the network service like follow,
# setup
Network configuration -> Edit Devices -> eth0 (eth0) – Intel Corporation 82540EM Gigabit Ethernet Controller
Save your settings and quit
[or]
# system-config-network
Edit Devices -> eth0 (eth0) – Intel Corporation 82540EM Gigabit Ethernet Controller
Save your settings and quit
Restart your network in order for your configuration to take effect.
# /etc/init.d/network restart
Configure network by editing configuration
Lastly you can configure the network by editing the configuration files stored in the /etc/sysconfig/network-scripts/ directory.
# cd /etc/sysconfig/network-scripts/
# vi ifcfg-eth0
Append/modify as follows:
1 2 3 4 5 6 7 8 | # Intel Corporation 82540EM Gigabit Ethernet Controller DEVICE=eth0 BOOTPROTO=none ONBOOT=yes HWADDR=06:01:78:a7:00:33 NETMASK=255.255.255.0 IPADDR=192.168.0.10 TYPE=Ethernet |
Save and close the file. Define default gateway and hostname in /etc/sysconfig/network configuration file
# vi /etc/sysconfig/network
Append/modify configuration as follows:
1 2 3 4 | NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=centos.how2centos.com GATEWAY=192.168.0.1 |
Save and close the file. Restart networking:
# /etc/init.d/network restart

6 Comments » 
