📜 ⬆️ ⬇️

What is Zeroconf and what it is eaten with

I, like the old Linux user, when I first installed Ubuntu and saw the unfamiliar word avahi , of course, I immediately looked at google . He stumbled over several links, saw other incomprehensible words, such as zeroconf , multicast dns , bonjour . Immediately I realized that this is some kind of muddy technology from Apple and I don’t need anything.

However, with the growth of the local network inside my apartment, I thought that it would be nice to be curious how to adapt zeroconf to make your life easier.

Let's understand the terminology:
  1. Zeroconf is a protocol developed by Apple and designed to solve the following problems:
    • selection of the network address for the device;
    • finding computers by name;
    • discovery of services such as printers.
  2. Avahi is an open and free implementation of the zeroconf protocol.
  3. Bonjour is Apple's open-source implementation of the zeroconf protocol.


To assign IP addresses to devices, zeroconf uses RFC 3927 . The standard describes the assignment, the so-called link-local addresses, from the range of 169.254.0.0/16 . The technology is called IPv4 Link-Local or IPv4LL .
')
For name resolution (name resolving) Multicast DNS protocol is used or mDNS is shortened. It allows the device to select a name in the .local zone . It works almost like a normal DNS, but with nuances. Each computer keeps records of its zone ( A , MX , SRV ) itself and itself serves requests to them. When a computer wants to know a zone record, say, determine the IP address by name (get an A record for a given zone), it contacts multicast address 224.0.0.251 . Accordingly, the request is received by all computers in the local network, and the one who stores the zone for the name that interests us is answered.

For the search and discovery of services, the DNS protocol based Service Discovery or DNS-SD is used . In order to advertise which services are available on the device, DNS records like SRV , TXT , PTR .

How to make it all work on Linux? Much easier than it seems. We will analyze in steps:
  1. avahi-daemon , avahi-autoipd , libnss-mdns . If you own Ubuntu , then most likely these packages are already installed.
  2. Enable IPv4LL. This step is completely optional. If you have any IP address that is normally routed on the local network, then IPv4LL is unnecessary and even harmful, as by standard, routers should not forward packets with link-local addresses ( 169.254.* ). In other words, most likely it will not be possible to forward the Internet through NAT (I did not succeed). But if you have already decided, it is enough for the network interface of the local network, in the file /etc/network/interfaces to put the type ipv4ll . Something like this:
      iface eth0 inet ipv4ll 

    Next, you can do sudo invoke-rc.d networking restart or even reboot ( avahi-autoipd will not install the address 169.254.* On the interface if there is already another IP address, and after sudo invoke-rc.d networking restart it’s likely will not disappear anywhere).
  3. Allow the firewall to pass UDP packets on port 5353 at 224.0.0.251 (this is necessary for mDNS to work properly) on interfaces looking to the local network.

At this setting can be considered complete. What bonuses will you get after this? I list: all computers will receive names in the * .local domain, without unnecessary gestures on your part; Gajim or Empathy jabber-clients will show all interlocutors in the local network; Rhythmbox will share all music; Ekiga will allow to find and call everyone who has it running in LAN; PulseAudio will be able to find all published audio devices on the network; Well, much, much more. You can get acquainted with the list of programs that support avahi .

A few comments.
  1. You can view the announced services on the network using the avahi-browse --all command. It will also show in realtime the connection and disconnection of these services.
  2. If you have a firewall, then services can see each other, but not communicate, if the ports necessary for them are closed.
  3. With the avahi-dnsconfd you can clone /etc/resolv.conf to all computers on a local network.
  4. Be sure to vote for the idea of embedding the NFS + Zeroconf bundle in Gnome.

Source: https://habr.com/ru/post/66020/


All Articles