CentOS6.5 ping: unknown host solution

Source: Internet
Author: User
Tags nameserver

If a Linux (CentOS) server is pinged to the domain name, the following prompt is displayed:
# Ping www.sina.com
Ping: unknown host www.sina.com

If the network is correct, follow these steps:
1) Confirm that the Domain Name Server is set

# Cat/etc/resolv. conf
Nameserver 8.8.8.8# (Google's public DNS Service)
Nameserver 8.8.4.4# (Google's public DNS Service)

2) Confirm that the gateway has set/confirmed that the route table is normal

# Netstat-rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.10.10.1 0.0.0.0 UG 0 0 0 eth0

If not, add the gateway as follows:
# Route add default gw 10.245.75.1

# Grep GATEWAY/etc/sysconfig/network-scripts/ifcfg *
/Etc/sysconfig/network-scripts/ifcfg-eth0: GATEWAY = 10.245.75.1

3) confirm that dns resolution is available

# Grep hosts/etc/nsswitch. conf
Hosts:Files dns


The above 1) 2) 3) Just confirm the problem. I like to manually write the configuration file to solve the problem once.
After configuring the/etc/sysconfig/network-scripts/ifcfg-eth0 file, restart the network service:
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = "eth0"
NM_CONTROLLED = "yes"
ONBOOT = yes
TYPE = Ethernet
BOOTPROTO = static
IPADDR = 10.245.75.240
# PREFIX = 24
GATEWAY = 10.245.75.1
DNS1 = 8.8.8.8
DNS2 = 8.8.4.4
DEFROUTE = yes
20174_failure_fatal = yes
IPV6INIT = yes
NAME = "System eth0"
UUID = xxxxxxxx-xxxx-xxxxxxxxxxxx # uuid
HWADDR = xx: xx# Hwaddr
NETWORKING = yes

# Service network restart

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.