8 'This is early stage documentation, but at least attempts to cover
9 some basic usage, and bring mdns usage out of the dark.'
11 mDNS, also known as Bonjour or zero-configuration networking, enables automatic
12 discovery of computers, devices, and services on IP networks. It is
13 an internet standard documented in link:https://tools.ietf.org/html/rfc6762[RFC6762]
15 The 'mdns' package provides a compact implementation of this standard, well
16 integrated with the 'LEDE' system environment. In particular, almost all
17 interaction with the daemon is via link:ubus.html[ubus]
21 * mdnsd - provided by Apple's mDNSResponder package
22 * avahi-* - A fairly full, but quite large implementation
24 === Browsing announced services
28 # wait a second or two
29 $ ubus call mdns browse
30 # big json dump example...
33 "HP\\032Color\\032LaserJet\\032CP2025dn\\032(28A6CC)": {
38 "txt": "ty=HP Color LaserJet CP2025dn",
39 "txt": "product=(HP Color LaserJet CP2025dn)",
41 "txt": "adminurl=http:\/\/NPI28A6CC.local.",
42 "txt": "Transparent=T",
46 "HP\\032LaserJet\\032P3010\\032Series\\032[46A14F]": {
51 "txt": "pdl=application\/postscript,application\/vnd.hp-PCL,application\/vnd.hp-PCLXL",
52 "txt": "ty=HP LaserJet P3010 Series",
53 "txt": "product=(HP LaserJet P3010 Series)",
54 "txt": "usb_MFG=Hewlett-Packard",
55 "txt": "usb_MDL=HP LaserJet P3010 Series",
57 "txt": "adminurl=http:\/\/NPI46A14F.local."
64 * IP addresses are missing
65 * TXT records aren't valid json in the dump, so jsonfilter can't be used.
66 * How long is data cached? What causes it to update? No idea.
68 === Announcing local services
69 'mdns' scans all the services listed in 'ubus' (`ubus call service list`) and
70 looks for 'mdns' objects in their data object. You can view this more
71 selectively for example with:
73 # ubus call service list | jsonfilter -e '@[*].instances[*].data.mdns'
74 { "ssh_22": { "service": "_ssh._tcp.local", "port": 22, "txt": [ "daemon=dropbear" ] } }
77 Here we can see that ssh is being advertised locally.
79 If you want to advertise your own service, your service needs to (*AT THE
80 TIME OF WRITING*) be a link:procd.html[procd] managed service. You can use the `procd_add_mdns`
81 call to provide a basic definition.
85 procd_add_mdns <service> <proto> <port> [<textkey=textvalue> ... ]
90 As an example, the following call
92 procd_add_mdns "hoho" "tcp" "99" "daemon=special" "colour=fuschia"
94 will result in advertising `_hoho._tcp.local` with two text records.
96 If you wish to create a more complicated mdns information block, see
97 'procd_add_mdns_service' in '/lib/functions/procd.sh' but be warned that mdns
98 probably can't automatically support everything you can represent in json.