[avahi] getaddrinfo (Avahi) returning unreachable IP address for .local hostname

Jared Albers jaredaalbers at gmail.com
Thu Dec 31 10:29:25 PST 2015


Hi Guys,

I'm using 'getaddrinfo' to resolve .local hostnames in an application.
However I've encountered a scenario in which the address being returned for
a device is a self-assigned IPv4 address (169.254.X.X) that can't be
reached on any interface by the host machine. I'm assuming this because the
host machine has received an IPv4 address via the DHCP server and therefore
there is no reason to also have a self-assigned address?

It is my understanding that 'getaddrinfo' will ultimately use Avahi to
resolve .local hostnames as defined in the 'hosts:' line of the
'nsswitch.conf' file. It is also my understanding according to this old
thread (http://lists.freedesktop.org/archives/avahi/2009-May/001644.html),
that by design Avahi returns only one IP address when resolving.

As such, I'd like to better understand why 'getaddrinfo' is returning an
unreachable address for a host. Is this a bug in Avahi?

The device in question has three addresses (1 self-assigned IPv4, 1
DHCP-assigned IPv4, and 1 IPv6). If by design Avahi will only return a
single address to 'getaddrinfo', why isn't it returning a reachable address?

If I force binding a self-assigned address via 'avahi-autoipd --force-bind
eth0', then I'm able to communicate with the device. Alternatively, if I
force communication over IPv6, I'm also able to communicate with the device.

However, both of the above mentioned techniques aren't really suitable
solutions. It seems inappropriate and potentially problematic for an
application to bind a self-assigned IP address to an interface, and relying
solely on IPv6 to communicate won't work if the user has disabled IPv6
addressing (perhaps for compatibility reasons).

How do I go about fixing this issue?

-Jared
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/avahi/attachments/20151231/59249198/attachment.html>


More information about the avahi mailing list