2014-09-06
When the Linux server ping does not pass the domain name, the following prompt appears:
[[email protected] ~]# Ping www.baidu.com
Ping:unknown Host Www.baidu.com
1. Network detection
First determine that the router is connected and the router has access to the extranet, which can be determined by accessing the gateway
[[email protected] ~]# Ping 192.168.2.251
PING 192.168.2.251 (192.168.2.251) bytes of data.
Bytes from 192.168.1.1:icmp_seq=1 ttl=64 time=2.96 ms
If you determine that the network is not a problem, you can find a workaround by following these steps:
1) OK set up the domain name server, if not, it is recommended to set up Google's public DNS service, it should not be a problem
[email protected] ~]# vi/etc/resolv.conf
nameserver 192.168.2.251
2) Make sure the gateway is set
# grep gateway/etc/sysconfig/network-scripts/ifcfg*
/etc/sysconfig/network-scripts/ifcfg-eth0:gateway=192.168.2.251
if it is not set, the gateway is increased in the following ways:
# route Add default GW 192.168.2.251
or, after manually writing the/etc/sysconfig/network-scripts/ifcfg* file, restart the network service:
# Service Network Restart
3) ensure available DNS resolution
# grep hosts/etc/nsswitch.conf
Hosts:files DNS
Successful results:
If any of the above problems, after the correction, re-test, should be no problem:
#ping www.baidu.com
PING www.a.shifen.com (220.181.6.175) bytes of data.
Bytes from 220.181.6.175:icmp_seq=0 ttl=50 time=9.51 ms
Linux server ping does not pass domain name