0%

Avahi-Daemon Service

Robin

Avahi is a free zero-configuration networking (zeroconf) implementation, including a system formulticast DNS/DNS-SDservice discovery.

Backgroud

Avahi is a system which enables programs to publish and discover services and hosts running on alocal network. For example, a user can plug their computer into a network and have Avahi automatically advertise thenetwork services running on the machine which could enable access to files and printers.

ZeroConf or UPnPs

Why UPnPs, because UPnP is an organization, not a specific protocol. It’s like saying: We are implementing RFC XXXX, rather than saying: We are implementing IETF.

ZeroConf is a precisely defined, three-in-one protocol, namely: Address Selection, Name Resolution and Service Discovery, to reduce the difficulty of network configuration

For example, Apple’s Bonjour service is an implementation of ZeroConf. If Bonjour for Windows service is installed on Windows, you can easily find and use printers that support ZeroConf on the network.

The purpose of ZeroConf is to improve the availability and reliability of the product without the need to provide complex documentation, reduce support costs, and improve customer satisfaction.

In contrast, UPnP is an open device-related protocol set. For each new device, a new working group is set up in the UPnP Forum to discuss how such devices work. The problem is that while there are many devices that claim to support UPnP, these are just nominal claims. For example, Windows does not use UPnP to discover, configure, and use printers that exist on the network.

Why not replace UPnP with ZeroConf?

There is a misunderstanding here:

  1. There is no question of choice here: there is no reason to not support UPnP when supporting ZeroConf, which is technically entirely feasible. At the level of local address selection, ZeroConf and UPnP are exactly the same.
  2. As mentioned earlier, ZeroConf is the protocol and UPnP is the organization.
  3. If someone says: We are adapting UPnP, it is estimated to have two meanings: we are adapting to a specific UPnP protocol, or he means that those unfortunate network configuration problems have been left to the engineers to solve.

Conclusion

  • In terms of address selection, ZeroConf is not different from UPnP.
  • ZeroConf provides domain name resolution services, but UPnP does not (obvious difference).
  • At the level of service discovery, the two have their own implementations, but they do not conflict. ZeroConf is mDNS-SD and UPnP is SSDP.
  • If you are building a new product, rather than working on an existing UPnP protocol model, it doesn’t make sense to use UPnP. UPnP is only for a specific implementation of some problems in a very narrow direction.

Install

1
:~$ sudo apt-get install avahi-daemon

Configure Avahi

The path of configure file was /etc/avahi/avahi-daemon.conf.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# This file is part of avahi.
#
# See avahi-daemon.conf(5) for more information on this configuration
# file!

[server]
host-name=foo
domain-name=local
#browse-domains=0pointer.de, zeroconf.org
use-ipv4=yes
use-ipv6=no
allow-interfaces=eth0
#deny-interfaces=wlan0
check-response-ttl=yes
use-iff-running=no
enable-dbus=yes
disallow-other-stacks=yes
#allow-point-to-point=no
cache-entries-max=4096
clients-max=4096
objects-per-client-max=1024
entries-per-entry-group-max=32
ratelimit-interval-usec=1000000
ratelimit-burst=1000

[wide-area]
enable-wide-area=yes

[publish]
disable-publishing=no
disable-user-service-publishing=no
add-service-cookie=yes
publish-addresses=yes
publish-hinfo=no
publish-workstation=no
publish-domain=yes
publish-dns-servers=192.168.50.1, 192.168.50.2
publish-resolv-conf-dns-servers=no
publish-aaaa-on-ipv4=yes
publish-a-on-ipv6=no

[reflector]
#enable-reflector=no
#reflect-ipv=no

[rlimits]
#rlimit-as=
#rlimit-core=0
#rlimit-data=8388608
#rlimit-fsize=0
#rlimit-nofile=768
#rlimit-stack=8388608
#rlimit-nproc=3

How to config hostname

1
sed -i 's/^#host-name=.*/host-name=pi/' /etc/avahi/avahi-daemon.conf

Add service for local lan

The Path is /etc/avahi/services/.

man avahi.service

public SSH service

ssh.service:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<!-- See avahi.service(5) for more information about this configuration file -->

<service-group>
<name replace-wildcards="yes">%h ssh</name>
<service protocol="ipv4">
<type>_ssh._tcp</type>
<port>22</port>
<host-name>pi.net</host-name>
</service>
</service-group>

