In this small tutorial, I will show you how to convert from DHCP to Static IP address.
Configure eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0HWADDR=08:00:27:76:4c:d5TYPE=EthernetONBOOT=yesBOOTPROTO=noneIPV6INIT=noUSERCTL=noNM_CONTROLLED=yesPEERDNS=yesIPADDR=192.168.1.140NETMASK=255.255.255.0
Configure Default Gateway
# vi /etc/sysconfig/network
NETWORKING=yesHOSTNAME=centos6GATEWAY=192.168.1.1
Configure DNS Server
# vi /etc/resolv.conf
nameserver 8.8.8.8 # Replace with your DNS1nameserver 192.168.1.1 # Replace with your DNS2
Restart Network Interface
# /etc/init.d/network restart
Check now
# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:76:4C:D5 inet addr:192.168.1.140 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe76:4cd5/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:366 errors:0 dropped:0 overruns:0 frame:0 TX packets:252 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:34247 (33.4 KiB) TX bytes:27082 (26.4 KiB)
Check the Connectivity
[root@centos6 ~]# ping centos.org
PING centos.org (85.12.30.227) 56(84) bytes of data.64 bytes from 85.12.30.227: icmp_seq=1 ttl=56 time=10.2 ms64 bytes from 85.12.30.227: icmp_seq=2 ttl=56 time=11.0 ms^C--- centos.org ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1596msrtt min/avg/max/mdev = 10.233/10.623/11.013/0.390 ms
[root@centos6 ~]# nslookup centos.orgServer: 62.179.104.196Address: 62.179.104.196#53Non-authoritative answer:Name: centos.orgAddress: 85.12.30.227