From Gentoo Wiki
Jump to:navigation Jump to:search

avahi is a zeroconf service discovery and publishing program. A common use for it is to be able to connect to machines via yourhostname.local within your LAN.



KERNEL Required options
Networking support  --->
   Networking options  --->
     [*]   IP: multicasting

USE flags

Some packages are aware of the zeroconf USE flag pulling in avahi.

USE flags for net-dns/avahi System which facilitates service discovery on a local network

autoipd Build and install the IPv4LL (RFC3927) network address configuration daemon
bookmarks Install the avahi-bookmarks application (requires dev-python/twisted)
dbus Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc)
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
gdbm Add support for sys-libs/gdbm (GNU database libraries)
gtk Use gtk3 for the avahi utilities to build the avahi-ui-gtk3 library
howl-compat Enable compat libraries for howl
introspection Add support for GObject based introspection
ipv6 Add support for IP version 6
mdnsresponder-compat Enable compat libraries for mDNSResponder
mono Build Mono bindings to support dotnet type stuff
nls Add Native Language Support (using gettextGNU locale utilities)
python Add optional support/bindings for the Python language
qt5 Add support for the Qt 5 application and UI framework
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)


root #emerge --ask net-dns/avahi


root #emerge --ask sys-auth/nss-mdns


Server Services


Enable the server to start whenever systemd thinks it is appropriate:

root #systemctl enable avahi-daemon.service

If you want to use it right away, also start the service:

root #systemctl start avahi-daemon.service


Be sure to add the service to the default runlevel for the server daemon to start on system boot. Do so with the rc-update command:

root #rc-update add avahi-daemon default

Start the service (without restarting) with the rc-service command:

root #rc-service avahi-daemon start

Client Files

Add the appropriate mdns into the hosts line in /etc/nsswitch.conf, An example line looks like:

FILE /etc/nsswitch.conf
hosts:       files mdns_minimal [NOTFOUND=return] dns mdns

Once this is installed it should be possible to ping the hostname of the machine appending .local. For example:

user $ping yourhostname.local


Check avahi-daemon is running and listen for 5353 UDP:

root #ss -ltunp | grep 5353


udp   UNCONN 0      0                *     users:(("avahi-daemon",pid=4072,fd=13))
udp   UNCONN 0      0                                *:5353              *:*     users:(("avahi-daemon",pid=4072,fd=14))

Commands like host and dig do not use /etc/nsswitch.conf, so they can't be used for Avahi diagnostic. Use getent hosts yourhostname.local instead.

For example:

user $getent hosts gentoo-desktop.local

Output when mdns_minimal in /etc/nsswitch.conf:

fe80::bbbd:5967:6af8:9d27 gentoo-desktop.local