Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How exactly does mDNS resolve addresses?

Tags:

Once a service is discovered through DNS-SD, how exactly does the address of that host get resolved, and does it take significantly more time/overhead?

Also, if I am using JmDNS or Bonjour there are call-backs for both serviceFound and serviceResolved. If I am just interested in the IP address of the device publishing a certain service, is there a faster/more efficient way of getting the address than going through both serviceFound and serviceResolved?

Thanks

like image 344
ndc5057 Avatar asked Aug 06 '12 20:08

ndc5057


People also ask

How does mDNS Protocol work?

When an mDNS client needs to resolve a hostname, it sends an IP multicast query message that asks the host having that name to identify itself. That target machine then multicasts a message that includes its IP address. All machines in that subnet can then use that information to update their mDNS caches.

What is the difference between mDNS and DNS?

mDNS is also involved in the resolution of domain names to the IP addresses, similar to DNS. Unlike the conventional DNS, the operation of mDNS is up to the level of local network since the operation of DNS takes place at global level. In the Zeroconf network, it works in the combination of the protocol DNS-SD.

What ports does mDNS use?

mDNS listens on port 5353/UDP.

Where is mDNS used?

mDNS (Multicast Domain Name Service) is a related version of DNS, designed for use on small networks, especially in situations where there is no managed DNS server. In mDNS, each device attached to the network (e.g. computers, printers, etc.)


1 Answers

DNS-SD uses Multicast DNS (MDNS) which works by sending DNS packets over UDP to a certain multicast address. All mdns-capable hosts in the network also listen to this address. It uses UDP so, it's quite low overhead. Also, the clients are designed in a way that the amount of chatter on the network is kept to a minimum, by using extensive caching.

Service discovery is a two step process. The first step is finding the names of all hosts providing a certain service (e.g. printing). This will not yet give you the ip address, instead it gives you the mdns name (ending with .local). This is because the ip could possibly change, whereas the name will not.

The second step in service discovery is to resolve the .local name of the host over mdns. You ask via multicast who foo.local is, foo.local will see that packet, and respond via broadcast with its ip address, port number and other information.

like image 87
igorw Avatar answered Sep 20 '22 11:09

igorw