知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

Linux能ping通IP,ping不通域名

发布时间:2014-09-05 13:17:59作者:知识屋

今天碰到个问题, 能ping通IP地址, ping不通域名, 一直以为是 DNS解析服务器的问题, 找了半天, 问题不在这里。

[root@www postfix]# cat /etc/resolv.confnameserver 202.96.209.133options attempts:1 timeout:1 rotate#nameserver 10.202.72.117nameserver 10.202.72.118nameserver 114.114.114.114nameserver 8.8.8.8[root@www postfix]# 

看了一下路由表, 问题也不在路由网关上。

[root@www postfix]# netstat -rnKernel IP routing tableDestination     Gateway         Genmask         Flags   MSS Window  irtt Iface115.28.80.0     0.0.0.0         255.255.252.0   U         0 0          0 eth110.163.176.0    0.0.0.0         255.255.240.0   U         0 0          0 eth0169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth1192.168.0.0     10.163.191.247  255.255.0.0     UG        0 0          0 eth0172.16.0.0      10.163.191.247  255.240.0.0     UG        0 0          0 eth010.0.0.0        10.163.191.247  255.0.0.0       UG        0 0          0 eth00.0.0.0         115.28.83.247   0.0.0.0         UG        0 0          0 eth1[root@www postfix]# [root@www postfix]# [root@www postfix]# [root@www postfix]# [root@www postfix]# routeKernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Iface115.28.80.0     *               255.255.252.0   U     0      0        0 eth110.163.176.0    *               255.255.240.0   U     0      0        0 eth0link-local      *               255.255.0.0     U     1002   0        0 eth0link-local      *               255.255.0.0     U     1003   0        0 eth1192.168.0.0     10.163.191.247  255.255.0.0     UG    0      0        0 eth0172.16.0.0      10.163.191.247  255.240.0.0     UG    0      0        0 eth010.0.0.0        10.163.191.247  255.0.0.0       UG    0      0        0 eth0default         115.28.83.247   0.0.0.0         UG    0      0        0 eth1

然后再看看 :

[root@www postfix]# grep hosts /etc/nsswitch.conf#hosts:     db files nisplus nis dns#hosts:      files dnshosts:      dns files
我修改为 先 dns, 在 files, 测试了, 也还是不通。

最后发现是防火墙的原因, 我开启了防火墙, 造成了 ping 域名不通。

域名解析用到了53端口, 需要把下面的设置配置到防火墙里即可。

iptables -A INPUT -p udp --sport 53 -j ACCEPTiptables -A OUTPUT -p udp --dport 53 -j ACCEPTiptables -A INPUT -p udp --dport 53 -j ACCEPTiptables -A OUTPUT -p udp --sport 53 -j ACCEPT
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