microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.38k stars 818 forks source link

Need help making mDNS work #2664

Closed anohren closed 4 years ago

anohren commented 6 years ago

I can't figure out how to do it. I can't ssh into my .local address because it can't resolve the name.

I also have this unanswered question on Superuser: https://superuser.com/q/1262998/36197

I've followed the last example in this thread:

https://github.com/Microsoft/WSL/issues/384

In other words:

~$ sudo service dbus start
 * Starting system message bus dbus                                                                                                                    [ OK ]
~$ sudo service avahi-daemon start
 * Starting Avahi mDNS/DNS-SD Daemon avahi-daemon                                                                                                      [ OK ]
~$ avahi-resolve --name rpi.local
Failed to resolve host name 'rpi.local': Timeout reached

This was done after installing the packages listed in this answer.

rpi.localcan be resolved by Windows.

Windows 10 Version 10.0.16299 build 16299

~$ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial
therealkenc commented 6 years ago

384 says SO_REUSEPORT was stubbed, but it isn't immediately obvious to me whether stubbing SO_REUSEPORT would address the problem. Windows already has a service listening on 5353. You fired up another service on the same port under WSL, but that doesn't mean the WSL service is going to get the request. Maybe someone out there could confirm they have actually got avahi-daemon running satisfactorily, because #384 technically only says the Protocol not available error was squashed, not that avahi-daemon actually does what people are expecting.

Or I could be talking out of my butt. Haven't tried it. But essentially you've set up (in principle) a load-balanced mDNS with two services on your box, and that tilts my head to the left. YRMV.

anohren commented 6 years ago

Ok, I see. I was led to believe that these lines from #384 was an indication that avahi was doing something useful:

:~# avahi-resolve-address 192.168.0.52
192.168.0.52    xxxxx.corp.microsoft.com
therealkenc commented 6 years ago

To be clear, I don't specifically know that it isn't doing something useful. I just did a netstat.exe -na | find "5353" and know Windows is already there; which is "unusual" compared to what would be the case on a Real Linux box. My November post was fishing for someone to say "yep avahi-daemon is working great on WSL here", in which case we could wander down the path of figuring out why it is working for them but not you. It was more of a question than a statement.

If you are feeling motivated you can try posting a concise CLI repro from clean Ubuntu / unadulterated Windows and see if you get a bite.

anohren commented 6 years ago

Thanks for the clarification

OhMeadhbh commented 6 years ago

please see https://github.com/Microsoft/WSL/issues/384 for a concise CLI repro from WSL and native Ubuntu.

n3dst4 commented 6 years ago

I see #384 has been closed but this is still a problem for me. I don't mind how mDNS gets resolved in WSL, I just care that it should.

Here are ground-up repro steps to make the problem clear:

  1. Set up a computer on your network running actual Ubuntu. Let's call it bunty. 🐧
  2. Make sure avahi-daemon in installed: sudo apt install avahi-daemon
  3. Make sure avahi-daemon is started: sudo systemctl start avahi-daemon.service
  4. Test that this ubuntu box can resolve its own mDNS name: ping bunty.local
  5. For extra certainty, run avahi-browse -a to get a list of all the local mDNS info. It should contain bunty somewhere.
  6. Go to a Windows box with WSL installed. 🗔
  7. Open a CMD prompt and enter ping bunty.local
  8. You should see it pinging the IP address of the Ubuntu box from step 1, indicating that Windows 10's built-in mDNS resolution is working 👌
  9. Now pop open a WSL prompt and enter the same command ping bunty.local

Expected: it should be able to resolve the name like everything else on the network ✨ Actual: it has no clue 😢

anohren commented 6 years ago

Even worse: once WSL resolved my rpi.local address to a random internet server address. I was SSH-ing into it and I even got a prompt for my user password...

Bottom line, I accidentally sent my password to a random machine.

n3dst4 commented 6 years ago

@anohren I had that too, but it turned out I had my work VPN up at the time and it was finding a raspberrypi.local on the office LAN. Any chance you were doing something similar?

anohren commented 6 years ago

Do you mean you had vpn set up in WSL, or in windows?

I don't have any vpn set up though so I doubt it.

n3dst4 commented 6 years ago

@anohren Windows VPN, no idea what crazy network config they had but it was making their .local addresses resolvable over regular DNS. I was just throwing that out there because there's no way a .local address should be resolvable over the public internet.

Coder-256 commented 5 years ago

This is still an issue on Windows 1903.

strarsis commented 5 years ago

+1! System ping in cmd.exe resolves correctly, but in WSL either with System error (when some unsupported resolver is used in /etc/nsswitch.conf; hosts) or just not being able to resolve.

hovissimo commented 4 years ago

Still not working in Version 10.0.17763 Build 17763

daler-rahimov commented 4 years ago

not working on winver 19041.1

ma2shita commented 4 years ago

Wrote how to use powershell.exe. It is not cool, but worked. I pray for COOL improvements. https://github.com/microsoft/WSL/issues/384#issuecomment-571566111

therealkenc commented 4 years ago

Ref #3365 avahi-daemon is better on WSL2

nnp19111990 commented 4 years ago

Hello Guys, I am running the below command on my one of the board having custom linux OS , avahi-daemon --file=/system/etc/avahi/avahi-daemon.conf& the avahi-daemon started on my board and I am able to ping the Host Name on one of the windows PC available with me , using commnad ping Ingenic.local The only issue is i am not able to see the host name on bonjour application(add-on) running on Internet Explorer. what is missing?

dlamblin commented 5 months ago

Well, the m in mDNS is multicast... And I noticed there's comment in WSL2 docs about mirrored networking mode allowing multicast to work. Maybe that's what you want? https://learn.microsoft.com/en-us/windows/wsl/networking#mirrored-mode-networking ; I didn't really check if it is, but I was searching why a zeroconf name wasn't working for a host on a WSL2 instance, and this old closed issue came up and later I found that mirrored mode addressed my issue, so I thought there may be others reading this with a similar situation.