Avahi

From Gentoo Wiki
Jump to: navigation, search
Resources

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.

Installation

Kernel

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 (overrides USE=gtk2) and build the avahi-ui-gtk3 library
gtk2 Use gtk2 for the avahi utilities (overridden by USE=gtk) and build the avahi-ui 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)

Server

root #emerge --ask net-dns/avahi

Client

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

Configuration

Server Services

systemd

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

OpenRC

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

Troubleshooting

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

root #ss -ltunp | grep 5353

Output:

udp   UNCONN 0      0                          0.0.0.0:5353        0.0.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