-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WSL 2 does not resolve local hostnames as it does in Windows (DNS issue) #5224
Comments
Fundamentally variation #4825. Muticast messages don't make it from your pi to inside WSL. |
If you still not able to get is work, follow below steps. Automated steps: https://gist.github.com/matthiassb/9c8162d2564777a70e3ae3cbee7d2e95 First run on powershell: Then run bash on windows with either ubuntu or bash commands (depending on your installation). Edit the /etc/resolv.conf and replace all nameserver {ip} with the ones generated by the top one. You should have internet and intranet back now. Remove the first line to make it permanent but be aware if you change networks it will not update anymore. (back it up first maybe?) |
Still waiting for a solution to what feels like a basic problem here... host name resolution should not be this complex. I should be able to access whatever I can access in windows. Do the WSL developers fundamentally disagree? Or is this just a low priority? We are all waiting for a response... |
I'm facing the same issue, except the other way around!
I thought it had to do with the name server being chosen, so I took from one of the replies above to figure out the NS used by PS
I think, surely that nameserver doesn't know my desired host name?
But it timesout in PS (note that any non-resolvable domain times out, I haven't seen something like NXDOMAIN)
All this was to say: there's a difference in how WSL and cmd/ps does DNS queries. |
I had the same problem, but like has been shown above the query actually resolves to a PS> ping raspberrypi_hostname
Pinging raspberrypi_hostname.local [<>] with 32 bytes of data:
... and pinging the So then I can ssh into the pi by using $ ssh user@raspberrypi_hostname.local but to make it the same as on Windows I created the following config file in
which makes it possible to run $ ssh user@raspberrypi_hostname in WSL 2. While this doesn't solve the underlying DNS issue it solves the particular problem of ssh-ing to a machine on your local network. So I'll leave this here if others, like me, are searching for a solution to this. |
This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request. Thank you! |
Issue is still relevant |
There's some intermittency on either side here. I've had the same host work sometimes in both, sometimes only in command, and sometimes only in WSL ubuntu. I am on Windows 11:
|
I've since found #11022, which seems to track that this happened after a window 11 update, with a potential fix too. |
Please fill out the below information:
Your Windows build number: Microsoft Windows [Version 10.0.18363.836]
What you're doing and what's happening: Trying to SSH to any device on my local network by way of DNS hostname resolution, and finding that WSL does not resolve hostnames properly for local devices.
cmd.exe
andpowershell.exe
can. I am able to run the above command in the command prompt (Windows compiled version of SSH) and have no issues. I also can invokecmd.exe
/powershell.exe
frombash
and get the same, expected and correct behavior:What should be happening is that DNS resolution in the WSL Linux environment works exactly the same as in the Windows environment. Without this, we're forced to "back out" into Windows-land to resolve the IP and then use that directly, which is a huge usability hit. The whole point of the WSL is to provide an alternative environment to the Windows CLI, one which is familiar to developers. IMO a working DNS resolution is a pretty big part of that, lest we need to rely on again, escape-hatching to Windows or workaround by using a proper full Linux distro in a VM software like virtualbox, which will provide this networking translation layer without problems.
strace -o ssh_dns_failure.strace -f ssh pi@raspberrypi
https://gist.github.com/JRHeaton/a67f922837cda51dacd3c1594cd13c4dThe text was updated successfully, but these errors were encountered: