Table of Contents

Avahi

Avahi is software for Linux that provides multicast DNS.

OS X

OS X will use mDNS to lookup any hostnames ending in .local

OS X seems to cache mDNS entries, even if a service and/or server goes away. To test:

  • Startup iptables, samba, avahi-daemon on nas
  • nas shows up in Finder as NAS
  • Shut down samba and/or avahi-daemon or reboot the box
  • NAS still displays as available.
Finder Bugs

Finder has bugs related to browsing services with zeroconf. See also Samba wiki page for Finder bugs related there as well.

  • Disable avahi on the server, and remove any .service files that advertise _smb._tcp. Start Samba on the server with smbd and nmbd enabled. Finder will display the server as available (lowercase). Start avahi, and now the server shows up in Finder in uppercase. Stop avahi, and the server stops showing up in Finder at all.

Samba

Avahi will advertise services for a Samba server, regardless of whether a smb.service entry exists or not.

Hosts

You can advertise subnets and hosts with mDNS by adding entries to the hosts file in /etc/avahi.

Every service advertised by avahi must also have an entry in the hosts file.

A service for VNC for vnc.local, the hosts file needs to advertise the IP address for vnc.local as well.

Services

MDNS allows OS X to “see” services that are available through Finder. You can add custom services, which is useful for something that doesn't advertise over MDNS by default.

For example, if a server is running a service on another network, but you still want it visible from the existing LAN, you can add a custom service.

Each service has its own file in /etc/avahi/services/ that must end in a .service suffix.

Configuration

Configuration file is found at /etc/avahi/avahi-daemon.conf

Here are some common settings that may affect the network:

  • host-name - defaults to system hostname
  • domain-name - defaults to local (hostname.local)
  • enable-wide-area - only .local domains are resolved by mDNS (enabled by default)
  • disable-publishing - advertise services (any of them), default is to advertise
  • publish-dns-servers - comma-delimited list of unicast DNS servers

Here are some other settings that will probably not need to be modified:

  • publish-addresses - register mDNS records for all local IP addresses (enabled by default)
  • publish-domain - daemon announces the locally used domain name for browsing (enabled by default)

Examples

gentoo.local and netatalk

In /etc/avahi/hosts:

192.168.13.2 gentoo.local

In /etc/avahi/afp.service:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">gentoo</name>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <!-- Customize this to get a different icon in the Finder. -->
    <txt-record>model=PowerMac</txt-record>
    <host-name>gentoo.local</host-name>
  </service>
  <service>
    <type>_afpovertcp._tcp</type>
    <port>548</port>
    <host-name>gentoo.local</host-name>
  </service>
</service-group>
cloud.local and Samba

In /etc/avahi/hosts:

192.168.12.184 nas.local

In /etc/avahi/smb.service:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">nas</name>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=PowerMac</txt-record>
    <host-name>nas.local</host-name>
  </service>
  <service>
    <type>_smb._tcp</type>
    <port>445</port>
    <host-name>nas.local</host-name>
  </service>
</service-group>
win5.local and VNC

In /etc/avahi/hosts:

192.168.12.205 win5.local

In /etc/avahi/vnc.service:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">win5</name>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <host-name>win5.local</host-name>
  </service>
  <service>
    <type>_rfb._tcp</type>
    <port>5900</port>
    <host-name>win5.local</host-name>
  </service>
</service-group>

Ubuntu

The version of Avahi shipped with Ubuntu 10.04 is old, and causes problems on the LAN. Manual install is recommended.

Here's the configure flags to pass to the source install:

./configure --disable-qt3 --disable-qt4 --disable-gtk --disable-gtk3 --disable-mono --disable-gdbm --disable-pygtk --disable-python-dbus --disable-monodoc --disable-python
./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/lib64 --localstatedir=/var --disable-python-dbus --disable-pygtk --disable-xmltoman --disable-monodoc --enable-glib --enable-gobject --disable-tests --disable-autoipd --enable-compat-libdns_sd --disable-compat-howl --disable-doxygen-doc --disable-mono --enable-dbus --disable-python --disable-gtk --disable-gtk3 --disable-introspection --disable-gtk-utils --disable-qt3 --disable-qt4 --enable-gdbm --disable-static --enable-dbus