Hi,

I can confirm this behaviour. While one can work around it using
"options inet6" in /etc/resolv.conf, a better solution is converting hostname
to use getaddrinfo() instead of gethostbyname(). getaddrinfo() is the
preferred function to resolve addresses, see for example this entry from Ulrich
Drepper:

http://udrepper.livejournal.com/16116.html

So, after applying the patch I attached, the new version of hostname correctly
handles my IPv6-only host:

$ hostname
x200
$ hostname -f
No address associated with name
$ hostname -i
192.168.1.42
$ ./hostname-patched
x200
$ ./hostname-patched -f
x200.zekjur.net
$ ./hostname-patched -i 
2001:4d88:1008:4242:21f:16ff:fe06:3aab

Note that using getaddrinfo() removes old cruft, that is, the aliases field
returned by gethostbyname(). Thus, hostname -a will not work anymore. I’ve
documented this in the manpage and left the option available for backwards
compatibility.

Please apply the attached patch,

Thanks and best regards,
Michael

Attachment: hostname-ipv6.patch
Description: Binary data

Reply via email to