Avahi Networking

Write tutorials and howtos in here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

Avahi Networking

Postby altair4 on 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:
Code: Select all
sudo service avahi-daemon status

If it's not running start it:
Code: Select all
sudo service avahi-daemon start

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:
Code: Select all
avahi-browse -at | grep IPv4

** Using a GUI:
Code: Select all
sudo apt-get install avahi-discover

Then in a terminal run:
Code: Select all
avahi-discover

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:
Code: Select all
gksu gedit /etc/avahi/services/ssh.service

With this content:
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>

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:
Code: Select all
gksu gedit /etc/avahi/services/samba.service

With this content:
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>

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?

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

From Windows in Run or in Explorer ( Windows Explorer - not I.E. ) connect to a Linux Samba server and then Map a particular share:
Code: Select all
\\linux-host-name.local


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.
Last edited by altair4 on Sat Aug 23, 2014 7:18 pm, edited 8 times in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 16
Level 16
 
Posts: 6054
Joined: Tue Feb 03, 2009 10:27 am

Linux Mint is funded by ads and donations.
 

Re: Avahi Networking

Postby altair4 on Sun Dec 23, 2012 10:10 am

I received an email from someone who knows who I really am ( and surprisingly still talks to me ) stating that the avahi *.service templates I posted above do not work. She eventually allowed me access to her PC and I discovered an interesting issue:

I placed the *service file contents in "code" tags. If you use "SELECT ALL" to highlight the contents and do a copy and paste into an editor it indents the first line rendering it useless.

That first line has to start on the first column of the first row so if it has spaces in front of it they need to be removed. Or don't do a "SELECT ALL". Indents in subsequent lines don't matter it's only the first line that matters.

I have edited the HowTo to reflect this odd behavior.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 16
Level 16
 
Posts: 6054
Joined: Tue Feb 03, 2009 10:27 am


Return to Tutorials / Howtos

Who is online

Users browsing this forum: paperloader and 2 guests