Avahi Networking
Posted: Wed Sep 19, 2012 9:44 am
Avahi is a Linux implementation of Zero Configuration Networking ( Zeroconf ) which implements muticast DNS ( mDNS ) allowing ip address to hostname resolution without the use of standard LAN side DNS services. It is installed by default in Ubuntu / Mint although you may not need it depending on how your network is set up. And there may be issues if you find yourself in a corporate network governed by Active Directory authentication where it may conflict with that system.
It is useful in the home network if you don't have a LAN side dns server or your router does not provide that service automatically. The same functionality is provided by Bonjour for Apple products.
Note: This is different than Netbios Name resolution which Samba handles automatically by default.
Preliminaries
Make sure avahi is running:
If it's not running start it:
Note: avahi requires that port 5353/udp is open.
So what can you do with this?
[1] Direct access to another machine by name.
For all machines that have avahi installed you are no longer dependent on LAN side dns servers to resolve host names so one can access another machine though an mDNS qualified ( *.local ) host name everywhere you would normally use the hostname alone or have been forced to use an ip address instead. For example:
ping hostname.local PINGING
nautilus smb://hostname.local SAMBA
nautilus ssh://hostname.local SSH
ipp://hostname.local:631/printers/printer_name REMOTE PRINTER
[2] You can scan the LAN for published services:
** From the terminal:
** Using a GUI:
Then in a terminal run:
Once installed avahi-discover will show up in the menu:
XFCE: Menu > System > Avahi Zeroconf Browser
Mint-Gnome: Menu > System Tools > Avahi Zeroconf Browser
[3] You can create your own avahi published services.
Services are published by creating an *.service config file in the /etc/avahi/services directory and they will now appear as a separate item when browsing the network through Nautilus / Thunar. Examples:
[3a] SSH
Once you set up openssh-server create an ssh.service file:
With this content:
Make sure the first line starts on the first column of the file. It must not have any spaces in front of it.
[3b] Samba Shares
Once you set up Samba shares create a samba.service file:
With this content:
Make sure the first line starts on the first column of the file. It must not have any spaces in front of it.
What about Windows?
EDIT: Windows 10 now has a partial implementation of this protocol. Please see: http://forums.linuxmint.com/viewtopic.php?f=42&t=199907
First, you may already have the capability if you are running applications such as iTunes and Adobe Photoshop on Windows because Bonjour is bundled with it. If not then there is a partial implementation of it available to Windows in the form of the following utility from Apple: Bonjour Print Services for Windows: http://support.apple.com/kb/DL999
It will run the following service on Windows: Bonjour Service - mDNSResponder.exe. Installing a non native networking application on a Windows box may not be something you want to do but I thought I'd point out that it is available.
That particular utility is used to discover avahi/Bonjour enabled printers but it includes the back-ends that enable it to access and be accessed by hostname.local queries. You cannot browse to or be browsed for services in Windows but what you can do for example is:
From Linux connect to a Windows SMB server and then Bookmark that location:
From Windows in Run or in Explorer ( Windows Explorer - not I.E. ) connect to a Linux Samba server and then Map a particular share:
And Apple?
OSX has it installed by default and it would appear that all iOS based apple products have it installed by default.
Updated to expand the Windows section.
It is useful in the home network if you don't have a LAN side dns server or your router does not provide that service automatically. The same functionality is provided by Bonjour for Apple products.
Note: This is different than Netbios Name resolution which Samba handles automatically by default.
Preliminaries
Make sure avahi is running:
Code: Select all
sudo service avahi-daemon status
Code: Select all
sudo service avahi-daemon start
So what can you do with this?
[1] Direct access to another machine by name.
For all machines that have avahi installed you are no longer dependent on LAN side dns servers to resolve host names so one can access another machine though an mDNS qualified ( *.local ) host name everywhere you would normally use the hostname alone or have been forced to use an ip address instead. For example:
ping hostname.local PINGING
nautilus smb://hostname.local SAMBA
nautilus ssh://hostname.local SSH
ipp://hostname.local:631/printers/printer_name REMOTE PRINTER
[2] You can scan the LAN for published services:
** From the terminal:
Code: Select all
avahi-browse -at | grep IPv4
Code: Select all
sudo apt-get install avahi-discover
Code: Select all
avahi-discover
XFCE: Menu > System > Avahi Zeroconf Browser
Mint-Gnome: Menu > System Tools > Avahi Zeroconf Browser
[3] You can create your own avahi published services.
Services are published by creating an *.service config file in the /etc/avahi/services directory and they will now appear as a separate item when browsing the network through Nautilus / Thunar. Examples:
[3a] SSH
Once you set up openssh-server create an ssh.service file:
Code: Select all
gksu gedit /etc/avahi/services/ssh.service
Code: Select all
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h SSH</name>
<service>
<type>_sftp-ssh._tcp</type>
<port>22</port>
</service>
</service-group>
[3b] Samba Shares
Once you set up Samba shares create a samba.service file:
Code: Select all
gksu gedit /etc/avahi/services/samba.service
Code: Select all
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h SMB</name> ## Display Name
<service>
<type>_smb._tcp</type>
<port>445</port>
</service>
</service-group>
What about Windows?
EDIT: Windows 10 now has a partial implementation of this protocol. Please see: http://forums.linuxmint.com/viewtopic.php?f=42&t=199907
First, you may already have the capability if you are running applications such as iTunes and Adobe Photoshop on Windows because Bonjour is bundled with it. If not then there is a partial implementation of it available to Windows in the form of the following utility from Apple: Bonjour Print Services for Windows: http://support.apple.com/kb/DL999
It will run the following service on Windows: Bonjour Service - mDNSResponder.exe. Installing a non native networking application on a Windows box may not be something you want to do but I thought I'd point out that it is available.
That particular utility is used to discover avahi/Bonjour enabled printers but it includes the back-ends that enable it to access and be accessed by hostname.local queries. You cannot browse to or be browsed for services in Windows but what you can do for example is:
From Linux connect to a Windows SMB server and then Bookmark that location:
Code: Select all
nemo smb://windows-host-name.local
Code: Select all
\\linux-host-name.local
OSX has it installed by default and it would appear that all iOS based apple products have it installed by default.
Updated to expand the Windows section.