discover iOS device name using mDNS discover iOS device name using mDNS ios ios

discover iOS device name using mDNS


Have you tried the dns-sd command line tool?

If you type dns-sd -B _services._dns-sd._udp to get all available services, you'll see there's a _whats-my-name service available.

$ dns-sd -B _services._dns-sd._udpBrowsing for _services._dns-sd._udpDATE: ---Tue 16 Dec 2014---14:38:30.746  ...STARTING...Timestamp     A/R    Flags  if Domain               Service Type         Instance Name14:38:30.747  Add        3   5 .                    _tcp.local.          _nfs14:38:30.747  Add        3   5 .                    _tcp.local.          _afpovertcp14:38:30.747  Add        3   5 .                    _tcp.local.          _smb14:38:30.747  Add        2   0 .                    _tcp.local.          _whats-my-name14:38:31.330  Add        3  10 .                    _tcp.local.          _nfs14:38:31.330  Add        3  10 .                    _tcp.local.          _afpovertcp14:38:31.330  Add        2  10 .                    _tcp.local.          _smb

after that we can query for this service which outputs the following:

$ dns-sd -B _whats-my-name._tcpBrowsing for _whats-my-name._tcpDATE: ---Tue 16 Dec 2014---14:40:20.738  ...STARTING...Timestamp     A/R    Flags  if Domain               Service Type         Instance Name14:40:20.742  Add        2   0 local.               _whats-my-name._tcp. Blub MacBook Pro

The Instance Name is the interesting part here. I assume the _whats-my-name service is available on every computer running bonjour. Maybe you can hunt down the sent queries and reconstruct it with basic bash tools if you can't access dns-sd in every case. More over you should not use dns-sd in your script. Instead you should use a specific implementation of the protocol for your programming language.

Note: Be aware that the name of the device may not be reliable to detect which device you are communicating with

Hope that helps.