5

Background

I have a device plugged into my Windows PC via Ethernet. The device is running an mDNS service and has its own hostname (gp800-49d1a).

From WSL, I can ping gp800-49d1a with success, and I can nslookup gp800-49d1a with the following result:

Server:         172.30.176.1
Address:        172.30.176.1#53

Non-authoritative answer:
Name:   gp800-49d1a.local
Address: 169.254.93.130
Name:   gp800-49d1a.local
Address: fe80::e700:63f:1807:adf2

I can get the IP address 169.254.93.130. Connecting on this address works. Everything is correct up to this point.

Problem

When I run nslookup gp800-49d1a from Windows Command Prompt, I get the following result:

Server:  dns.google
Address:  8.8.8.8

*** dns.google can't find gp800-49d1a: Non-existent domain

When I run ping gp800-49d1a from Windows Command Prompt, it works fine.

So for some reason nslookup from WSL is OK, but nslookup from Windows is not.

Additional Info

I can access my device from Google Chrome just fine using the hostname. It seems both Chrome and WSL know how to find the mDNS entry, but nslookup from Windows Command Prompt does not.

Question

Since nslookup doesn't find my device from Windows Command Prompt, what else can I use to get the IP address of my device from Windows?

1
  • 1
    Your question is tagged with mDNS. nslookup only does DNS.
    – Daniel B
    Apr 1 at 19:33

2 Answers 2

14

nslookup is exclusively a DNS client, not an mDNS client nor a generic hostname lookup tool. It completely ignores the whole "hostname lookup" system that the OS has, instead manually sending DNS packets to one server (the first server it finds in the OS-provided list).

The only reason it works in WSL is because you're talking to the DNS service ('Dnscache') running on the Windows host, which then proxies queries to all mechanisms it supports (including mDNS which is handled by 'Dnscache' on Windows).

Even in this case, however, the Linux nslookup still bypasses normal Linux hostname lookup, instead doing DNS manually, and it still thinks it is only talking unicast DNS to one specific server that it finds in /etc/resolv.conf – it only happens that that server performs this translation without nslookup's knowledge.

When you run it directly on Windows, however, that doesn't happen – nslookup talks to the DNS server at 8.8.8.8, and that server has no clue about your .local mDNS hostnames.

5
  • Thank you for the helpful information. In this case, it helped me rephrase the question. I have edited the question accordingly. What I really care about in this situation is looking up the IP address of my device from a Windows machine that does not have WSL.
    – nullromo
    Apr 1 at 20:42
  • If you can edit this answer to solve the problem without using PowerShell, I will accept this as the answer. Otherwise, I'll go with my PowerShell answer.
    – nullromo
    Apr 1 at 20:50
  • I am not a Windows user any more. But I think you can add your device name and IP address to the Windows hosts file and nslookup will find it there. Google 'where is the Windows hosts file' for instructions.
    – Wastrel
    Apr 2 at 14:02
  • @Wastrel thanks for the idea, but I need a machine-agnostic method that works without admin access. And I won't know the IP address, hence the need for nslookup.
    – nullromo
    Apr 2 at 16:28
  • If dnscache is running on the Windows host, can't one just add 127.0.0.1 to the nslookup command line to tell it to query that server? -- Doesn't seem to be a running on a default Windows install though.
    – jcaron
    Apr 2 at 17:27
13

As mentioned in u1686_grawity's answer, nslookup from Windows Command Prompt does not work with mDNS.

To get the IP address of a device you can use the PowerShell command Resolve-DnsName <hostname>.

> Resolve-DnsName gp800-49d1a

Name                   Type   TTL   Section    IPAddress
----                   ----   ---   -------    ---------
gp800-49d1a.local      AAAA   120   Answer     fe80::e700:63f:1807:adf2
gp800-49d1a.local      A      120   Answer     169.254.93.130

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .