Resolve mDNS/Bonjour local network names from CLI
13 novembre 2024 à 14:52
ping
can resolve .local
domains, but e.g. host
can't, which is annoying when trying to resolve the IP address of a mDNS host from a e.g. script.
Fortunately, there is avahi-resolve
that can do that, and is easy enough to use in scripts.
The reason I needed that was to consolidate a setup where a network scanner provides a mDNS name, but it can't be used in the SANE device path, only the IP works. So, replace the IP field in the call with "$(avahi-resolve --name -4 NAME.local | awk '{print $2}')"
and voila.
— Permalink