I am trying to use "dns-sd" command line tool on my Windows 7 machine.

I can already do something. For example I can register a service using "dns-sd -R ...". I also can browser (see) registered services using "dns-sd -B ...". What I still miss, is how to unregister a service.

At the moment when I type "dns-sd -R ..." the dns-sd does not return me to the command prompt. To return to the command prompt I need to press Ctrl-C. And the service stays registered till I press Ctrl-C.

What I want is to run "dns-sd -R ..." in the background regime and then I would like to have a possibility to unregister a service from the command line.

One more thing which I do not understand yet is what "to look up a service" means. In my picture it should be sufficient to register a service, to see it and then to unregister it. But apparently I need to look up a service. What does it mean and why I need to do it?

ADDED: As it is asked, I clarify. I refer to "dns-sd" command line tool which I use in Windows 7. I think this command is part of Bonjour software for Windows (from Apple). Well, I did not checked if I had this command before I installed Bonjour, but I assume I did not have it. So, my question is about this command.


It's not clear to me exactly what you're trying to accomplish but it sounds like you may be using the wrong tool. dns-sd is a command line testing tool for Multicast DNS and DNS Service Discovery (DNS-SD). The purpose of DNS Service Discovery as the name implies is to advertise network services. The DNS-SD operations are as follows:


Discover the browse and registration domains configured on the host machine. ".local" will always be returned, Wide-Area domains (eg: example.com) may be available as well:

  • dns-sd -E


Browse for service instances (optionally, in a specific domain):

  • dns-sd -B _http._tcp
  • dns-sd -B _http._tcp dns-sd.org


Resolves a service instance (as returned by Browse) to a host and port to connect to along with a text record containing any service specific parameters:

  • dns-sd -L \ *\ Google,\ searching\ the\ Web _http._tcp dns-sd.org


Registers a service instance so it can be browsed and resolved by other clients browsing a given domain.

  • dns-sd -R Example _http._tcp local 80

Can you be more specific about what is you're trying to accomplish?

  • I register a service with "dns-sd -R". After I type this command, service is registered and I do NOT return to the command line. When i type Ctrl+C I unregister the service and return to the command line. I wanted to know if it is possible to register a service and return to the command line and then to unregister the service by another command. Another part of my question was about "dns-sd -L" which "look up a service instance". I do not understand what "look up" means. I am not user in which way I should be more specific. What exactly should I specify? – Roman Mar 10 '10 at 9:08
  • dns-sd is a testing tool and is not meant to run in the background. The "-L" switch is used to resolve a service. I've added to my post an example of how to use it. Again Bonjour is a network service discovery protocol — it's purpose is to register, browse for and resolve network services. An example use might be to advertise a webserver so that users can use their browser to discover and navigate to the webserver without knowing it's address, port, etc. The process you have outlined doesn't sound like the kind of thing that Bonjour is used for. Are you advertising a network service? – andrewtj Mar 10 '10 at 10:47

If you run a dns-sd command in a terminal (or "DOS box") to register a service, the process stays active in the foreground and does not return a shell prompt to you. The respective service stays registered as long as the dns-sd process keeps running. As soon as you cancel that process by hitting '[ctrl]+[c]', the services becomes un-registered.

Hence, to get back your prompt in the terminal, you have to start the dns-sd command (= process) in the background (or send it into the background after it is started). To un-register the respective service you have to kill the process by whatever means:

  • fetch it into the foreground again and '[ctrl]+[c]' it, or

  • kill the respective PID (process ID).


The way deregistering a service is handled with Apple's mDNS daemon is that upon registering a service the registering process is provided with a service descriptor, and that descriptor is needed to deregister the service. That means that typically only the process that registers a has the necessary info to deregister it. A process can't start up and deregister a service that that process didn't register in the first place.

One reason for this design is that the process that is providing the service is supposed to also be responsible for registering and de-registering it, which ensures that the status of the service registration is synchronized with the actual service availability.

When using dns-sd to do a proxy registration the process continues running so that when you close it, that process can do the proper deregistration. If you need long-lived service registration you need to arrange for the dns-sd process to be long-lived. Launchd can be used to manage this on OS X.

One more thing which I do not understand yet is what "to look up a service" means. In my picture it should be sufficient to register a service, to see it and then to unregister it. But apparently I need to look up a service. What does it mean and why I need to do it?

Browsing for services just tells you what service instances exist; It does not provide sufficient information to actually connect to and use them. To use a service you take the user friendly name discovered via browsing and "look up" or "resolve" the service instance. This tells you the additional information needed for connecting to it: the host, the port number, etc.

This reduces traffic (the additional data could be relatively large, so you don't want to get it for every service instance) and also decouples stable service instance names from the possibly less stable service instance connection data, similar to how hostnames and IP addresses are decoupled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.