1 |
Hi, |
2 |
|
3 |
I'm having some issues wih resolving of the loopback ip address with |
4 |
glibc's gethostbyaddr() / getnameinfo(). |
5 |
|
6 |
I have a setup with the following (abbreviated) /etc/hosts file: |
7 |
|
8 |
==8<================ |
9 |
::1 ip6-localhost |
10 |
127.0.0.1 localhost |
11 |
==8<================ |
12 |
|
13 |
When using gethostbyaddr() or getnameinfo() to resolve ip address |
14 |
127.0.0.1, the hostname "ip6-localhost" is returned, but I expected to |
15 |
see "localhost". |
16 |
|
17 |
When editing /etc/hosts and putting the 127.0.0.1 above the ::1 line, |
18 |
things work normally. |
19 |
|
20 |
It seems that glibc treats the loopback ip addresses (127.0.0.1 and ::1) |
21 |
as a special case, and returns the first entry from the hosts file for |
22 |
any loopback address, making no difference between ipv4 and ipv6. I |
23 |
would expect libc to differ between the 2 addresses, but it seems it |
24 |
doesn't. |
25 |
|
26 |
However: I find no documentation in man pages or google saying that the |
27 |
loopback addresses receive a special treatment, or that the entries in |
28 |
the hosts file should be in some special order to make things work as |
29 |
expected. |
30 |
|
31 |
I can easily reproduce this on several gentoo hosts, running |
32 |
glibc-2.10.1-r1 or glibc-2.9_p20081201-r2, and also on ubuntu 9.04 |
33 |
(libc6 version 2.9-4ubuntu6) and 9.10 (2.10.1-0ubuntu15). |
34 |
|
35 |
Could someone explain to me if this is intended behaviour, and why, as I |
36 |
tend to see this more as a bug? |
37 |
|
38 |
-- |
39 |
Regards, |
40 |
Tom |
41 |
|
42 |
PS: I tested this by using the name-addr-test utils provided by postfix |
43 |
(2.6.5 tarball, auxiliary/name-addr-test/ dir), because postfix was the |
44 |
application that showed me this strange behaviour and the test utils |
45 |
were readily available. |
46 |
|
47 |
PS2: When you want to reproduce this, no actual ipv6 connectivity is |
48 |
needed. Since glibc supports ipv6 out of the box, this should 'work' |
49 |
with any setup. |