Difference between revisions of "Avahi"

From ArchWiki
Jump to: navigation, search
(Obtaining IPv4LL IP address: merge request)
(Hostname resolution: python-dbus -> python2-dbus, use {{Pkg}} formatting on package names.)
Line 43: Line 43:
There's a good list of software with Avahi support at their website: http://avahi.org/wiki/Avah4users
There's a good list of software with Avahi support at their website: http://avahi.org/wiki/Avah4users
{{Note|{{ic|avahi-discover}} needs pygtk and python-dbus to be installed.}}
{{Note|{{ic|avahi-discover}} needs {{Pkg|pygtk}} and {{Pkg|python2-dbus}} to be installed.}}
===File sharing===
===File sharing===

Revision as of 17:56, 20 February 2014

From Wikipedia:Avahi (software):

"Avahi is a free Zero-configuration networking (zeroconf) 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)."


Install avahi and nss-mdns, available in the official repositories.

You can manage the Avahi daemon with avahi-daemon.service using systemd.

Using Avahi

Obtaining IPv4LL IP address

Merge-arrows-2.pngThis article or section is a candidate for merging with dhcpcd.Merge-arrows-2.png

Notes: should be merged into the main page (Discuss in Talk:Avahi#)

By default, if you are getting IP using DHCP, you are using the dhcpcd package. It can attempt to obtain an IPv4LL address if it failed to get one via DHCP. By default this option is disabled. To enable it, comment noipv4ll string:


Alternatively, run avahi-autoipd:

# avahi-autoipd -D

Hostname resolution

Avahi also allows you to access computers using their hostnames.

Note: you must install nss-mdns for this to work, and have avahi-daemon.service enabled and running.

Suppose you have machines with names maple, fig and oak, all running Avahi. Avahi can be set up so that you do not 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 myhostname dns


hosts: files myhostname mdns_minimal [NOTFOUND=return] dns

The mdns_minimal module handles queries for the .local TLD only. In case you have configured Avahi to use a different TLD, you'll also need to add the full mdns module at the end. There also are IPv4-only and IPv6-only modules mdns[46](_minimal).

Avahi includes several utilities which help you discover the services running on a network. For example, run

avahi-browse -alr

to discover services in your network.

The Avahi Zeroconf Browser (avahi-discover) 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

Note: avahi-discover needs pygtk and python2-dbus to be installed.

File sharing


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 OS X). Create a .service file in /etc/avahi/services with the following contents:

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
  <name replace-wildcards="yes">NFS Music Share on %h</name>

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.


Should work out-of-the-box.


You can grab gshareAUR from the Arch User Repository and have shared files between the LAN, with no configuration, no hours in samba hacking, no nothing - it just works.


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">
   <name>FTP file sharing</name>

When you are done, restart the avahi-daemon.service and vsftpd.service services.

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 is a mono program that allows simple file-sharing between two desktops when both are running 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 giverAUR.

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

Link-Local (Bonjour/Zeroconf) chat

Avahi can be used for bonjour protocol support under linux. Check Wikipedia:Comparison of instant messaging clients or List of Applications#Instant messaging for a list of clients supporting the bonjour protocol.

Airprint from Mobile Devices

Avahi along with CUPS also provides the capability to print to just about any printer from airprint compatible mobile devices. In order to enable print capability from your device, simply create an avahi service file for your printer in /etc/avahi/services and restart avahi. An example of a generic services file for an HP-Laserjet printer would be similar to the following with the name, rp, ty, adminurl and note fields changed. Save the file as /etc/avahi/services/youFileName.service:

 <?xml version="1.0" standalone='no'?>
 <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
     <txt-record>note=Office Laserjet 4100n</txt-record>
     <txt-record>product=virtual Printer</txt-record>
Alternatively, https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py can be used to generate Avahi service files. It depends on python2 and pycups. The script can be run using:
# python2 airprint-generate.py -d /etc/avahi/services


Be sure to open UDP port 5353 if you're using iptables:

 # iptables -A INPUT -p udp -m udp --dport 5353 -j ACCEPT

If you're following the more-than-useful Simple Stateful Firewall format for your firewall:

 # iptables -A UDP -p udp -m udp --dport 5353 -j ACCEPT

See also