Difference between revisions of "Avahi"

From ArchWiki
Jump to: navigation, search
(Hostname resolution)
(Samba)
(44 intermediate revisions by 18 users not shown)
Line 1: Line 1:
[[Category:Networking (English)]]
+
[[Category:Networking]]
{{i18n|Avahi}}
+
[[fr:Avahi]]
 
+
 
[http://avahi.org/ Avahi] is a free [[Wikipedia:Zero Configuration Networking|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). (Source: [[Wikipedia:Avahi (software)]])
 
[http://avahi.org/ Avahi] is a free [[Wikipedia:Zero Configuration Networking|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). (Source: [[Wikipedia:Avahi (software)]])
  
 
== Installation ==
 
== Installation ==
Install Avahi with:
+
[[pacman|Install]] {{Pkg|avahi}} and {{Pkg|nss-mdns}}, available in the [[official repositories]].
{{bc|
+
 
# pacman -S avahi nss-mdns
+
{{bc|# pacman -S avahi nss-mdns}}
}}
+
 
After installing Avahi you will need to restart the ''dbus'' daemon before you can start ''avahi-daemon''.
+
{{Note|After installing Avahi you will need to restart the {{ic|dbus}} [[daemon]] before you can start {{ic|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.
+
=== Enable Avahi daemon ===
 +
You can enable Avahi Daemon at startup with the following command:
  
{{Note|Sometimes adding avahi-daemon to {{ic|/etc/rc.conf}} can cause it to load too early and fail. One possible solution is to add it as "{{Ic|/etc/rc.d/avahi-daemon start}}" in {{ic|/etc/rc.local}}.}}
+
# systemctl enable avahi-daemon.service
  
 
== Using Avahi ==
 
== Using Avahi ==
Line 28: Line 28:
  
 
=== Hostname resolution ===
 
=== Hostname resolution ===
Avahi also allows you to access computers using their hostnames. '''Note:''' you must install {{Ic|nss-mdns}} for this to work.
+
Avahi also allows you to access computers using their hostnames. '''Note:''' you must install {{Ic|nss-mdns}} for this to work, and have the {{Ic|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 {{Ic|/etc/hosts}} file for each computer. Instead you can simply use {{Ic|maple.local}} to access whatever services {{Ic|maple}} has. However by default, .local querying is disabled in Arch Linux. To enable it edit the file {{Ic|/etc/nsswitch.conf}} and change the line:
 
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 {{Ic|/etc/hosts}} file for each computer. Instead you can simply use {{Ic|maple.local}} to access whatever services {{Ic|maple}} has. However by default, .local querying is disabled in Arch Linux. To enable it edit the file {{Ic|/etc/nsswitch.conf}} and change the line:
  hosts: files dns
+
  hosts: files myhostname dns
to
+
to:
  hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
+
  hosts: files myhostname mdns_minimal [NOTFOUND=return] dns
  
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: [https://bugs.launchpad.net/ubuntu/+source/avahi/+bug/94940 Ubuntu Bug 94940]) -- I found this to be true for Arch; However, I just used the line:
+
The {{Ic|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 {{Ic|mdns}} module at the end. There also are IPv4-only and IPv6-only modules {{Ic|mdns[46](_minimal)}}.
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 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.
  
Avahi also has quite a few nifty utilities which can help you discover which services are being used on a network. 
 
 
The {{Ic|avahi-discover}} (Avahi Zeroconf Browser) shows the various services on your network. You can also browse SSH and VNC Servers using {{Ic|bssh}} and {{Ic|bvnc}} respectively.
 
The {{Ic|avahi-discover}} (Avahi Zeroconf Browser) shows the various services on your network. You can also browse SSH and VNC Servers using {{Ic|bssh}} and {{Ic|bvnc}} respectively.
  
 
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|For run {{Ic|avahi-discover}} you need to install Avahi, pygtk and python-dbus.}}
+
{{Note|{{Ic|avahi-discover}} needs pygtk and python-dbus to be installed.}}
  
 
===File sharing===
 
===File sharing===
Line 51: Line 50:
 
====NFS====
 
====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:
 
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:
 
+
{{hc|/etc/avahi/services/nfs_Zephyrus_Music.service|<nowiki>
 
  <?xml version="1.0" standalone='no'?>
 
  <?xml version="1.0" standalone='no'?>
 
  <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 
  <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 
  <service-group>
 
  <service-group>
   <name>Zephyrus Shared Music</name>
+
   <name replace-wildcards="yes">NFS Music Share on %h</name>
 
   <service>
 
   <service>
 
     <type>_nfs._tcp</type>
 
     <type>_nfs._tcp</type>
Line 61: Line 60:
 
     <txt-record>path=/data/shared/Music</txt-record>
 
     <txt-record>path=/data/shared/Music</txt-record>
 
   </service>
 
   </service>
  </service-group>
+
  </service-group></nowiki>}}
  
 
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 [http://www.macosxhints.com/article.php?story=20071116042238744 a script is available]. This was based upon [http://ubuntuforums.org/showthread.php?p=4387032#post4387032 this post].
 
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 [http://www.macosxhints.com/article.php?story=20071116042238744 a script is available]. This was based upon [http://ubuntuforums.org/showthread.php?p=4387032#post4387032 this post].
 +
 +
====Samba====
 +
 +
{{Note|{{Pkg|samba}} package from extra repository build without an avahi support.}}
 +
{{hc|/etc/avahi/services/smb.service|<nowiki>
 +
<?xml version="1.0" standalone='no'?>
 +
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 +
<service-group>
 +
    <name replace-wildcards="yes">Samba Shares on %h</name>
 +
    <service>
 +
        <type>_smb._tcp</type>
 +
        <port>139</port>
 +
    </service>
 +
</service-group></nowiki>}}
 +
{{Note|If you are trying to connect with OS X Lion the port needs to be 445, not 139.}}
  
 
====GShare====
 
====GShare====
Line 97: Line 111:
 
Note that this depends on gnome-sharp, which has heavy GNOME dependencies.
 
Note that this depends on gnome-sharp, which has heavy GNOME dependencies.
  
===Link-Local XMPP Chat===
+
===Link-Local (Bonjour/Zeroconf) chat===
Link-Local XMPP clients need TCP port 5298 allowed for incoming connections. Check [[Simple_stateful_firewall_HOWTO#Opening_ports_to_incoming_connections|Simple stateful firewall: opening ports to incoming connections]] for more details if you use iptables.
+
 
 +
Avahi can be used for bonjour protocol support under linux. The following chat clients support link-local chat.
  
 
====Gajim====
 
====Gajim====
Line 114: Line 129:
  
 
====Telepathy====
 
====Telepathy====
[http://telepathy.freedesktop.org Telpathy] is a communication framework which supports different protocols using plugins. The [http://www.archlinux.org/packages/?sort=&q=telepathy-salut&maintainer=&last_update=&flagged=&limit=50 Telepathy Salut] plugin provides support for Bonjour/Link-Local XMPP protocol. Empathy is a GNOME front-end to Telepathy. Officially, KDE does not support Telepathy, but work is going on which will eventually replace Kopete. Development version of KDE Telepathy is available in [https://aur.archlinux.org/packages.php?O=0&K=telepathy&do_Search=Go AUR].
+
[http://telepathy.freedesktop.org Telpathy] is a communication framework which supports different protocols using plugins. The {{Pkg|telepathy-salut}} plugin provides support for Bonjour/Link-Local XMPP protocol. Empathy is a GNOME front-end to Telepathy. Officially, KDE does not support Telepathy, but work is going on which will eventually replace Kopete. KDE Telepathy is available in extra.
 +
 
 
===Airprint from Mobile Devices===
 
===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 not fields changed. Save the file as /etc/avahi/services/youFileName.service:
+
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'?><!--*-nxml-*-->
 
   <?xml version="1.0" standalone='no'?><!--*-nxml-*-->
 
   <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 
   <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
Line 152: Line 168:
 
   </service-group>
 
   </service-group>
  
== External Resources ==
+
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: {{bc|# python2 airprint-generate.py -d /etc/avahi/services}}
 +
 
 +
=== Firewall ===
 +
 
 +
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==
 
* [http://avahi.org/ Avahi] - Official project website
 
* [http://avahi.org/ Avahi] - Official project website
 
* [http://en.wikipedia.org/wiki/Avahi_%28software%29 Wikipedia entry]
 
* [http://en.wikipedia.org/wiki/Avahi_%28software%29 Wikipedia entry]
 
* [http://www.apple.com/support/downloads/bonjourforwindows.html Bonjour for Windows] - Enable Zeroconf on Windows
 
* [http://www.apple.com/support/downloads/bonjourforwindows.html Bonjour for Windows] - Enable Zeroconf on Windows
 
* http://www.zeroconf.org/
 
* http://www.zeroconf.org/

Revision as of 16:41, 15 July 2013

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). (Source: Wikipedia:Avahi (software))

Installation

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

# pacman -S avahi nss-mdns
Note: After installing Avahi you will need to restart the dbus daemon before you can start avahi-daemon.

Enable Avahi daemon

You can enable Avahi Daemon at startup with the following command:

# systemctl enable avahi-daemon.service

Using Avahi

Obtaining IPv4LL IP address

By default, if you are getting IP using DHCP, you are using 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:

/etc/dhcpcd.conf
...
#noipv4ll
...

Alternatively, run avahi-autoipd, included in avahi package:

# 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 the 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

to:

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-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

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

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:

/etc/avahi/services/nfs_Zephyrus_Music.service
 <?xml version="1.0" standalone='no'?>
 <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 <service-group>
   <name replace-wildcards="yes">NFS Music Share on %h</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.

Samba

Note: samba package from extra repository build without an avahi support.
/etc/avahi/services/smb.service
 <?xml version="1.0" standalone='no'?>
 <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 <service-group>
    <name replace-wildcards="yes">Samba Shares on %h</name>
    <service>
        <type>_smb._tcp</type>
        <port>139</port>
    </service>
 </service-group>
Note: If you are trying to connect with OS X Lion the port needs to be 445, not 139.

GShare

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.

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

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 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 AUR.

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. The following chat clients support link-local chat.

Gajim

Gajim is a Jabber/XMPP instant messenger client written in PyGTK. In the accounts setup just enable "Local" account.

Pidgin

Pidgin is an instant messaging 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.

Kopete

Kopete is the KDE equivalent of Pidgin. It supports the Bonjour/Link-local XMPP protocol. One need to create an account in Kopete, by simply entering the desired name.

Telepathy

Telpathy is a communication framework which supports different protocols using plugins. The telepathy-salut plugin provides support for Bonjour/Link-Local XMPP protocol. Empathy is a GNOME front-end to Telepathy. Officially, KDE does not support Telepathy, but work is going on which will eventually replace Kopete. KDE Telepathy is available in extra.

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">
 <service-group>
   <name>yourPrnterName</name>
   <service>
     <type>_ipp._tcp</type>
     <subtype>_universal._sub._ipp._tcp</subtype>
     <port>631</port>
     <txt-record>txtver=1</txt-record>
     <txt-record>qtotal=1</txt-record>
     <txt-record>rp=printers/yourPrnterName</txt-record>
     <txt-record>ty=yourPrnterName</txt-record>
     <txt-record>adminurl=http://198.168.7.15:631/printers/yourPrnterName</txt-record>
     <txt-record>note=Office Laserjet 4100n</txt-record>
     <txt-record>priority=0</txt-record>
     <txt-record>product=virtual Printer</txt-record>
     <txt-record>printer-state=3</txt-record>
     <txt-record>printer-type=0x801046</txt-record>
     <txt-record>Transparent=T</txt-record>
     <txt-record>Binary=T</txt-record>
     <txt-record>Fax=F</txt-record>
     <txt-record>Color=T</txt-record>
     <txt-record>Duplex=T</txt-record>
     <txt-record>Staple=F</txt-record>
     <txt-record>Copies=T</txt-record>
     <txt-record>Collate=F</txt-record>
     <txt-record>Punch=F</txt-record>
     <txt-record>Bind=F</txt-record>
     <txt-record>Sort=F</txt-record>
     <txt-record>Scan=F</txt-record>
     <txt-record>pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/urf</txt-record>
     <txt-record>URF=W8,SRGB24,CP1,RS600</txt-record>
   </service>
 </service-group>
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

Firewall

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