Some notes about AvahiFri 30 December 2011 by admin
Topic clearly informs that it's my first english language post, so be patient to all my language mistakes ;) Let's get back to main topic Avahi I would call that it's daemon which I have to disable after fresh install of RHEL compatible distros, but what's more about it ?
Couple weeks ago I stand face into a problem to discover my headless desktops in not management (by me) network. I tried to write some script to cope with this problem, but luckily I realized that I heard something called zeroconf project which relates me to Avahi implementation. Avahi deals with concepts mDNS,DNS-SD. The first one mDNS it's multicast DNS helps us to determine an IP address without using centralized DNS, so technically we send a multicast query message using:
MAC address 01:00:5E:00:00:FB IPv4 address 18.104.22.168 or IPv6 address FF02::FB UDP port 5353
in reply we get the hostnames of discovered hosts in .local domain. To get the things done in Avahi we simply start:
service messagebus start service avahi start
avahi is tightly integrated with messagebus/d-bus that's why we have to start it first. To discover hosts in our network:
$ avahi-browse -t -r -a
and now we get extensive info about the discovered hostnames including services running on them. Keyword services stand against the second concept of zeroconf DNS-SD. It uses DNS SRV,PTR,TXT records to advertise Service Instance Names. To setup sample DNS-SD record we can use bundled one in Avahi:
# rpm -ql avahi | grep ".service$"
simply copy one of them into /etc/avahi/services and edit it (simple xml file), then restart avahi and rerun avahi-browse. The second way to publish service is to use avahi-publish:
# avahi-publish -s ftp _ftp._tcp 21 &
list of known service types is described in http://www.dns-sd.org/ServiceTypes.html
So when you get hostnames and services you can send it via d-bus to particular application that's why avahi is tighly integrated with messagesbus. It also worth to mention about link local address http://en.wikipedia.org/wiki/Link-local_address it gives you the last brick to setup zeroconf machine (no DHCP,DNS). Avahi is responsible to maintain link local address (well-known ipv4 169.254.0.0/16) via avahi-autoipd.
Of course Avahi zeroconf implementation it's not prepared for large network, it's suitable for small setups. Using mDNS you have to also realized that's pretty easy to forge some DNS answer to i.e. to become printer.local ;)
More info about Avahi on project website: http://avahi.org/ or simply:
$ man -k avahi