TodayTools

Multicast DNS

How mDNS works

Finding printers and speakers with no server

Donate
L7ApplicationPort 5353UDP
What brings you here?

Watch it happen

How much detail

Your laptop finds office-printer.local on the home network with no DNS server, just by asking everyone.

Your laptop
Home Wi-Fi
Office printer
Kenji's phone
Wi-FiCableLookupControlResponse

3 steps, 3 packets

First up: Ask the room. Press Play to watch it happen, one step at a time.

0 of 30/3

What is mDNS?

Multicast DNS lets devices on the same home or office network find each other by name with no DNS server at all. A device asks the whole network who owns a name ending in .local, and the owner answers.

Paired with DNS-SD (DNS Service Discovery), it also lets apps find services by type: every printer, every speaker, every screen you can cast to. This is how a print dialog or a music app fills its list the moment you open it.

Think of it like this. It is like walking into a small office and asking out loud: who is the printer? The printer says: me, I am at desk 40. Everyone in the room hears the answer, so nobody needs to ask again for a while.

Step by step

Find by name

3 steps

Your laptop finds office-printer.local on the home network with no DNS server, just by asking everyone.

  1. 1

    Ask the room

    Who is office-printer.local?

    Names ending in .local are not sent to your DNS resolver. Instead the laptop sends the question to the multicast group 224.0.0.251 on port 5353, which every device on the network hears.

  2. 2

    Owner answers

    Only the printer replies

    Every device checks the name. Only the printer owns office-printer.local, so only it answers. Kenji's phone ignores the question.

  3. 3

    Everyone learns

    Answer sent to the group

    The answer also goes to the whole group, so other devices update their caches for free. The record lasts 120 seconds and is refreshed as needed.

Browse services

4 steps

The print dialog lists printers without knowing any names, using DNS-SD service browsing over mDNS.

  1. 1

    Ask for a service type

    Any printers here?

    The print dialog asks for PTR records of _ipp._tcp.local, the service type for network printers. It does not need to know any printer names.

  2. 2

    Printer describes itself

    PTR, SRV, TXT and A in one go

    The printer answers with its friendly name (PTR), its host and port (SRV, port 631), details like colour support (TXT) and its address (A). One reply holds everything.

  3. 3

    Quiet repeats

    Known-answer suppression

    When the laptop asks again later, it lists the answers it already knows. The printer sees its own answer in the list and stays quiet, which saves traffic.

  4. 4

    Goodbye

    TTL 0 when it switches off

    Before the printer powers down it sends its records with TTL 0. Every device removes it from its list at once instead of waiting for it to time out.

Name clash

4 steps

A second printer with the same default name joins. Probing spots the clash and it picks a new name.

  1. 1

    Probe

    Is office-printer.local taken?

    Before using a name, a device asks for it three times, 250 ms apart. Its first probe asks for a direct (QU) reply.

  2. 2

    Defended

    The first printer answers

    The existing printer replies with its own record. The new printer now knows the name is taken.

  3. 3

    Rename and probe again

    office-printer-2.local

    The new printer picks a new name, often by adding a number, and probes that one three times. Nobody answers.

  4. 4

    Announce

    The new name is claimed

    It sends an unsolicited answer to the group so every device learns the new name right away.

Myths and mix-ups

  • mDNS is not a different kind of DNS: it uses the same message format, sent to a group instead of a server.
  • mDNS does not work across the internet; its packets stay on the local network.
  • A .local name is not registered anywhere; each device simply claims it and defends it.
  • mDNS is not only on Apple devices; Windows, Android, Linux, printers and smart speakers use it too.

Try it yourself

Run these on your own computer to see mDNS at work.

  • List every service type (macOS)

    dns-sd -B _services._dns-sd._udp

    Shows the kinds of services on your network. Press Ctrl+C to stop.

  • Find printers (macOS)

    dns-sd -B _ipp._tcp

    Each line is a printer announcing itself. Try _http._tcp for devices with a web page.

  • Look up a .local name (macOS)

    dns-sd -G v4 office-printer.local

    Replace the name with a device on your network.

  • Browse everything (Linux)

    avahi-browse -a

    Needs the avahi-utils package. Lists every service and the device offering it.

  • Reach a device by name

    ping office-printer.local

    Works on macOS, Linux and Windows 10 or later when the device answers mDNS.

mDNS at a glance

Layer
Application (7)
Port
UDP 5353
Group address
224.0.0.251 and ff02::fb
Names
End in .local
Reach
Local network only, never past a router
Service discovery
DNS-SD (RFC 6763)
Defined
2013 (RFC 6762)

Defined inRFC 6762RFC 6763

Header fields

What mDNS puts in its messages, with example values from the stories above.

mDNS

Transaction ID
0x0000Multicast mDNS sets this to zero. Answers are matched by name, not by number.
Flags
0x8400 Standard query response, AuthoritativeAA=1: the printer is the true owner of its own name.
Query
office-printer.local, type A, class IN, "QM" questionQM means the answer may come back by multicast, so everyone can hear it.
Answer
office-printer.local A 192.168.1.40, TTL 120, cache flushCache flush says: this is the full, current answer, throw away older ones.
Additional
Office Printer._ipp._tcp.local SRV 0 0 631 office-printer.localWhere the service lives: host name and port. 631 is the IPP printing port.
Known answer
_ipp._tcp.local PTR Office Printer._ipp._tcp.local, TTL 4499Answers already known go in the question, so their owners do not repeat them.
Authority
office-printer.local A 192.168.1.41The record it wants to claim, so two probing devices can settle a tie.

Test yourself

Question 1 of 5Score 0

Which port does mDNS use?

Questions people ask

What is mDNS?

Multicast DNS lets devices on a local network find each other by name, like printer.local, without a DNS server. The question goes to everyone and the owner answers.

What is a .local address?

A name a device gives itself on your local network, found with mDNS. It only works inside that network and is not registered anywhere.

What port does mDNS use?

UDP port 5353, sent to the group address 224.0.0.251 for IPv4 or ff02::fb for IPv6.

Is it safe to block mDNS?

On a guest or public network, often yes. At home, blocking it can stop printers, speakers and casting from showing up.

Why can I not see my printer on another network?

mDNS packets stay on one local network and routers do not pass them on. Devices on a different subnet or VLAN need an mDNS gateway or the printer's IP address.

Donate