为啥我的电脑可以解析某个域名到正确的 IP,却 ping 不通

2018-03-20 15:16:54 +08:00
 aboutboy

C:\Users\LCE>nslookup 默认服务器: BUTONGWIFI Address: 192.168.8.1

butongwifi 服务器: BUTONGWIFI Address: 192.168.8.1

名称: butongwifi Address: 192.168.8.1

quit

C:\Users\LCE>ping butongwifi Ping 请求找不到主机 butongwifi。请检查该名称,然后重试。

C:\Users\LCE>ping 192.168.8.1

正在 Ping 192.168.8.1 具有 32 字节的数据: 来自 192.168.8.1 的回复: 字节=32 时间<1ms TTL=64 来自 192.168.8.1 的回复: 字节=32 时间<1ms TTL=64 来自 192.168.8.1 的回复: 字节=32 时间=1ms TTL=64 来自 192.168.8.1 的回复: 字节=32 时间=1ms TTL=64

192.168.8.1 的 Ping 统计信息: 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失), 往返行程的估计时间(以毫秒为单位): 最短 = 0ms,最长 = 1ms,平均 = 0ms

C:\Users\LCE>

PS: 1.由于上传截屏太麻烦,我就直接粘贴字符吧。 2.192.168.8.1 是我的路由器,其 hostname 是 butongwifi。 3.电脑是通过有线连接到路由器的,DNS 是 192.168.8.1。 4.手机访问 http://butongwifi 是正常的,通过 WIFI 连接到路由器。

8337 次点击
所在节点    DNS
22 条回复
ArianX
2018-03-20 15:35:54 +08:00
Ping 依赖于 ICMP 协议,禁用 ICMP 协议,就能禁止 ping
mchong
2018-03-20 16:38:20 +08:00
要不先 ipconfig /flushdns 看看
aboutboy
2018-03-20 17:15:58 +08:00
@ArianX 可是我直接 ping ip 是有响应的
aboutboy
2018-03-20 17:17:34 +08:00
@mchong 感觉 dns 解析没问题,只是 ping butongwifi 时有问题
————————————————————————————————————
C:\Users\LCE>ipconfig /flushdns

Windows IP 配置

已成功刷新 DNS 解析缓存。

C:\Users\LCE>nslookup
默认服务器: BUTONGWIFI
Address: 192.168.8.1

> butongwifi
服务器: BUTONGWIFI
Address: 192.168.8.1

名称: butongwifi
Address: 192.168.8.1

> exit

C:\Users\LCE>ping butongwifi
Ping 请求找不到主机 butongwifi。请检查该名称,然后重试。

C:\Users\LCE>
aboutboy
2018-03-20 17:22:19 +08:00
WordTian
2018-03-20 17:23:13 +08:00
对方服务器禁 ping 了呗
pkookp8
2018-03-20 17:24:56 +08:00
你把电脑 windows 自带防火墙打开,试试别的设备能不能 ping 通,人家也一样
ycz0926
2018-03-20 17:29:28 +08:00
iptables 了解下
NightRemix
2018-03-20 17:33:26 +08:00
我的服务器就禁 ping 关闭 22 端口了
aboutboy
2018-03-20 17:35:05 +08:00
@WordTian
@NightRemix 没有禁 ping,ping ip 是可以的,但 ping butongwifi 不行。
jasonyang9
2018-03-20 17:41:10 +08:00
因为主机名字叫 BU (不) TONG (通)。。。(逃

真正的原因可能是 nslookup 利用的是 DNS 服务,而 ping 会在没有后缀的名字解析时尝试用 NetBIOS。。。

https://superuser.com/questions/134057/can-ping-ip-address-and-nslookup-hostname-but-cannot-ping-hostname-temporarily-i
WordTian
2018-03-20 17:42:45 +08:00
@aboutboy 你电脑的 DNS 设的是哪个?路由器的?还是你自己找的别的?
WordTian
2018-03-20 17:48:04 +08:00
@WordTian 噢,是路由器的啊,按理来说没至于啊
zhigang1992
2018-03-20 17:55:38 +08:00
你把它加到 /etc/hosts 里面试试呢?
aboutboy
2018-03-20 18:00:38 +08:00
@WordTian DNS 是自动获取的,也就是 192.168.8.1,可以看我 nslookup 的截屏
@jasonyang9 感觉你这个有点道理,我仔细看看你发的链接
0x8C
2018-03-20 18:04:35 +08:00
ping 和浏览器
处理域名的方式不一样
“ butongwifi ”
明显不是个域名,本地 hosts 里也没有
ping 直接返回找不到无可厚非
jasontse
2018-03-20 18:07:06 +08:00
你需要 netsh winsock reset
aboutboy
2018-03-20 18:15:54 +08:00
@jasontse 我按你的方法,应该是修复 winsock 吧。还是不行。
Love4Taylor
2018-03-20 18:33:56 +08:00
设置下路由的 Domain Name 试试
WuwuGin
2018-03-20 19:31:34 +08:00
When a ping command is issued, the utility sends an ICMP Echo Request to a destination IP address. Try pinging the IP address of the target host to see if it responds. If that succeeds, try pinging the target host using a host name. Ping first attempts to resolve the name to an address through a DNS server, then a WINS server (if one is configured), then attempts a local broadcast. When using DNS for name resolution, if the name entered is not a fully qualified domain name, the DNS name resolver appends the computer's domain name or names to generate a fully qualified domain name.

If pinging by address succeeds but pinging by name fails, the problem usually lies in name resolution, not network connectivity. Note that name resolution might fail if you do not use a fully qualified domain name for a remote name. These requests fail because the DNS name resolver is appending the local domain suffixes to a name that resides elsewhere in the domain hierarchy.

了解一下。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/439735

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX