Linux ping: unknown host error solution

  

sometimes ping command error on the Linux server, today to summarize if a Linux server ping nowhere domain name, the following prompt: [root@localhost ~]# ping www.pythontab .comping: unknown host www.pythontab.com first determines that the router is connected, and the router can access the external network, which can be determined by accessing the gateway [root@localhost ~]# ping 192.168.1.1PING 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 ms64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.75 ms If it is determined that the network is ok, You can find the solution by the following steps: 1) Make sure the domain name server is set. If not, it is recommended to set Google's public DNS service. It should not be a problem [root@localhost ~]# cat /etc/resolv.confsearch localdomain because My DNS is not set up, which causes the ping external network to ping. Add dns to the file [root@localhost ~]# vi /etc/resolv.confsearch localdomainnameserver 202.98.96.68nameserver 61.139.2.69~2) Make sure the gateway is set #grep GATEWAY /etc/sysconfig/network-scripts/ifcfg* -------------------------------------------------- ----------------- /etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=192.168.40.1 --------------- -------------------------------------------------- -- If not set, add the gateway as follows: # route add default gw 192.168.40.1 After manually writing the /etc/sysconfig/network-scripts/ifcfg* file, restart the network service: # service network restart 3) Make sure Dns parsing # grep hosts /etc/nsswitch.conf --------------------------------------- ---------------------------- hosts: files dns ------------------ ------------------------------------------------- in case Which of the above has a problem, after the correction, and then test, there should be no problem:

Copyright © Windows knowledge All Rights Reserved