ping: unknown host www.baidu.com


 #注意有很多的DNS服務器 為了防止DDOS攻擊 所以都禁止PING 

[root@86 ~]# ping -c 2 www.baidu.com
ping: unknown host www.baidu.com

 如果出現上面的問題,先看DNS配置是否有問題:

[root@86 ~]# cat /etc/resolv.conf 
options timeout:1 attempts:1 rotate
nameserver 10.202.72.116
nameserver 10.202.72.118

 

[root@86 ~]# ping 10.202.72.116
PING 10.202.72.116 (10.202.72.116) 56(84) bytes of data.
^C
--- 10.202.72.116 ping statistics ---
29 packets transmitted, 0 received, 100% packet loss, time 28080ms

 

[root@86 ~]# ping 8.8.8.8 -c 2
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

--- 8.8.8.8 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 10999ms

[root@86 ~]# ping 8.8.8.8 -c 8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=41 time=57.6 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=41 time=58.8 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=41 time=57.3 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=41 time=62.7 ms

--- 8.8.8.8 ping statistics ---
8 packets transmitted, 4 received, 50% packet loss, time 8005ms
rtt min/avg/max/mdev = 57.335/59.137/62.782/2.185 ms

 

[root@86 ~]# cat /etc/resolv.conf
options timeout:1 attempts:1 rotate
nameserver 8.8.8.8
nameserver 4.4.4.4

 

[root@86 ~]# ping www.baidu.com -c 2
PING www.a.shifen.com (220.181.111.188) 56(84) bytes of data.
64 bytes from 220.181.111.188: icmp_seq=1 ttl=52 time=3.82 ms
64 bytes from 220.181.111.188: icmp_seq=2 ttl=52 time=3.79 ms

--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1170ms
rtt min/avg/max/mdev = 3.796/3.810/3.824/0.014 ms

 ----------------------------------------------------------------新裝虛擬機VHOST設了防火牆不能用ping解析域名-----------------------------

iptables 是通過腳本設的(內容如下)
#!/bin/bash
set -x
#design by bass
/etc/init.d/iptables stop
iptables -P INPUT ACCESS
iptables -P FORWORD ACCESS
iptables -P OUTPUT ACCESS
iptables -F
iptables -X
iptables -L -n
/etc/init.d/iptables save
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#郵箱服務開啟25,110端口 
iptables -A INPUT -p tcp --dport 110 -j ACCEPT
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
#ftp服務開啟21,20 以及被動模式的隨機端口
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 20 -j ACCEPT
#DNS服務開53端口
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
#允許icmp包通過,也就是允許PINT
iptables -A INPUT -p icmp -j ACCEPT
#允許loopback(不然會導致DNS無法正常關閉)
iptables -A INPUT -i lo -p all -j ACCEPT
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

 

[root@IPT sysconfig]# ping www.baidu.com
ping: unknown host www.baidu.com

 

[root@IPT ~]# vi /etc/sysconfig/network
[root@IPT ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=IPT
GATEWAY=192.168.1.1
#增加網關

 

[root@IPT ~]# ping www.baidu.com -c 2
PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.
64 bytes from 61.135.169.125: icmp_seq=1 ttl=54 time=2.18 ms
64 bytes from 61.135.169.125: icmp_seq=2 ttl=54 time=1.92 ms

--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1003ms
rtt min/avg/max/mdev = 1.929/2.055/2.182/0.134 ms

 

[root@IPT ~]# cat /etc/resolv.conf 
; generated by /sbin/dhclient-script
nameserver 202.106.196.115
nameserver 202.106.0.20
#nameserver 8.8.8.8
#nameserver 4.4.4.4

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM