Avahi

The purpose of this article is to give provide information on how to setup the avahi daemon, clients and services. This provide the share service for Apple's network service discovery method "Bonjour" and other systems using Zeroconf/Avahi.

Installation
There are three USE flags around for Avahi/Bonjour support, some apps even use two of them. These are, It is possible to enable them all globally in, but if you do this make sure you enable the and  compatibility USE flags on.
 * - Enables avahi support.
 * - Enables zeroconf support.
 * - Enables bonjour support.

These USE flags are used by ,
 * - Enable support for the D-BUS system message bus. This is needed for applications to publish their services automatically, i.e.
 * - Enable the IPv4LL (RFC3927) network address configuration daemon.
 * - Enable howl compatibility layer.
 * - Enable mDNSResponder compatibility layer.
 * - Enable -3* bindings.
 * - Enable -4* bindings.
 * - Enable bindings.
 * - Enable bindings.
 * - Enable bindings.

Once you've set your USE flags, emerge avahi,

Add the avahi-daemon to the default runlevel,

Testing
If the daemon is installed and running, you can test its function on the local machine by running,

If you see something like the following, all is good, + eth1 IPv4 localhost                                        SSH-Fernzugriff      local + eth1 IPv4 SFTP File Transfer on localhorst                 SFTP File Transfer   local

Avahi also installs a graphical frontend (if build with any of the, or  USE flags) which you should be able to select from your menues. It is called "Avahi Zeroconf Browser". You can also start it from the commandline with:

Services
Some services requires a service description, others can automatically publish their services through Avahi using the D-BUS message bus.

Apache
Sharing local homepages is absolutely easy. Emerge the dnssd mod,

add APACHE2_OPTS="${APACHE2_OPTS} -D DNSSD" to

Restart the apache server,

Cups
Zeroconf isn’t enabled by default so you have to browse the CUPS admin page and enable it. Open http://localhost:631/admin if you’re running it on localhost and enable the “Share published printers connected to this system” option. “Change Settings” will restart CUPS and your printer should be instantly visible to zeroconf-aware applications in the local network.

Unfortunately, shared printers from other systems aren't usable with zero configuration by default. You have to check "Show shared printers from other systems" under Administration and you have to actively search for them and manually add them in the webinterface.

This scrip extracts the configured printers from cups. The necessary .service are created then put them in /etc/avahi/services/ .This will make them visible under avahi, a feature called AirPrint for Macs.

distcc
Make sure you first enabled the USE flag for. Edit your distcc hosts file to include zeroconf hosts,

NTP
See NTP.

MPD
Edit and enable Zeroconf support as shown below,

Pidgin
Pidgin has the USE flag which enables it to communicate to other Instant Messenger in the LAN without a server. Just compile it with that flag, go to the "Accounts" menu, click add and choose "Bonjour" from the list of services. Type in a name you like to use and you are ready.

Custom Services
These are services that Avahi publishes based on what it finds in.

Samba
Avahi can be used for a faster discovery of Samba shares.

Webinterfaces
It is possible to Broadcast Bookmarks of your Webinterfaces on your local Network with the help of Avahi. For that you need to create an static Avahi Servicefile with the following Content. This may be used for non-Apache web-servers.

Now restart Avahi and check the Bookmark Menu under Safari or Epiphany. There you will see how automatically they will appear, when those Services are available.

NFS
Apple's "Finder" is able to autodetect NFS Shares in the Network by using ZeroConf. For that we will use an static Avahi servicefile with the following content:

Now restart Avahi and see how those Shares get mounted with Finder.

A workaround is posted at http://www.macosxhints.com/article.php?story=20071116042238744

iPhoto
iPhoto uses dpap at port 8770. Once this is set up, one can browse shared photos via iPhoto or Front Row on a Mac, or from an Apple TV. Don't forget to enable the USE flag on.

Then, install the DPAP server using CPAN,

Create the DPAP server script,

Add the Avahi service file,

Restart the Avahi daemon,

And finaly, start the DPAP server,

Autoipd
Gentoo's /etc/conf.d/net can use autoipd as a module, which comes quite handy on LANs without DHCP running. The following packages are needed:
 * net-dns/avahi
 * sys-auth/nss-mdns

The following use USE flags should be set:
 * (only for net-dns/avahi, to build the avahi-autoipd program)
 * (only for net-dns/avahi, to build the avahi-autoipd program)
 * (only for net-dns/avahi, to build the avahi-autoipd program)

Configuration
There is not much configuration needed but as the documentation is sparse you need to know where to look. First edit /etc/conf.d/net (replace eth0 with your interface):

Baselayout 2 (OpenRC):

Old baselayout-1:

If you use the second configuration you may want to reduce the timeout for the DHCP client. Therefor see /etc/dhcp/dhclient.conf.sample for dhclient.

Now you need to edit the file /etc/nsswitch.conf: Change the following:

or, if you also want IPv6 support, to

Finalizing
To immediately make use of Avahi do the following as root: Code:

Now you should have a 169.254.* IP address (try ifconfig). Try to ping .local to see if name resolution for the .local domain works.

Uninstalling
Make sure to change your /etc/nsswitch.conf back to the default values, if you ever uninstall sys-auth/nss-mdns!

Browsing Services

 * Make sure you use domain=local in, NOT your real unicast dns domain!
 * If firewalled, open port 5353 (UDP)
 * Make sure you use the right network interface on machines with multiple network cards.
 * Some wireless access points block broadcast traffic ( Cisco DPC3825 DOCSIS provided by Shaw ISP ). Switching to LAN or a different AP allowed AVAHI to work again.