Share this question

Welcome to Teachnovice Q&A, where you can ask questions and receive answers from other members of the community.

This is a collaboratively edited question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Why is 'ping' unable to resolve a name when 'nslookup' works fine?

0 like 0 dislike
505 views

On my Windows XP workstation, I can find the machine I want to connect to in DNS with nslookup:

nslookup wolfman
Server: dns.company.com
Address: 192.168.1.38

Name: wolfman.company.com
Address: 192.168.1.178

But, when I try to connect to that machine, I get an error telling me that the machine can't be found (i.e., can't be looked up in DNS):

C:\> ping wolfman
Ping request could not find host wolfman. Please check the name and try again.

I am able to connect if I use the IP address directly:

C:\> ping 192.168.1.178

Pinging 192.168.1.178 with 32 bytes of data:

Reply from 192.168.1.178: bytes=32 time=41ms TTL=126
Reply from 192.168.1.178: bytes=32 time=41ms TTL=126
Reply from 192.168.1.178: bytes=32 time=44ms TTL=126
Reply from 192.168.1.178: bytes=32 time=38ms TTL=126

I could work around this by adding an entry to my hosts file, but I would rather find out why this is happening. The problem is transient, most of the day I can connect to the machine just fine.

How is this possible?

ETA: I left this out for brevity, but it was asked for:

C:\> ping wolfman.company.com
Ping request could not find host wolfman.company.com. Please check the name and try again.

ETA: Other applications get the same results. I only tried ping to simplify. telnet can't connect, Cygwin apps print a "unknown host wolfman" message.

Update: Using wireshark, I found that my workstation is not attempting a DNS lookup. It's just reporting the "could not find host" error message.

asked Nov 10, 2016 by skiphoppy  

11 Answers

0 like 0 dislike
I believe that nslookup opens a winsock connection on the DNS port and issues a query, whereas ping uses the DNS Client service. You could try and stop this service and see whether this makes a difference.

Some commands that will reinitialize various network states :

Reset WINSOCK entries to installation defaults : netsh winsock reset catalog
Reset TCP/IP stack to installation defaults : netsh int ip reset reset.log
Flush DNS resolver cache : ipconfig /flushdns
Renew DNS client registration and refresh DHCP leases : ipconfig /registerdns
Flush routing table : route /f (reboot required)
answered Nov 10, 2016 by harrymc  
0 like 0 dislike
Try ipconfig /displaydns and look for wolfman. 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.

nslookup doesn't use the cache, but rather queries the DNS server directly.
answered Nov 10, 2016 by craig65535  
0 like 0 dislike

nslookup works different to other commands when resolving names/ip addresses on Windows.

The normal resolution method on Windows is as follows:

  1. The client checks to see if the name queried is its own.
  2. The client then searches a local Hosts file, a list of IP address and names stored on the local computer.
  3. Domain Name System (DNS) servers are queried.
  4. If the name is still not resolved, NetBIOS name resolution sequence is used as a backup. This order can be changed by configuring the NetBIOS node type of the client.

nslookup on the other hand is used for testing Domain Name Servers.

answered Nov 10, 2016 by Bryan  
0 like 0 dislike
Try ping with hostname followed by a dot. So instead of ping wolfman use ping wolfman.

That should get you resolving without having to do workarounds with hosts file, etc.
answered Nov 10, 2016 by Senthil  
0 like 0 dislike
Maybe wolfman.company.com is listed in C:\Windows\system32\drivers\etc\hosts ?

nslookup bypasses that file and always asks DNS, while ping and other tools first of all look up in "hosts" file, then in DNS.
answered Nov 10, 2016 by Mikhail Kupchik  
0 like 0 dislike

I've struggled with a similar issue and have tried the solution suggested by @harrymc. I found what eventually seems to (at least somewhat) work at the microsoft technet forum (nslookup works but nothing else has DNS on standalone Win7 PC)

Here's the quote:

... try to use the command below to flush and reset a client resolver cache for test.

ipconfig /flushdns

ipconfig /registerdns

Please refer to the link below for more details. http://jefferyland.wordpress.com/2011/07/28/quick-review-of-flushdns-registerdns-and-dns-queries/

So basically what was missing for me was ipconfig /registerdns

answered Nov 10, 2016 by Mick Halsband  
0 like 0 dislike

Just today we had the same issue, but the solution was different. So I thought, I'd add it for reference as this was the top most search result.

  • Problem: ping will not resolve a host name, but nslookup can. (Observed on 2 different Windows Server 2012 R2 hosts.)
  • Cause: (For each host) The host has more than one NIC connected and there are multiple default gateways configured.
  • Solution: (For each host) Remove default gateway from configuration of all NICs but one, so there reamains only one default gateway.
answered Nov 10, 2016 by djlauk  
0 like 0 dislike

I had the same problem on a Windows 2012R2 (=8.1) system, and tried all the above suggestions, but none of them would fix it:
- Pinging the fully qualified name worked.
- Pinging the unqualified name did not.
- Both worked on several other systems, that had the same OS and apparently the same configuration.
- All the necessary suffix search strings were there.
(Note that some of the proposed fixes, like the workaround for the multi-label queries, are obviously irrelevant, as the unqualified name has only one part.)

Then I noticed that the target system I was trying to ping did NOT have an IPv6 address. So I tried "ping -4 unqualified_name", and bingo! this worked.
So for some reason, on this system only, ping only tried to resolve unqualified name->IPv6 address, and not unqualified name->IPv4.
For me the fix was to disable IPv6 completely as I don't need it at all. But I'd be really interested to find a more gentle way to tell ping (or presumably the DNS client service) to try resolving both IPv4 and IPv6 addresses.

answered Nov 10, 2016 by Jean-François Larvoire  
0 like 0 dislike
Adding an entry in the file c:/windows/system32/drivers/etc/hosts might fix it.
answered Nov 10, 2016 by Manoj Agarwal  
0 like 0 dislike

i have encountered this when we migrated to windows 7 from windows XP, the issue was related to a Windows 7 Multi Label DNS Query issue.

Allow DNS Suffix Appending to Unqualified Multi-Label Name Queries - see:

http://computerstepbystep.com/allow_dns_suffix_appending_to_unqualified_multi_label_name_queries.html

Hope this helps

answered Nov 10, 2016 by Sony NS  
...