2

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.

Cyberduck's DNS lookup error

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.

3

Use dns-sd

It's the Multicast DNS (mDNS) & DNS Service Discovery (DNS-SD) tool for BSD.

$ dns-sd -Gv4v6 <hostname>.local

For my example, I write:

$ dns-sd -Gv4v6 raspberrypi.local

And get the IP (redacted) in the address column:

DATE: ---Wed 19 Jun 2019---
14:23:40.213  ...STARTING...
Timestamp     A/R    Flags if Hostname               Address         TTL
14:23:40.531  Add        2  5 raspberrypi.local.     <redacted MAC>  120
14:23:40.548  Add        2  5 raspberrypi.local.     10.1.2.3        120
14:23:40.838  Add        3  5 raspberrypi.local.     <redacted MAC>  120
14:23:40.838  Add        2  5 raspberrypi.local.     10.1.2.4        120

Hostnames and IP addresses have been changed to protect the innocent. I found this answer by looking for other questions about finding Bonjour machines.

  • Where is the IP address? At least put in 192.1.2.3 or some non routable address to show how the answer gives an IP address resolution. – bmike Jun 20 at 0:56
  • Are the <redacted local IP> and <redacted MAC> insufficient? Update: changed the redacted tags to false IP addresses. – Merchako Jun 20 at 0:59
  • 1
    That looks awesome! On mobile I didn’t see it was scrolled content so it looked horribly short. – bmike Jun 20 at 1:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .