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
联系方式QQ:326528263 EMAIL:clnking@163.com 网名:bass 分享技术 突破难点 创新思维