[avahi] Looking for help/advice

Eric Wing ewmailing at gmail.com
Mon May 9 14:42:02 PDT 2011

On 5/9/11, Robert Schweikert <rschweikert at novell.com> wrote:
> Hi,
> Trying again to find some help.
> I would like to automate certain tasks for machine configuration in a
> cluster setup. One example of this automatic setup would be setting up
> and NFS mount. Basically the head node of the cluster gets installed and
> manually configured. Then I'd like to run some kind of service on the
> head node and when a cluster node gets installed, upon firstboot some
> client code runs to find the service running on the head node. Then gets
> the IP address from the head node and the path for the NFS share it exports.
> Is Avahi, the proper tool for the job?

Possibly. Please make sure you understand that Zeroconf is only the
service-advertisement and service-discovery portion of the problem.
The actual mounting of NFS still goes through your normal

> How would I go about implementing something like this?

Basically, your server should advertise its service when it becomes
available. You clients should browse for those services when they want
to find and connect to the service.

With respect to automation, the one thing you may need to write
addition code to handle is dealing with name collisions. If two
Zeroconf services try to advertise under the same name, this is not
allowed and Zeroconf has a collision resolution process that tries to
pick a new name that doesn't collide. So one corner case is that your
service dies, but you didn't clean up the stale advertisement, and you
restart the service and try to advertise it again. Your tools need to
deal with the possibility that it could be connecting to the service
that no longer exists and may need to try one of the others.

As for APIs, I live mostly on the Apple side which uses Apple's
Bonjour implementation instead of Avahi so the APIs and tools are a
little different.

I know Avahi has some configuration files that let you advertise
services, though I'm not sure if this is too static for you.

What little I've done with Avahi is mostly documented here:

Apple has a commandline tool called dns-sd which is mostly a debugging
tool, but can be used to advertise or find services on the fly if you
throw the correct command line parameters at it. You could either
implement something like that yourself or just use their tool.
(Apple's source code is open source, but if you use Avahi, you'll need
to port the code.) Of course, you can just implement your own custom
tool for your special purposes directly using the same concepts.

Beginning iPhone Games Development

More information about the avahi mailing list