32

Does Windows (some modern flavour) have an mDNS server installed and/or running by default? If so then how does one tell it, preferably dynamically, to start/stop advertising a new service?

If there is no standard then how does one deal with the problem of conflicts trying to run multiple mDNS servers in that environment?

Basically, I want to implement a service that will run on Linux, Windows and Mac OS X and which needs to advertise its zeroconf webserver location using mDNS. On Linux I just use avahi-publish (or install a config file). I'm guessing that the answer will be straightforward for OS X. I'm struggling to find information for Windows.

awy
  • 5,271
  • 5
  • 23
  • 28

6 Answers6

46

Starting with Windows 10, Microsoft made strides towards a native Windows implementation of mDNS and DNS-SD.

While earlier iterations have been limited to UWP apps, a general Win32 API has been exposed from at least SDK version 10.0.18362.0 (1903/19H1, May 2019).

Note: This implementation is currently confirmed working only for 64bit build targets, there is an open issue preventing compilation for 32bit targets.

Outdated note from a previous version of this answer:

Early iterations resulted in mDNS network flooding:

Windows 10, in its default configuration, will spam its local networks by responding to all mDNS requests with null response packets.

This issue was fixed in Windows 10 1511 (10586) and above

Jens Habegger
  • 5,266
  • 41
  • 57
  • "which is currently limited to UWP apps" => does not appear to be true any more. The page you link to now says "Win32 DNS Service Discovery (DNS-SD) APIs are declared in the windns.h header. For example, the Win32 APIs for announcing and discovering services are DnsServiceRegister and DnsServiceBrowse" – Simon Kissane Nov 25 '20 at 05:41
  • Thanks for the heads up. Unfortunately, the documentation does not indicate since when this limitation has been liftet. I'll adapt the answer to reflect the new situation. – Jens Habegger Nov 25 '20 at 08:37
  • According to a [random but informative PR on GitHub](https://github.com/mumble-voip/mumble/pull/4494), the APIs were exposed to Win32 in SDK version 10.0.18362.0 (1903/19H1). (Possibly, the Win32 APIs were there all along but only documented and exposed in public header files starting in that SDK version.) Also, the same PR mentions that apparently this API is broken and buggy on 32bit, but works fine on 64bit. – Simon Kissane Nov 25 '20 at 09:21
  • Thanks for your research, I updated the answer to reflect the latest development. – Jens Habegger Nov 25 '20 at 09:43
  • No longer an "open issue" – Andrew Savinykh Oct 07 '21 at 23:07
12

Last time I needed one, Apple's Bonjour Print Services for Windows was the most convenient mDNS client for Windows I could find. Only 5MB.

Nicolas Melay
  • 1,612
  • 1
  • 13
  • 12
  • 3
    I have not been able to get this to work on the most recent version of Windows 10. I suspect that the reason is that Windows itself (a process called DNSCache) is now listening on port 5353. – Kevin Keane Jun 10 '18 at 04:37
5

Have also successfully used C++/WinRT for dnssd discovery directly from C++ now. It appears from our perspective to be quicker and more reliable to query services and will let you easily install a watcher to get notifications when devices arrive etc. Of course, this is limited to versions of Windows 10 with support for C++/WinRT, which starts with 10.0.17134.0 (Windows 10, version 1803).

One caveat: We've noticed that it does not provide, nor recognise, a FQDN (trailing dot). So for a device that Bonjour OR Avahi would give an address of mydevice.local., Windows instead gives mydevice.local. Attempting to ping mydevice.local. under Windows 10 (1809) fails.

Ian
  • 433
  • 3
  • 6
  • I am very interested in your solution as we have exactly the same problem... would you be able to share some code/example... that would be SUPER helpful! Thanks. – user3256556 Apr 30 '20 at 06:53
3

Windows 10 supports natively mDNS/Zeroconf, but only for modern APIs, not for Win32 applications. If you have such an application, a third party service is required.

Source: https://social.technet.microsoft.com/Forums/en-US/8a0346de-2296-4f46-bc36-ff3fb13e283b/builtin-mdnsdnssd-zeroconf-support-in-windows-10

FarO
  • 161
  • 11
  • "only for modern APIs, not for Win32 applications" => appears to no longer be true. See DnsServiceRegister and DnsServiceBrowse APIs in windns.h – Simon Kissane Nov 25 '20 at 05:42
  • @SimonKissane can you provide a link, since you mention a mistake and (I guess) also downvoted? – FarO Nov 25 '20 at 13:46
  • no I didn't downvote you. Someone else must have done that. For link, please see Jens Habegger answer above which has been updated with the details – Simon Kissane Nov 26 '20 at 03:22
  • @SimonKissane I'm trying to use these functions but their registration doesn't show in UPnP scanning tools. – Michael Chourdakis Apr 30 '22 at 14:01
  • @MichaelChourdakis I had a project I was planning to use them in, and so was researching them to determine its feasibility, but (at least for now) that project isn't going ahead, so I never actually tried using them. Given that, sorry, I can't help you with any issues using it. (Maybe turn your problem into a question, and perchance someone else will answer it?) – Simon Kissane May 01 '22 at 04:13
-3

The short answer is to support both Avahi and Bonjour. You'll need Bonjour support to run on OSX anyway, and if a Windows user has installed iTunes they'll already be running it.

As a fallback for Windows users not running iTunes, you can compile Avahi as a library for Windows (with a bit of effort) and bundle it. This is a non-trivial bit of packaging, but the alternative is requiring your Windows users to install iTunes in order to use your application.

Arc
  • 21
  • 1
  • 5
    Avahi and Bonjour are differently licensed implementations of the same protocol. https://en.wikipedia.org/wiki/Avahi_(software)#Avahi_vs._Bonjour – Matt Mar 17 '16 at 14:30