windows DNS 问题,nslookup 有效,ping 无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/330395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:48:01  来源:igfitidea点击:

DNS problem, nslookup works, ping doesn't

windowsdns

提问by user42088

I am setting up a development server in my flat. I have set up an Ubuntu DNS server on it and have added the zone weddinglist (just weddinglist - no TLD. It's just an internal domain.)

我正在我的公寓里设置一个开发服务器。我已经在其上设置了一个 Ubuntu DNS 服务器并添加了区域婚礼列表(只是婚礼列表 - 没有TLD。它只是一个内部域。)

This works fine on my Ubuntu laptop.

这在我的 Ubuntu 笔记本电脑上运行良好。

On all my Windows PCs (Vista and XP) I get the following from the command prompt:

在我所有的 Windows PC(Vista 和 XP)上,我从命令提示符中得到以下信息:

C:\Users\Giles Roadnight>nslookup weddinglist
Server:  UnKnown
Address:  192.168.0.40

Name:    weddinglist
Address:  192.168.0.41


C:\Users\Giles Roadnight>ping 192.168.0.41

Pinging 192.168.0.41 with 32 bytes of data:
Reply from 192.168.0.41: bytes=32 time<1ms TTL=64
Reply from 192.168.0.41: bytes=32 time<1ms TTL=64
Reply from 192.168.0.41: bytes=32 time<1ms TTL=64
Reply from 192.168.0.41: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.0.41:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\Users\Giles Roadnight>ping weddinglist
Ping request could not find host weddinglist. Please check the name and try again.

My ipconfig:

我的ipconfig:

C:\Users\Giles Roadnight>ipconfig -all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : Giles-Desktop
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Marvell Yukon 88E8001/8003/8010 PCI Gigabit Ethernet Controller
   Physical Address. . . . . . . . . : **-**-**-**-**-**
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::f179:680f:f313:5448%8(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.0.5(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.0.1
   DNS Servers . . . . . . . . . . . : 192.168.0.40
   NetBIOS over Tcpip. . . . . . . . : Enabled

I am pretty sure that I have the DNS set up OK as the nslookup is OK but I can't ping and I can't access webpages at weddinglist.

我很确定我的 DNS 设置正常,因为 nslookup 正常,但我无法 ping 并且无法访问婚礼列表中的网页。

How can I make ping work for the Windows PCs?

如何使 Windows PC 的 ping 工作?

回答by Alnitak

It's possible that the Windows internal resolver is adding '.local' to the domain name because there's no dots in it. nslookupwouldn't do that.

Windows 内部解析器可能将“.local”添加到域名中,因为其中没有点。 nslookup不会那样做。

To verify this possiblity, install 'Wireshark' (previously aka Ethereal) on your client machine and observe any DNS request packets leaving it when you run the pingcommand.

要验证这种可能性,请在您的客户端计算机上安装“Wireshark”(以前称为 Ethereal),并在运行ping命令时观察任何离开它的 DNS 请求数据包。



OK, further investigation on my own XP machine at home reveals that for single label names (i.e. "foo", or "foo.") the system doesn't use DNS at all, and instead uses NBNS (NetBios Name Service).

好的,在我自己的 XP 机器上的进一步调查显示,对于单个标签名称(即“foo”或“foo”),系统根本不使用 DNS,而是使用 NBNS(NetBios 名称服务)。

Using a hint found at http://www.chicagotech.net/netforums/viewtopic.php?t=1476, I found that I was able to force DNS lookups for single label domains by putting a single entry reading "." in the "Append these DNS suffixes (in order)" in the "Advanced TCP/IP settings" dialog

使用在http://www.chicagotech.net/netforums/viewtopic.php?t=1476 上找到的提示,我发现我能够通过将单个条目读取为“.”来强制对单标签域进行 DNS 查找。在“高级 TCP/IP 设置”对话框中的“附加这些 DNS 后缀(按顺序)”中

回答by Jamie Cook

I had this problem occasionally when using a multi-label name ie test.internal

我在使用多标签名称时偶尔会遇到这个问题,即 test.internal

The solution for me was to stop/start the dnscache on my windows 7 machine. Open a console as administrator and type

我的解决方案是在我的 Windows 7 机器上停止/启动 dnscache。以管理员身份打开控制台并输入

net stop dnscache
net start dnscache

then sigh and look for a way to get a Mac as your principal desktop.

然后叹息并寻找一种方法让 Mac 作为您的主要桌面。

回答by Nick

I have the same issue with IIS running on my home server, on the client machine a command like ipconfig /flushdnsusually solves the problem.

我在我的家庭服务器上运行 IIS 时遇到了同样的问题,在客户端机器上,一个命令ipconfig /flushdns通常可以解决这个问题。

回答by xx1xx

I had the same issue. As pointed out by other answers ping and nslookup use different mechanisms to lookup an ip.

我遇到过同样的问题。正如其他答案所指出的,ping 和 nslookup 使用不同的机制来查找 ip。

Chances are you are trying to ping a machine not on the same domain. When you ping the fully qualified name of the server this should then work.

您可能正在尝试 ping 不在同一域中的机器。当您 ping 服务器的完全限定名称时,这应该可以工作。

nslookup works:

nslookup 工作:

PS C:\Users\Administrator> nslookup nuget
Server:  ad-01.docs.com
Address:  192.168.10.20

Name:    nuget.docs.com
Address:  192.168.10.17

Ping fails:

Ping 失败:

PS C:\Users\Administrator> ping nuget
Ping request could not find host nuget. Please check the name and try again.

Ping works, using FQDN:

Ping 工作,使用 FQDN:

PS C:\Users\Administrator> ping nuget.docs.com

Pinging nuget.docs.com [192.168.70.17] with 32 bytes of data:
Reply from 192.168.10.17: bytes=32 time=1ms TTL=127
Reply from 192.168.10.17: bytes=32 time=2ms TTL=127
Reply from 192.168.10.17: bytes=32 time=2ms TTL=127
Reply from 192.168.10.17: bytes=32 time=2ms TTL=127

Ping statistics for 192.168.10.17:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 2ms, Average = 1ms


To fix this you will need to alter the DNS setting for the machine and add the DNS suffix to lookup.

要解决此问题,您需要更改机器的 DNS 设置并添加 DNS 后缀以进行查找。

  1. Control Panel\Network and Internet\Network Connections
  2. Network adapter -> properties
  3. IPV4 -> Properties
  4. General tab -> Advanced
  5. DNS Tab
  6. Select "Append these DNS suffixes (in order)"
  7. Add the required domain names
  8. Disable, then enable your network adapter (don't do this on a VM, you'll loose your connection, instead try 'ipconfig /renew')
  1. 控制面板\网络和 Internet\网络连接
  2. 网络适​​配器 -> 属性
  3. IPV4 -> 属性
  4. 常规选项卡 -> 高级
  5. DNS选项卡
  6. 选择“附加这些 DNS 后缀(按顺序)”
  7. 添加需要的域名
  8. 禁用,然后启用您的网络适配器(不要在 VM 上执行此操作,您会断开连接,而是尝试“ipconfig /renew”)

Advanced TCP/IP Settings

高级 TCP/IP 设置

回答by benc

I think this behavior can be turned off, but Window's online help wasn't extremely clear:

我认为可以关闭此行为,但 Window 的在线帮助不是很清楚:

If you disable NetBIOS over TCP/IP, you cannot use broadcast-based NetBIOS name resolution to resolve computer names to IP addresses for computers on the same network segment. If your computers are on the same network segment, and NetBIOS over TCP/IP is disabled, you must install a DNS server and either have the computers register with DNS (or manually configure DNS records) or configure entries in the local Hosts file for each computer.

如果禁用 TCP/IP 上的 NetBIOS,则无法使用基于广播的 NetBIOS 名称解析将计算机名称解析为同一网段上的计算机的 IP 地址。如果您的计算机在同一网段,并且 TCP/IP 上的 NetBIOS 被禁用,则您必须安装 DNS 服务器并让计算机注册 DNS(或手动配置 DNS 记录)或在本地 Hosts 文件中为每个服务器配置条目。计算机。

In Windows XP, there is a checkbox:

在 Windows XP 中,有一个复选框:

Advanced TCP/IP Settings

高级 TCP/IP 设置

[ ] Enable LMHOSTS lookup

[ ] 启用 LMHOSTS 查找

There is also a book that covers this at length, "Networking Personal Computers with TCP/IP: Building TCP/IP Networks (old O'Reilly book)". Unfortunately, I cannot look it up because I disposed of my copy a while ago.

还有一本书详细介绍了这一点,“使用 TCP/IP 连接个人计算机:构建 TCP/IP 网络(O'Reilly 老书)”。不幸的是,我无法查找它,因为我不久前丢弃了我的副本。

回答by Stephen Darlington

Do you have an entry for weddinglistin your hosts file? You can find this in:

您的主机文件中有婚礼清单条目吗?您可以在以下位置找到:

C:\WINDOWS\system32\drivers\etc

nslookupalways uses DNS whereas ping uses other methods for finding hostnames as well.

nslookup总是使用 DNS 而 ping 也使用其他方法来查找主机名。

回答by juan

I found a little bug in windows Server 2003 R2 EE. you know that when you specify your IP address in the NIC (network connections), windows tells you that if you dont specify the preferred DNS server, it will put his own ip because it is an DNS server? well it doesn't do that...

我在 windows Server 2003 R2 EE 中发现了一个小错误。你知道当你在网卡(网络连接)中指定你的IP地址时,windows会告诉你,如果你不指定首选DNS服务器,它会放他自己的IP,因为它是一个DNS服务器?好吧,它不会那样做...

I fixed my problem writing the dns adress manually, instead of letting windows do it for me.

我解决了手动编写 dns 地址的问题,而不是让 windows 为我做。

回答by Ngobo

Try ipconfig /displaydns and look for weddinglist. If it's cached as "name does not exist" (possibly because of a previous intermittent failed lookup), you can flush the cache with ipconfig /flushdns.

尝试 ipconfig /displaydns 并查找婚礼列表。如果它被缓存为“名称不存在”(可能是因为之前的间歇性查找失败),您可以使用 ipconfig /flushdns 刷新缓存。

nslookup doesn't use the cache, but rather queries the DNS server directly.

nslookup 不使用缓存,而是直接查询 DNS 服务器。

It worked for me..

它对我有用..

from https://superuser.com/a/507892

来自https://superuser.com/a/507892

回答by bfhd

I also had this problem on a Server 2012 R2 VM joined to my local AD domain. I eventually solved the problem by taking the VM off the domain and re-joining it.

我在加入本地 AD 域的 Server 2012 R2 VM 上也遇到了这个问题。我最终通过将虚拟机从域中移除并重新加入来解决了这个问题。

回答by james smith

I also encountered this issue. No Windows application (except Chrome) could access the internet. I found it was a duplicate IP on the LAN. I changed the local IP, and everything, including ping, started working again.

我也遇到了这个问题。没有 Windows 应用程序(Chrome 除外)可以访问互联网。我发现它是 LAN 上的重复 IP。我更改了本地 IP,包括 ping 在内的一切都重新开始工作。

I found the problem doing an

我发现问题在做

IPCONFIG /ALL

and it listed

它列出了

IPv4 Address. . . . . . . . . . . : 10.10.0.20(Duplicate)

IPv4 地址。. . . . . . . . . . :10.10.0.20(重复)