WSL: Can't resolve ".local" (mDNS) hosnames
I have an existing stock Ubuntu server on my network. Let’s say its hostname is “my-server”. (The following should work with a stock Mac as well; not sure about Windows servers?)
If I open up a regular Command Prompt, I can do the following:
C:\Users\me>ping my-server.local
Pinging my-server [10.0.0.1] with 32 bytes of data:
Reply from 10.0.0.1: bytes=32 time=3ms TTL=64
Reply from 10.0.0.1: bytes=32 time=1ms TTL=64
Reply from 10.0.0.1: bytes=32 time=1ms TTL=64
Reply from 10.0.0.1: bytes=32 time=1ms TTL=64
Ping statistics for 10.10.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 3ms, Average = 1ms
But from Bash-on-Windows:
bash-on-windows$ ping my-server.local
ping: unknown host my-server.local
For comparison, from a real Ubuntu machine on the same network, I can do:
real-linux$ ping my-server.local
PING my-server.local (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.206 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=0.138 ms
64 bytes from 10.0.0.1: icmp_seq=3 ttl=64 time=0.130 ms
(...)
Granted, ping wouldn’t work even if it could resolve the name due to #18 , but other tools like curl or ssh would work if appropriate services were running on the server. I’m just trying to post a minimal reproducer.
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Reactions: 14
- Comments: 39 (5 by maintainers)
This is still an issue, please reopen.
I am able to use cmd.exe to ping a
.localbut not WSL.On Native Linux mDNS services are normally provided by Avahi. As you assured me, your request is for mDNS name resolution to work on WSL, not the Avahi mDNS service. It is not the same software installed. One is Avahi. One is the Windows 10 mDNS service.
There are no known outstanding issues with dbus in WSL. If you find any problems with dbus, please feel encouraged to open a new issue describing the diverge.
I am really saying: that if it doesn’t work, that would be a great new issue submission. But it would need a repro with a concise set of CLI repro steps on both the win32 side and the WSL side that identified a diverge in behaviour in WSL versus say a Real Linux Ubuntu in a VM connected to the same mDNS service on Windows.
Oooh, I just hit this one. It was quite a head-scratcher! I’m curious as to whether there’s been any progress on this 😮
It also refutes Microsoft’s position that “it is impossible to do mDNS in WSL because the WinNT side does mDNS” - if PowerShell can do mDNS, then they should be able to replicate that functionality as a resolver. I am reminded that Microsoft has a long history of favoritism. I mean, it’s not surprising that they want you to use WinNT instead of WSL, but they should at least stop saying they’re “a Linux Company” or that they support Linux. WSL is a toy, meant to demonstrate the functionality of their hypervisor (which, admittedly, is pretty cool if you want to run WinNT). They clearly have no interest in making a useful product. As much as I groan every time I have to slog through the AWS console, I’m happy to stick with AWS if this is how they support Linux.
no. mDNS already works on Windows 10. in fact, my work around is to use cmd.exe to do the resolution with a command like
ping -4 whatever.localand then copy the ip address into a bash window.i assure you, my request is for mDNS name resolution to work on WSL.
the title of this issue is “can’t resolve ‘.local’ (mDNS) hostnames” and not “can i listen on port 5353.”
i’m asking if we’ll ever be able to resolve .local (mDNS) hostnames.
@scivision - I looked into this a bit. As explained previously, there were two blocking issues.
After stubbing (1) (because there is no support from Windows networking stack), implementing (2) and few other minor changes, it seems like
avahi-daemonis happy.I will get the PR out and try to get this in time for Fall Creators Update.
If you look at the
avahi-daemonlogs (with this change), it still complains aboutIP_ADD(DROP)_MEMBERSHIP, but that can be taken up as a separate issue. It appears to be functional otherwise, in my limited testing.This should be fixed in 16273
I really think this issue should be reopened. It would be great if WSL handled mDNS out of the box, or if one simply had to
apt install avahi-daemon; sudo service avahi-daemon startBeing able to resolve “.local” network names without copying->pasting ip addresses should be possible.edit: I’m still seeing this issue on build 17134.286, any assistance is appreciated.
On one of the latest builds:
From the output above, we can see few blocking issues here. Those would be; support for the socket option
SO_REUSEPORTandSO_PASSCRED for netlink sockets. Support forSO_REUSEPORTrequires some work from the core Windows networking team and the WSL team is working with them on that.SO_PASSCRED for netlink socketsseems entirely in control of WSL and should be trivial. No ETA for either of them yet.To get .local mDNS hostnames working on WSL 1, I ran the following:
If I leave out
sudo service dbus startthen I see:For me this is only working over IPv4, and not over IPv6.
Lack of Avahi support in WSL makes it difficult to use WSL/WIndows PCs in teaching labs with increasingly ubiquitous Raspberry PI and the like in engineering education.
avahi-daemonis okay on WSL2 ref #4210 (message). I’ve been using it myself recently. Whether something like that would (or even should) get rolled into WSL-brand/initI don’t know. I suspect (but can’t prove) the longer term answer is going to be some kind of support for systemd.This issue ended up dupe #376 and fixed in 16273, because that was the first (but not the only) blocker on
avahi-daemonat the time. Also ref #3365.It’s understandable why avahi does not work out-of-the-box, but this doesn’t mean that the issue is resolved. The issue presented in the first entry could be solved without avahi, e.g. by adding the mDNS entries to /etc/hosts by WSL, or providing the mapping in any other way.
Manually translating hostname to IP will not work if TLS is involved and certificate is issued for the .local domain name. Likewise, SSH may complain.
If not by default, does anyone know if there is a (linux-side) service that can be installed, that interfaces WinNT side to query mDNS resolution?
@ma2shita That works, but it’s not a workaround when I’m trying to use Ansible to provision machines, for example.
How about trying this?
powershell.execan be invoked from bash on WSL. STDOUT is returned to bash so it can be piped. (e.g. grep, jq (with ConvertTo-JSON in PowerShell))@sunilmut This is still not working in Version 10.0.17763 Build 17763
And I assure you, if it doesn’t work, that would be a great new issue submission. But it would need a repro with a concise set of CLI repro steps on both the win32 side and the WSL side that identified a diverge in behaviour in WSL versus say a Real Linux Ubuntu in a VM connected to the same mDNS service on Windows.
Which no one (that I am aware of) has looked into.