Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avahi Hostname Resolution: Is it caching somewhere?

I am using Fedora 18 with the avahi command line tools (version 0.6.31)

I use avahi-resolve-host-name to discover the IP address of units on my subnet, for testing purposes during development. I monitor the request and response with Wireshark. After one successful request and response, no further requests show up on Wireshark, but the tool still returns an IP address. Is it possible the computer/avahi daemon/something else is 'caching' the result?

The Question: I wish to send out the request packet with EVERY CALL of avahi-resolve-host-name. Is this possible?

The Reason: I'm getting 'false positives' so to speak. I try to resolve 'test1.local', and I am getting a resulting IP, but the unit is no longer located at this IP. I want the request sent every time so I can avoid seeing units at incorrect IP addresses.

like image 511
trh178 Avatar asked Aug 22 '13 18:08

trh178


1 Answers

I see that I'm a bit late to answer your question but I'm going to leave a generic answer in case someone else stumbles upon this.

My answer is based on avahi-0.6.32_rc.


Is it possible the computer/avahi daemon/something else is 'caching' the result?

Yes, avahi-daemon is caching lookup results. While this doesn't seem to be explicitly listed in features, the avahi-daemon(8) manpage tips it:

The daemon [...] provides two IPC APIs for local programs to make use of the mDNS record cache the avahi-daemon maintains.


I wish to send out the request packet with EVERY CALL of avahi-resolve-host-name. Is this possible?

Yes, it is. The relevant option is cache-entries-max (from avahi-daemon.conf(5)):

cache-entries-max= Takes an unsigned integer specifying how many resource records are cached per interface. Bigger values allow mDNS work correctly in large LANs but also increase memory consumption.

To achieve the desired effect, you can simply set:

cache-entries-max=0

This will disable the caching entirely and force avahi-daemon to reissue the MDNS packets on every request, therefore making it possible for you to monitor them.

However, I should note here that this will also render avahi pretty much useless for normal use. While avahi-daemon will be issuing lookup packets, it will be unable to store the results and every call of avahi-resolve-host-name (as well as other command-line tools, nss-mdns, D-Bus API…) will fail.

like image 102
Michał Górny Avatar answered Sep 18 '22 09:09

Michał Górny