- publish services and hosts running on a local network, and
- discover services and hosts running on a local network.
apt install avahi-daemon
Machines that have cups installed will already have avahi-daemon as a recommended package.
Basically, avahi-daemon will quietly get on with its job of publishing and discovering network services and hosts and most users will require little more from it apart from hostname resolution.
However, it is sometimes desirable to interact directly with avahi-daemon and, for that purpose, avahi-utils is available. The utilities are
Other packages (GUI) of interest are
apt install libnss-mdns
As explained in /usr/share/doc/libnss-mdns/README.Debian, the package's post-installation script alters a line in /etc/nsswitch.conf to read
hosts: files mdns4_minimal [NOTFOUND=return] dns
The mDNS domain .local is where hosts on the network reside and mdns4_minimal handles queries only for that domain. Hostname resolution takes place automatically with commands such as
ping <hostname>.local ssh <hostname>.local nmap <hostname>.local
To resolve a hostname to an IPv4 address with avahi-resolve:
avahi-resolve -n -4 <hostname>.local
The reverse process is performed with
avahi-resolve -a 192.168.7.235
avahi-resolve obtains an IP address or hostname directly from the mDNS multicast from hosts. It does not use the NSS functionality of libnss-mdns.
For a complete view of services and hosts on the network:
avahi-browse -art | less
An entry from the output of one such command will be used to illustrate the common features of any entry.
= eth0 IPv4 Music Player @ desktop Music Player Daemon local hostname = [desktop.local] address = [192.168.7.20] port =  txt = 
Music Player Daemon is the friendly service name. The service is running on port 6600 of the machine desktop.local with an IPv4 address 192.168.7.20. The text record (txt =) in this case is empty. If a service name is not available it will be replaced by the service type. All this information is published and will be available to a client wishing to access the service.
A list of all the service names known to avahi-daemon is given by
avahi-browse --dump-db -k
gives a list of matching service types, application protocol names. The service type _mpd._tcp matches the human-readable Music Player Daemon. This service can specifically be browsed for with
avahi-browse -rt _mpd._tcp
Or, in general:
avahi-browse -rt <service-type>
Display service types of services discovered on the network:
Debian Package Integration with Avahi
Some indication of the Debian packages that support service publication and discovery may be gleaned from libavahi-client3:
apt rdepends libavahi-client3
An incomplete list of packages that co-operate with avahi-daemon to give service publication and discovery is:
With root privileges and for temporary disablement:
systemctl disable avahi-daemon.service avahi-daemon.socket systemctl stop avahi-daemon.service avahi-daemon.socket
Reverse this state of affairs:
systemctl enable avahi-daemon.service avahi-daemon.socket systemctl start avahi-daemon.service avahi-daemon.socket
For permenant disablement (surviving a machine reboot):
systemctl mask avahi-daemon.service avahi-daemon.socket systemctl disable avahi-daemon.service avahi-daemon.socket systemctl stop avahi-daemon.service avahi-daemon.socket
Registering a New Service in Avahi
avahi-daemon will publish local services set up according to .service files placed in the directory /etc/avahi/services. This is independent of the services published from what the system is already aware of on the network.
An example is ssh. openssh-server does not advertise via mDNS but can be induced to by the .service file provided in /usr/share/doc/avahi-daemon/examples/.
Printing and Scanning Services
A scanning service is generally observed to be published by a modern MFD scanning device and shown on discovery as having a service type of _uscan._tcp. libsane1 and sane-airscan provides backends for scanner discovery via avahi-daemon and the escl protocol.