为啥我的电脑可以解析某个域名到正确的 IP,却 ping 不通 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
aboutby
V2EX    DNS

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

  •  
  •   aboutboy 2018-03-20 15:16:54 +08:00 8850 次点击
    这是一个创建于 2838 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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 连接到路由器。

    第 1 条附言    2018-03-20 17:30:58 +08:00

    pingerror

    第 2 条附言    2018-03-20 17:33:31 +08:00
    注:192.168.8.1 是我用的路由器,其名称是 butongwifi。
    第 3 条附言    2018-03-20 17:40:05 +08:00

    pingerror pingerror

    如图,我在路由器上设置*.wifi都解析到192.168.8.1,*.butongwifi也是,但*.wifi就是正常的,但*.butongwifi就有问题。

    第 4 条附言    2018-03-20 17:59:08 +08:00

    我重新设置了。现在呢,直接ping wifi或者ping butongwifi不行,但ping wifi.和ping butongwifi.就可以。 电脑上浏览器http://butongwifi.也可以,但http://butongwifi仍然不行

    pingerror pingerror pingerror pingerror pingerror pingerror

    第 5 条附言    2018-03-20 18:02:09 +08:00
    为啥带.就可以,不带就不行?我感觉这是 windows 的某种机制导致的。
    第 6 条附言    2018-03-20 21:14:00 +08:00

    mahua 谢谢大家热心帮助。现在已经搞定了。如上图,以前所在域这里我没有设置,现在设置为lan,就好了。 设置以后,dns解析正常,ping也正常,通过浏览器访问http://butongwifi也正常了。

    22 条回复    2018-03-20 21:21:25 +08:00
    ArianX
        1
    ArianX  
       2018-03-20 15:35:54 +08:00 via Android   2
    Ping 依赖于 ICMP 协议,禁用 ICMP 协议,就能禁止 ping
    mchong
        2
    mchong  
       2018-03-20 16:38:20 +08:00
    要不先 ipconfig /flushdns 看看
    aboutboy
        3
    abotboy  
    OP
       2018-03-20 17:15:58 +08:00
    @ArianX 可是我直接 ping ip 是有响应的
    aboutboy
        4
    aboutboy  
    OP
       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
        5
    aboutboy  
    OP
       2018-03-20 17:22:19 +08:00
    WordTian
        6
    WordTian  
       2018-03-20 17:23:13 +08:00 via Android
    对方服务器禁 ping 了呗
    pkookp8
        7
    pkookp8  
       2018-03-20 17:24:56 +08:00 via Android
    你把电脑 windows 自带防火墙打开,试试别的设备能不能 ping 通,人家也一样
    ycz0926
        8
    ycz0926  
       2018-03-20 17:29:28 +08:00 via iPhone
    iptables 了解下
    NightRemix
        9
    NightRemix  
       2018-03-20 17:33:26 +08:00
    我的服务器就禁 ping 关闭 22 端口了
    aboutboy
        10
    aboutboy  
    OP
       2018-03-20 17:5:05 +08:00
    @WordTian
    @NightRemix 没有禁 ping,ping ip 是可以的,但 ping butongwifi 不行。
    jasonyang9
        11
    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
        12
    WordTian  
       2018-03-20 17:42:45 +08:00 via Android
    @aboutboy 你电脑的 DNS 设的是哪个?路由器的?还是你自己找的别的?
    WordTian
        13
    WordTian  
       2018-03-20 17:48:04 +08:00 via Android
    @WordTian 噢,是路由器的啊,按理来说没至于啊
    zhigang1992
        14
    zhigang1992  
       2018-03-20 17:55:38 +08:00 via iPhone
    你把它加到 /etc/hosts 里面试试呢?
    aboutboy
        15
    aboutboy  
    OP
       2018-03-20 18:00:38 +08:00
    @WordTian DNS 是自动获取的,也就是 192.168.8.1,可以看我 nslookup 的截屏
    @jasonyang9 感觉你这个有点道理,我仔细看看你发的链接
    0x8C
        16
    0x8C  
       2018-03-20 18:04:35 +08:00
    ping 和浏览器
    处理域名的方式不一样
    “ butongwifi ”
    明显不是个域名,本地 hosts 里也没有
    ping 直接返回找不到无可厚非
    jasontse
        17
    jasontse  
       2018-03-20 18:07:06 +08:00 via iPad
    你需要 netsh winsock reset
    aboutboy
        18
    aboutboy  
    OP
       2018-03-20 18:15:54 +08:00
    @jasontse 我按你的方法,应该是修复 winsock 吧。还是不行。
    love4taylor
        19
    love4taylor  
    PRO
       2018-03-20 18:33:56 +08:00
    设置下路由的 Domain Name 试试
    WuwuGin
        20
    WuwuGin  
       2018-03-20 19:31:34 +08:00 via Android
    When apingcommand 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.

    了解一下。
    7654
        21
    7654  
       2018-03-20 19:36:08 +08:00
    这个需要在 DNS 端建立 butongwifi 解析到 192.168.8.1
    ping 才能正确响应
    aboutboy
        22
    aboutboy  
    OP
       2018-03-20 21:21:25 +08:00
    各位热心 V 友,我已经发现问题并解决了,请看 APPEND 最下一条。
    @0x8C @7654 @ArianX @Love4Taylor @NightRemix @WordTian @WuwuGin @jasontse @jasonyang9
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2527 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 32ms UTC 01:27 PVG 09:27 LAX 17:27 JFK 20:27
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86