Public Samba Service

samba.service:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<!-- See avahi.service(5) for more information about this configuration file -->

<service-group>
<name replace-wildcards="yes">%h samba</name>
<service protocol="ipv4">
<type>_smb._tcp</type>
<port>139</port>
<host-name>pi.net</host-name>
</service>
</service-group>

Public ftp service

ftp.service:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<!-- See avahi.service(5) for more information about this configuration file -->

<service-group>
<name replace-wildcards="yes">%h Ftp</name>
<service protocol="ipv4">
<type>_ftp._tcp</type>
<port>21</port>
<host-name>pi.net</host-name>
</service>
</service-group>

types of service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# Devices

_workstation._tcp:Workstation
_workstation._tcp[de]:Arbeitsplatzrechner
_workstation._tcp[it]:Macchine

# Web

_http._tcp:Web Site
_http._tcp[de]:Web-Angebot
_http._tcp[it]:Sito Web

_https._tcp:Secure Web Site
_https._tcp[de]:Sicheres Web-Angebot
_https._tcp[it]:Sito Web sicuro

_rss._tcp:Web Syndication RSS

# Network

_domain._udp:DNS Server
_domain._udp[de]: DNS-Dienst

_ntp._udp:NTP Time Server

_smb._tcp:Microsoft Windows Network
_smb._tcp[it]:Rete Microsoft Windows

_airport._tcp:Apple AirPort

# File and data access

_ftp._tcp:FTP File Transfer
_ftp._tcp[de]:FTP-Dateifreigabe

_tftp._udp:TFTP Trivial File Transfer

_webdav._tcp:WebDAV File Share
_webdav._tcp[it]:WebDAV Condivisione File

_webdavs._tcp:Secure WebDAV File Share
_webdavs._tcp[it]:WebDAV Condivisione File Sicuro

_afpovertcp._tcp:Apple File Sharing

_nfs._tcp:Network File System

_sftp-ssh._tcp:SFTP File Transfer

_apt._tcp:APT Package Repository
_apt._tcp[it]:APT - Repository dei Pacchetti

_odisk._tcp:DVD or CD Sharing

_adisk._tcp:Apple TimeMachine

# Remote machine access

_ssh._tcp:SSH Remote Terminal
_ssh._tcp[de]:SSH-Fernzugriff
_ssh._tcp[it]:SSH Terminale remoto

_rfb._tcp:VNC Remote Access
_rfb._tcp[it]:Controllo remoto VNC

_telnet._tcp:Telnet Remote Terminal
_telnet._tcp[it]:Telnet Terminale Remoto

_timbuktu._tcp:Timbuktu Remote Desktop Control

_net-assistant._udp:Apple Net Assistant

_udisks-ssh._tcp:Remote Disk Management

# Mail

_imap._tcp:IMAP Mail Access
_imap._tcp[it]:Posta - IMAP

_pop3._tcp:POP3 Mail Access
_pop3._tcp[it]:Posta - POP3

# Printing

_printer._tcp:UNIX Printer
_printer._tcp[it]:Stampante UNIX

_pdl-datastream._tcp:PDL Printer
_pdl-datastream._tcp[it]:Stampante PDL

_ipp._tcp:Internet Printer
_ipps._tcp:Secure Internet Printer

# Multimedia

_daap._tcp:iTunes Audio Access
_daap._tcp[de]:iTunes Audio-Zugriff
_daap._tcp[it]:Accesso Audio iTunes

_dacp._tcp:iTunes Remote Control

_realplayfavs._tcp:RealPlayer Shared Favorites
_realplayfavs._tcp[it]:RealPlayer - Preferiti Condivisi

_raop._tcp:AirTunes Remote Audio
_airplay._tcp:AirPlay Remote Video

_rtsp._tcp:RTSP Realtime Streaming Server
_rtp._udp:RTP Realtime Streaming Server

_dpap._tcp:Digital Photo Sharing
_dpap._tcp[it]:Condivisione Foto

_pulse-server._tcp:PulseAudio Sound Server
_pulse-sink._tcp:PulseAudio Sound Sink
_pulse-source._tcp:PulseAudio Sound Source

_mpd._tcp:Music Player Daemon

_remote-jukebox._tcp:Remote Jukebox

