Linux能ping通IP,ping不通域名

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

[[email protected] postfix]# cat /etc/resolv.conf
nameserver 202.96.209.133
options attempts:1 timeout:1 rotate
#nameserver 10.202.72.117
nameserver 10.202.72.118
nameserver 114.114.114.114
nameserver 8.8.8.8
[[email protected] postfix]# 

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

[[email protected] postfix]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
115.28.80.0     0.0.0.0         255.255.252.0   U         0 0          0 eth1
10.163.176.0    0.0.0.0         255.255.240.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth1
192.168.0.0     10.163.191.247  255.255.0.0     UG        0 0          0 eth0
172.16.0.0      10.163.191.247  255.240.0.0     UG        0 0          0 eth0
10.0.0.0        10.163.191.247  255.0.0.0       UG        0 0          0 eth0
0.0.0.0         115.28.83.247   0.0.0.0         UG        0 0          0 eth1
[[email protected] postfix]#
[[email protected] postfix]#
[[email protected] postfix]#
[[email protected] postfix]#
[[email protected] postfix]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
115.28.80.0     *               255.255.252.0   U     0      0        0 eth1
10.163.176.0    *               255.255.240.0   U     0      0        0 eth0
link-local      *               255.255.0.0     U     1002   0        0 eth0
link-local      *               255.255.0.0     U     1003   0        0 eth1
192.168.0.0     10.163.191.247  255.255.0.0     UG    0      0        0 eth0
172.16.0.0      10.163.191.247  255.240.0.0     UG    0      0        0 eth0
10.0.0.0        10.163.191.247  255.0.0.0       UG    0      0        0 eth0
default         115.28.83.247   0.0.0.0         UG    0      0        0 eth1

然后再看看 :

[[email protected] postfix]# grep hosts /etc/nsswitch.conf
#hosts:     db files nisplus nis dns
#hosts:      files dns
hosts:      dns files

我改动为 先 dns,  在  files, 測试了, 也还是不通。

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

域名解析用到了53端口。 须要把以下的设置配置到防火墙里就可以。

iptables -A INPUT -p udp --sport 53 -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p udp --sport 53 -j ACCEPT

这样就能够 ping 通域名了。

时间: 2024-08-07 08:25:45

Linux能ping通IP,ping不通域名的相关文章

【linux】linux下能ping通ip 但是不能ping通域名

经过一翻查找后解决了,原因和方法如下: [[email protected]~]# grep host /etc/nsswitch.conf#hosts: db files nisplus nis dnshosts:            files主机只找文件不走dns,将其该成hosts:      files   dns   即可! [linux]linux下能ping通ip 但是不能ping通域名

red hat7 系统可以ping通ip地址但是不能ping通域名

在red hat7中ifconfig后出现这样的情况,ens33是物理网卡,与eth0一样只是不同的名字.但是只能ping通ip地址不能ping通域名. 解决方法: 在文件 /etc/resolv.conf文件下更改nameserver的值 加上 nameserver 8.8.8.8  域名解析服务  nameserver 8.8.4.4为备用的 在文件 etc/sysconfig/network-scripts下修改 ifcfg-eth0 或者 ifcfg-ens33文件,设置静态ip地址,

公司网络能ping通ip,不能ping域名

第一天去公司,就因为网络问题弄了大半天.只能ping通ip,不能ping域名.网上查了各种方式都不行,刷新dns缓存.说是什么域名解析问题.dns的问题.公司里好几个人都看了看不能解决.领导让重装系统,等了十几分钟,装完了,还是不行.最后的解决办法是:换了个ip就行了.比如本来这个位置上的ip是192.168.161.126该为192.168.161.127竟然成功了.但是还是不知道为什么,求大牛指点. 2017-03-21  23:12:57

可以PING通IP,PING名字不通,可以远程,但不能访问共享文件夹?

问题现象:可以PING通IP,PING名字不通,可以远程,但不能访问共享文件夹? 问题原因:目标主机中NetLogon服务未启动. 问题处理:远程打开目标主机,“我的电脑-管理-服务-启动(改为自动)”  . 问题跟踪: ①错误表现 CMD-"net use \\192.168.1.2" 发生系统错误1792. 试图登录,但是网络登录服务没有启动. ②正确表现 CMD-"net use \\192.168.1.2" 命令成功完成.

能ping通ip地址但无法上网

今天遇到很奇怪的一件事情,能ping通ip地址,但是无法ping通机器名,更不能上网.打电话给公司IT也没搞定,建议重装系统,崩溃…… 后来自己在网上搜到这篇文章,很简单的把问题解决了,分享一下: http://blog.sina.com.cn/s/blog_6356dc570101aom2.html 我用的是第三种办法,运行命令“netsh winsock reset catalog”,然后重启电脑,搞定.

ping通IP,telnet 3306不通

一个同事装的MySQL数据库,无法连接.??1.查看权限??2.查看防火墙??检查用户权限,防火墙都没问题,就是无法连接,能ping通,但是telnet 3306 端口无法成功.??检查了下数据库配置文件,结果配置了bind-address ?bind-address = 127.0.0.1???禁掉bind-address = 127.0.0.1??重启数据库,telnet成功!?

Linux:服务器ping不通域名(能ping通ip地址)

在确定网络没问题的情况下, 可以通过以下三个步骤寻找解决办法: 1) 确定设置了域名服务器, 没有的话, 可设置Google的公共DNS服务: # cat /etc/resolv.conf ------------------------------------------------------------------- nameserver 8.8.8.8 nameserver 8.8.4.4 -------------------------------------------------

Ubantu ping通IP,ping不通baidu

ping www.baidu.com 可能是本地DNS服务器没配置. 修改域名服务器配置文件 vi /etc/resolv.conf 原文地址:https://www.cnblogs.com/glodears/p/9020445.html

【BAT批处理】根据计算机名批量自动ping,并给出ping结果(ping通还是ping不通)

@echo off (for /f "tokens=1*" %%a in (ipTable.txt) do ( ping %%a >nul && echo %%a OK||echo %%a Failed ))>result.txt 会读取ipTable.txt中的内容,ipTable示例: testComputerName1 testComputerName2 testComputerName3 ..... 此外,如果ipTable.txt中有多列,列与列中