Quick Tip: Configure Static IP in Centos 6.5

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=eth0
HWADDR=08:00:27:76:4c:d5
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPV6INIT=no
USERCTL=no
NM_CONTROLLED=yes
PEERDNS=yes
IPADDR=192.168.1.140
NETMASK=255.255.255.0

Configure Default Gateway

# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=centos6
GATEWAY=192.168.1.1

Configure DNS Server

# vi /etc/resolv.conf
nameserver 8.8.8.8 # Replace with your DNS1
nameserver 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 ms
64 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 1596ms
rtt min/avg/max/mdev = 10.233/10.623/11.013/0.390 ms
[root@centos6 ~]# nslookup   centos.org
Server:         62.179.104.196
Address:        62.179.104.196#53
Non-authoritative answer:
Name:   centos.org
Address: 85.12.30.227


你可能感兴趣的:(gateway,convert)