Difference between revisions of "Avahi"

From ArchWiki
Jump to: navigation, search
m (NFS: spelling)
(Installation: add nss-mdns to install command line)
Line 5: Line 5:
 
Install Avahi with:
 
Install Avahi with:
 
<pre>
 
<pre>
# pacman -S avahi
+
# pacman -S avahi nss-mdns
 
</pre>
 
</pre>
 
After installing Avahi you will need to restart the ''dbus'' daemon before you can start ''avahi-daemon''.
 
After installing Avahi you will need to restart the ''dbus'' daemon before you can start ''avahi-daemon''.
  
To start Avahi at boot add ''avahi-daemon'' to the DAEMONS line of /etc/rc.conf. Note that ''avahi-daemon'' must be started after the ''dbus'' daemon.
+
To start Avahi at boot, add ''avahi-daemon'' to the DAEMONS line of /etc/rc.conf. Note that ''avahi-daemon'' must be started after the ''dbus'' daemon.
  
 
For some reason, I (ArcherSeven) have found that adding avahi-daemon to /etc/rc.conf loads it too early and it fails.  To get around this, I added it as '/etc/rc.d/avahi-daemon start' to /etc/rc.local.  Might be worth a try if you have issues.  (This despite it being the last loaded daemon in rc.conf)
 
For some reason, I (ArcherSeven) have found that adding avahi-daemon to /etc/rc.conf loads it too early and it fails.  To get around this, I added it as '/etc/rc.d/avahi-daemon start' to /etc/rc.local.  Might be worth a try if you have issues.  (This despite it being the last loaded daemon in rc.conf)

Revision as of 13:55, 3 June 2010

Avahi is a free Zeroconf (Zero Configuration Networking) implementation, including a system for multicast DNS/DNS-SD service discovery. It allows programs to publish and discover services and hosts running on a local network with no specific configuration. For example you can plug into a network and instantly find printers to print to, files to look at and people to talk to. It is licensed under the GNU Lesser General Public License (LGPL). (Source: Wikipedia:Avahi (software))

Installation

Install Avahi with:

# pacman -S avahi nss-mdns

After installing Avahi you will need to restart the dbus daemon before you can start avahi-daemon.

To start Avahi at boot, add avahi-daemon to the DAEMONS line of /etc/rc.conf. Note that avahi-daemon must be started after the dbus daemon.

For some reason, I (ArcherSeven) have found that adding avahi-daemon to /etc/rc.conf loads it too early and it fails. To get around this, I added it as '/etc/rc.d/avahi-daemon start' to /etc/rc.local. Might be worth a try if you have issues. (This despite it being the last loaded daemon in rc.conf)

Using Avahi

Hostname resolution

Avahi also allows you to access computers using their hostnames. Note: you may need to install nss-mdns for this to work.

Suppose you have machines with names maple, fig and oak, all running avahi. Avahi can be set up so that you don't have to manage a /etc/hosts file for each computer. Instead you can simply use maple.local to access whatever services maple has. However by default, .local querying is disabled in Arch Linux. To enable it edit the file /etc/nsswitch.conf and change the line:

hosts: files dns

to

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

A small section of users in Ubuntu noticed a slowdown in DNS querying; it was attributed to this change. Whether it applies to Arch Linux too, is not known. (Reference: Ubuntu Bug 94940) -- I found this to be true for Arch; However, I just used the line:

hosts: files mdns4_minimal dns mdns4

and I get the correct behavior without slower DNS.

Note: I had to remove mdns completely to prevent slowdowns. However, mdns_minimal alone appeared to be sufficient.

Avahi also has quite a few nifty utilities which can help you discover which services are being used on a network. The avahi-discover (Avahi Zeroconf Browser) shows the various services on your network. You can also browse SSH and VNC Servers using bssh and bvnc respectively.

There's a good list of software with Avahi support at their website: http://avahi.org/wiki/Avah4users

File Sharing

NFS

If you have an NFS share set up, you can use Avahi to be able to automount them in zeroconf-enabled browsers (such as Konqueror on KDE and Finder on Mac OS X). Create a .service file in /etc/avahi/services with the following:

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name>Zephyrus Shared Music</name>
  <service>
    <type>_nfs._tcp</type>
    <port>2049</port>
    <txt-record>path=/data/shared/Music</txt-record>
  </service>
</service-group>

The port is correct if you have insecure as an option in your /etc/exports; otherwise, it needs to be changed (note that insecure is needed for OS X clients). The path is the path to your export, or a subdirectory of it. For some reason the automount functionality has been removed from Leopard, however a script is available. This was based upon this post.

GShare

You can grab gshare from [community] and have shared files between the lan, with no configuration, no hours in samba hacking, no nothing - it just works.

Vsftpd

Sourced from ubuntuforums.org. If you would rather use a regular ftp service, install vsftpd and avahi. Change the settings of vsftpd according to what is shown on the ubuntuforums page or according to your own personal preferences (See 'man vsftpd.conf).

Create a ftp.service file in /etc/avahi/services and paste in that file

<?xml version="1.0" standalone='no'?>
   <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
   <service-group>
   <name>FTP file sharing</name>
   <service>
   <type>_ftp._tcp</type>
   <port>21</port>
   </service>
   </service-group>

When you are done, (re)start avahi-daemon and vsftpd in your /etc/rc.d directory.

/etc/rc.d/avahi-daemon restart
/etc/rc.d/vsftpd restart

You might need to add the following to your /etc/hosts.allow file, so that any person can attempt to log in to your ftp site. See 'man hosts.allow' for other settings that you might want.

'vsftpd: ALL' 

After that you should be able to browse through the ftp server from another computer in your network. The steps shown in this section are created so that the ftp server is 'advertised' by avahi to the local Zeroconf network.

Unless you are using GNOME or KDE, you might not be able to log in to the ftp server directly through your file manager, and so you will have to use a ftp client pointed to the IP address of the server or the hostname of the machine (as shown in this section).

Giver

Giver is a mono program that allows simple file-sharing between two desktops using Giver. All you need to do is click and drag the file to the name or picture of the person you wish to send the file to.

A package is on the AUR.

Note that this depends on gnome-sharp, which has heavy GNOME dependencies.

Pidgin

Pidgin is an instant messenging client that supports quite a few commonly used IM protocols. In addition to these, it supports Bonjour.

Just select 'Bonjour' as the protocol type when you add an account, and enter a username. The first and last name you enter in the 'Advanced' tab will be what the other person (whom you are chatting with) sees, and 'local alias' under 'User Options' in the 'Basic' tab will be what you see of your own name (you could try putting in something like I, me or myself).

Once this is done, other Pidgin (iChat) users who are on the local network will see you and be able to chat with you. To implement file-sharing, you just send and receive files like you would do with a regular IM session.

External Resources