Normally, if I want to point to a Bonjour-capable host on my local network, I can use its local network hostname, hostname.local
, as in:
$ ssh pi@raspberrypi.local
Unfortunately, this doesn't work for all programs. I get DNS lookup errors when I try this notation in Cyberduck, for example.
So I tried the usual ways of looking up hostnames so I could just type in its IP address. First try, thanks to muscle memory was whois
:
$ whois raspberrypi.local
% IANA WHOIS server
% for more information on IANA, visit http://www.iana.org
% This query returned 0 objects.
%
% You queried for raspberrypi.local but this server does not have
% any data for raspberrypi.local.
Duh. Of course this of course didn't work because the Internet has no idea who my local machine is. I tried some more:
$ nslookup raspberrypi.local
Server: 1.1.1.1
Address: 1.1.1.1#53
** server can't find raspberrypi.local: NXDOMAIN
host -a raspberrypi.local
Trying "raspberrypi.local"
Host raspberrypi.local not found: 4(NOTIMP)
Oops. That's also asking the Internet. How about…
$ host -t NS raspberrypi.local
Host raspberrypi.local not found: 3(NXDOMAIN)
Still no luck. Help me out folks, how can I lookup the IP address of another machine on my local network if all I know is its Bonjour hostname?
Update: Apparently, Cyberduck gives the misleading DNS lookup error if you accidentally type the username into the Server field, as in pi@raspberrypi.local
instead of raspberrypi.local
. ??♂️ It's still a valid question, but not a great premise.
Best Answer
Use
dns-sd
It's the Multicast DNS (mDNS) & DNS Service Discovery (DNS-SD) tool for BSD.
For my example, I write:
And get the IP (redacted) in the address column:
Hostnames and IP addresses have been changed to protect the innocent. I found this answer by looking for other questions about finding Bonjour machines.