Jens Segers on Aug 04 2012

Advertising Ubuntu services to OSX using Avahi

At home I have an Ubuntu file server where I keep all my files and backups. On my macbook I have a startup script that mounts my shared folders into finder. But while experimenting with Avahi I managed to advertise my samba shares automatically.

Avahi is a system which facilitates service discovery on a local network via the mDNS/DNS-SD protocol suite. This enables you to plug your laptop or computer into a network and instantly be able to view other people who you can chat with, find printers to print to or find files being shared.

The first thing you need is the avahi-daemon running on your server:

sudo apt-get install avahi-daemon

Next, we need to tell it which specific services to advertise on our network. In the /etc/avahi/services folder you will find all the services that are being advertised. I removed the afp.service file (since I am not using afp) and created a smb.service file with the following contents:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>
    <name replace-wildcards="yes">%h</name>
    <service>
        <type>_smb._tcp</type>
        <port>445</port>
    </service>
    <service>
         <type>_device-info._tcp</type>
         <port>0</port>
         <txt-record>model=Xserve</txt-record>
    </service>
</service-group>

Restart the avahi-daemon to perform the changes:

sudo service avahi-daemon restart

Now you should have an avahi daemon running, advertising your samba shares. You can also advertise other services like http, ssh, vnc but more about that over here.


Comments

Johhny 7 months ago

Great tip, this accidentaly also fixed my problem connecting iTunes to my raspberry DAAPD server!! Thanks!


[email protected] 3 years ago

Thanks for the share!


Gert 4 years ago

Interesting article. Do note that avahi tends to screw up resolution of .local DNS names.