After installing CUPS, I noticed avahi-app was installed as a dependency. Also, while digging around a bit in /usr/local/etc/rc.d, I notice two files of interest: avahi-daemon and avahi-dnsconfd. As a result, I wanted to configure the Avahi on my system provide local hostname resolution using the hostname.local naming scheme as well as the discovery of avahi aware services.
In addition to avahi-app package installed as a dependency of CUPS, nss-mdns package installation is required. It provides host name resolution via Multicast DNS, building on Avahi.
# pkg install nss_mdns
Add the following to /etc/rc.conf:
Modify the hosts: line in /etc/nsswitch.conf to the following:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
mdns4_minimal will always deny to resolve host names not ending in .local or in the IP range 169.254.x.x. This allows mDNS authoritative requests for Zeroconf host names and addresses without creating extra burden on DNS Servers with always failing request and using it as a fallback for everything else.
# getent hosts foo.local 192.168.0.124 foo.local
Replace foo with a host name registered with a mDNS responder. Don’t use tools such as hosts or nslookup as they bypass the nss_mdns and issue a DNS query to the authoritative DNS Servers
Additionally, if a firewall is running on the system, allow UDP Traffic to the mDNS multicast address 184.108.40.206 on port 5353.
If not using the “minimal” version as show above, creating a /etc/mdns.allow file to enable name lookups via mdns in other domains than .local.
Since the above configuration included the “minimal” version, this feature was not tested.
https://github.com/lathiat/nss-mdns https://avahi.org man avahi-daemon.conf also see /usr/local/etc/avahi/avahi-daemon.conf