Solve Linux Ping: Unknown host www.baidu.com

Source: Internet
Author: User
Linux Ping: Unknown host www.baidu.com from http://www.cnblogs.com/happyhotty/articles/2539951.html

"Ping: Unknown host www.baidu.com"
Solution:
If a Linux server cannot ping the domain name, the following prompt is displayed:

[Root @ localhost ~] # Ping www.baidu.com
Ping: Unknown host www.baidu.com

First, make sure that the vro is connected and the vro can access the Internet.

[Root @ localhost ~] # Ping 192.168.1.1
Ping 192.168.1.1 (192.168.1.1) 56 (84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq = 1 TTL = 64 time = 2.96 MS
64 bytes from 192.168.1.1: icmp_seq = 2 TTL = 64 time = 1.75 MS

If the network is correct, follow these steps:
1) Confirm that the Domain Name Server has been set. If not, it is recommended to set up Google's public DNS Service, which should not cause problems.


[Root @ localhost ~] # Cat/etc/resolv. conf

Search localdomain

Because my DNS is not set, the ping to the Internet fails. Add DNS to this file

[Root @ localhost ~] # Vi/etc/resolv. conf

Search localdomain
Nameserver 202.98.96.68
Nameserver 61.139.2.69
~

2) Make sure that the gateway has been set

# Grep gateway/etc/sysconfig/network-scripts/ifcfg *
-------------------------------------------------------------------
/Etc/sysconfig/network-scripts/ifcfg-eth0: Gateway = 192.168.40.1
-------------------------------------------------------------------

If not, add the gateway as follows:

# Route add default GW 192.168.40.1

You can also manually write the/etc/sysconfig/network-scripts/ifcfg * file and restart the network service:

# Service network restart

3) make sure DNS resolution is available

# Grep hosts/etc/nsswitch. conf
-------------------------------------------------------------------
Hosts: Files DNS
-------------------------------------------------------------------

If any of the above problems occurs, correct them and test them again. The problem should be solved:

# Ping-C 3 www.baidu.com
Ping www.a.shifen.com (220.181.6.175) 56 (84) bytes of data.
64 bytes from 220.181.6.175: icmp_seq = 0 TTL = 50 time = 9.51 MS
64 bytes from 220.181.6.175: icmp_seq = 1 TTL = 50 time = 8.45 MS
64 bytes from 220.181.6.175: icmp_seq = 2 TTL = 50 time = 8.97 MS
--- Www.a.shifen.com Ping statistics ---
3 packets transmitted, 3 bytes ed, 0% packet loss, Time 2002 Ms
RTT min/AVG/max/mdev = 8.450/8.977/9.511/0.446 MS, pipe 2

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.