# DAAP share provided by iTunes on behalf of an iPod Touch
_touch-able._tcp:iPod Touch Music Library

_vlc-http._tcp:VLC Streaming

# Communication, presence, working together

_presence._tcp:iChat Presence

_sip._udp:SIP Telephony
_sip._udp[de]:SIP-Telefonie
_sip._udp[it]:Telefonia-SIP

_h323._tcp:H.323 Telephony
_h323._tcp[de]:H.323-Telefonie
_h323._tcp[it]:Telefonia-H.323

_presence_olpc._tcp:OLPC Presence

_iax._udp:Asterisk Exchange

_skype._tcp:Skype VoIP

_see._tcp:SubEthaEdit Collaborative Text Editor

_lobby._tcp:Gobby Collaborative Editor Session

_mumble._tcp:Mumble Server

# Databases

_postgresql._tcp:PostgreSQL Server

# Development

_svn._tcp:Subversion Revision Control
_svn._tcp[it]:Subversion - Versionatore

_distcc._tcp:Distributed Compiler
_distcc._tcp[de]:Verteilter Compiler
_distcc._tcp[it]:Compilatore Distribuito

_bzr._tcp:Bazaar

# Vendor specific

_MacOSXDupSuppress._tcp:MacOS X Duplicate Machine Suppression
_ksysguard._tcp:KDE System Guard
_omni-bookmark._tcp:OmniWeb Bookmark Sharing
_acrobatSRV._tcp:Adobe Acrobat
_adobe-vc._tcp:Adobe Version Cue
_home-sharing._tcp:Apple Home Sharing
_amzn-wplay._tcp:Amazon Fire TV
_qdiscover._tcp:QNAP NAS

# Other
_pgpkey-hkp._tcp:GnuPG/PGP HKP Key Server
_ldap._tcp:LDAP Directory Server
_tp._tcp:Thousand Parsec Server
_tps._tcp:Thousand Parsec Server (Secure)
_tp-http._tcp:Thousand Parsec Server (HTTP Tunnel)
_tp-https._tcp:Thousand Parsec Server (Secure HTTP Tunnel)
_shifter._tcp:Window Shifter
_xpra._tcp:Xpra Session Server
_libvirt._tcp:Virtual Machine Manager
_device-info._tcp:Device Info

avahi-daemon static host name file

man avahi.hosts

/etc/avahi/hosts

1
2
3
4
5
6
7
8
9
10
11
12
# This file is part of avahi.
#
# This file contains static ip address <-> host name mappings. These
# can be useful to publish services on behalf of a non-avahi enabled
# device. Please bear in mind that host names are expected to be
# fully qualified domain names, i.e. ending in .local!

# See avahi.hosts(5) for more information on this configuration file!

# Examples:
192.168.0.1 router.local
2001::81:1 test.local

Avahi-Tools

avahi-utils

1
2
:~$ sudo apt-get update
:~$ sudo apt-get install avahi-utils

1. avahi-browse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
:~$ avahi-browse -all
+ eth0 IPv4 transmission Web Site local
+ eth0 IPv4 pi Web Site local
+ eth0 IPv4 pi SSH Remote Terminal local
+ eth0 IPv4 R7800 SSH Remote Terminal local
+ eth0 IPv4 pi Secure Web Site local
:~$ avahi-browse -r _https._tcp
+ eth0 IPv4 pi Secure Web Site local
= eth0 IPv4 pi Secure Web Site local
hostname = [pi.net]
address = [192.168.100.100]
port = [50443]
txt = ["org.freedesktop.Avahi.cookie=1839282170"]
:~$

2. other tools

  • avahi-publish
  • avahi-publish-address
  • avahi-publish-service
  • avahi-resolve
  • avahi-resolve-address
  • avahi-resolve-host-name
  • avahi-set-host-name

avahi-discover (GUI Tool)

1
2
3
4
5
6
7
8
:~$ sudo apt-get install avahi-discover
:~$ avahi-discover
Browsing domain 'local' on -1.-1 ...
...
Found service 'pi' of type '_https._tcp' in domain 'local' on 2.0.
Found service 'transmission' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'pi' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'pi' of type '_ssh._tcp' in domain 'local' on 2.0.

References:

  • AVAHI
  • Zeroconf
  • UPnP
---- The End Thanks ----
Donate if you like the article.