brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: dns-sd -B lists the Bonjour services on your network

Terminal
~/tips/tip-macos-dns-sd-browse-bonjour

dns-sd -B _ssh._tcp

Shows which devices on your local network advertise SSH, file sharing or web pages.

Macs, printers, NAS boxes and a lot of smart home gear announce themselves on the local network with Bonjour. That’s how the Finder sidebar and the print dialog find things without you typing an IP address. With dns-sd you can watch those announcements yourself.

dns-sd -B _ssh._tcp

-B browses for a service type. This example lists every machine that announces an SSH server, such as a Mac with Remote Login switched on. Each line shows whether a service was added or removed, the interface, the domain (almost always local. at home) and the instance name. Other types work the same way: _smb._tcp for file sharing, _http._tcp for web pages, _ipp._tcp for printers.

Once you have a name, -L looks up how to reach it, with the host name, the port and any extra TXT attributes:

dns-sd -L "Office Mac" _ssh._tcp
dns-sd -G v4 office-mac.local

-G v4 then turns that .local host name into an IPv4 address (v6 and v4v6 also work). I like this when a device has a vague name in the Finder and I want to know which IP address and port it really uses.

The caveat: dns-sd never exits by itself. It keeps listening and prints new Add and Remove events as devices come and go, so stop it with Control-C. You also only see devices on your own network segment, so a server behind another router or on a separate VLAN won’t show up. And leave -R, the option that advertises a service, for testing. Apple’s own man page points out that announcing a service that doesn’t exist only confuses other people on the network.

Further reading: dns-sd(1) man page (Apple mDNSResponder source)

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link