0

I was struggling with this for a long time. I've few devices on my network and for some reason my windows on my main pc doesnt recognize them

Console screenshot

It doesn't make much sense to me - wouldn't WSL Ubuntu derive settings from windows? I've set default dns everywhere on windows.

Settings screenshot

Do you have any idea what the problem might be?

I've also checked to make sure that network has router IP listed as DNS Settings screenshot - 2

nslookup output on windows

Default Server:  UnKnown
Address:  192.168.100.1

resolv.conf on wsl

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.31.96.1

What's even weirder about it is the fact that nslookup resolves IP addresses correctly.

>nslookup main
Server:  UnKnown
Address:  192.168.100.1

Name:    main
Address:  192.168.100.89

EDIT. I've found the answer to this question in other thread: Why is 'ping' unable to resolve a name when 'nslookup' works fine? Thanks @DanielB for pointing me pointing me to the answer with nslookup command.

nxyt
  • 1
  • 3
  • I think there is some misconception here. Name resolution on local networks often does _not_ work using DNS (if we consider mDNS separate). Windows, Linux and macOS have different capabilities when it comes to this. Name resolution queries multiple sources, of which classic DNS is only one. You could use a packet sniffer to check what’s actually happening. – Daniel B Mar 21 '22 at 19:05
  • Normally your router does NOT contain a DNS, it would possibly be so only if you run special software in the router - e.g. https://www.google.com/search?q=DD-WRT+openwrt+%2BDNS – Hannu Mar 21 '22 at 19:14
  • @Hannu so if my router has 'DNS settings' that let me pick 'name' and ip it points to, thats not dns? It's even more confusing to me then, because those settings actually work like i think they are supposed to in ubuntuWSL and linux terminal on other device 'ping name' translates 'name' to ip address – nxyt Mar 21 '22 at 19:20
  • A DNS setting is what your DHCP-server provides, that data points out a DNS -server, which most likely is one your ISP uses (= has running). The router setting(s) is supposed to point directly at such a server, you may enter an IP manually; e.g. 4.4.4.4, or google's DNS 8.8.8.8 – Hannu Mar 21 '22 at 19:26
  • Okay, that's the screenshot of the settings page im talking about - https://imgur.com/a/ckHFoYa If my understanding is correct - external DNS IP is somewhere else, and this page purpose is to let me map some addresses to IP, isn't that right? It even works that way on linux and im not sure why, cause if it's router that does the translation, then system should not matter. – nxyt Mar 21 '22 at 19:33
  • What happens if you use `nslookup` on Windows? Does it use the router's DNS server? Does it resolve the name? Also, I'd like to recommend Wireshark once again. You will be able to inspect the actual DNS traffic. – Daniel B Mar 21 '22 at 23:11
  • Furthermore, please provide the `/etc/resolv.conf` that WSL generated. Please add all information to your question, not in comments. In the question, you can use proper formatting. – Daniel B Mar 21 '22 at 23:21
  • @DanielB I've added output of both to the question. I'm suprised windows actually uses router IP. – nxyt Mar 22 '22 at 10:32
  • You’ll also want to query `mainpc` in `nslookup`. Nothing surprising about the output so far. It’s using your router as the DNS server, as expected. // Your WSL config looks strange. It looks like you’re using the Docker Desktop DNS server? Did you somehow mix the Docker and regular WSL distributions? – Daniel B Mar 22 '22 at 10:42
  • @DanielB wait it makes no sense, nslookup 'name' points to correct address @_@ I followed regular instructions to install WSL, but i dont think WSL has anything to do with it. I've checked it on other devices and all linux devices can use dns aliases, and all windows devices cant. I'm more and more confused as 'nslookup main' and 'nslookup mainpc' resolve IP correctly - it outputs `Server: UnKnown Address: 192.168.100.1 Name: main Address: 192.168.100.89` – nxyt Mar 22 '22 at 10:48

1 Answers1

0

I've found answer to this question on other thread. Thanks @DanielB for guiding me with 'nslookup' command, from that point it was easy to find related questions. Turns out that windows sometimes doesn't use dns for some reason, to force it to use it you can add '.' at the end of the name.

So: ping main doesn't work, but ping main. does. It's the same for other commands, to ssh into the device with name i used in router dns i'd have to use something like ssh username@dnsname.

If you have web services and want to access them in the browser you can do it by adding dot in the name too, for example: main.:port

nxyt
  • 1
  • 3