by

Using Avahi in Ubuntu to Broadcast Services to Macs with Bonjour

If you followed this guide, your Ubuntu machine can now serve files to Macs on your local area network (LAN) using AFP. It would be nice if this Ubuntu/Netatalk Apple file server was discovered automatically by your Macs. This can be accomplished by installing Avahi, an implementation of Zeroconf similar to Apple’s Bonjour that allows services running on your Ubuntu machine to be broadcast on the LAN. The following guide will get you started with the installation. When you are finished, the Ubuntu/Netatalk Apple file server will appear in Finder on your Macs connected to your LAN.

Install the Avahi daemon using the apt-get package management software included with Ubuntu. Open a terminal and type the following command:

sudo apt-get install avahi-daemon

I’ve noticed that Avahi may already be installed by default if you are using a newer version of Ubuntu. The Avahi service should start automatically when your machine boots but to make sure type the following command:

sudo update-rc.d avahi-daemon defaults

Next, create a file that will specify information about the AppleShare file server (i.e. Netatalk server) running on your Ubuntu machine.

sudo vim /etc/avahi/services/afpd.service

Copy and paste the following XML code into this file.

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
</service-group>

Then, restart Avahi.

sudo /etc/init.d/avahi-daemon restart

That’s it. After a few minutes your AFP server running on you Ubuntu machine should show up in Finder on your Mac.

6 Comments


  1. // Reply

    Thanks for this! Very helpful! The only issue I have is that I can not copy files to the share from my MBP to the remote machine. But I can create folders. Any suggestion?


  2. // Reply

    Oh man. My mistake. I can write to the ext4 shared dir but unable to copy files from my MBP to an external drive on the remote machine that is shared. I think there is a permission issue. The attached shared drive has to be mounted as root. I think there is where my problem is. I can connect as root when accessing the afp shares.

    At least I know there wasn’t any issue with your tut.

    Thanks


  3. // Reply

    guhhh… no edit

    I can *NOT* connect as root when accessing the afp shares.


  4. // Reply

    Tried this on a Raspberry Pi running Raspbian, and unfortunately it doesn’t work. The daemon is running (saw it listed on reboot) and the service file is in place, but the computer’s not visible from a Mac at [name of Pi].local. I even verified the name in /etc/hostname.

    Thanks anyway.


Leave a Reply

Your email address will not be published.