Hi, I'm having some issues wih resolving of the loopback ip address with glibc's gethostbyaddr() / getnameinfo().
I have a setup with the following (abbreviated) /etc/hosts file: ==8<================ ::1 ip6-localhost 127.0.0.1 localhost ==8<================ When using gethostbyaddr() or getnameinfo() to resolve ip address 127.0.0.1, the hostname "ip6-localhost" is returned, but I expected to see "localhost". When editing /etc/hosts and putting the 127.0.0.1 above the ::1 line, things work normally. It seems that glibc treats the loopback ip addresses (127.0.0.1 and ::1) as a special case, and returns the first entry from the hosts file for any loopback address, making no difference between ipv4 and ipv6. I would expect libc to differ between the 2 addresses, but it seems it doesn't. However: I find no documentation in man pages or google saying that the loopback addresses receive a special treatment, or that the entries in the hosts file should be in some special order to make things work as expected. I can easily reproduce this on several gentoo hosts, running glibc-2.10.1-r1 or glibc-2.9_p20081201-r2, and also on ubuntu 9.04 (libc6 version 2.9-4ubuntu6) and 9.10 (2.10.1-0ubuntu15). Could someone explain to me if this is intended behaviour, and why, as I tend to see this more as a bug? -- Regards, Tom PS: I tested this by using the name-addr-test utils provided by postfix (2.6.5 tarball, auxiliary/name-addr-test/ dir), because postfix was the application that showed me this strange behaviour and the test utils were readily available. PS2: When you want to reproduce this, no actual ipv6 connectivity is needed. Since glibc supports ipv6 out of the box, this should 'work' with any setup.