On Wed, 16 Jun 2010, John Haxby wrote:
On 15 June 2010 15:06, Dag Wieers <[email protected]> wrote:
getent hosts testsys
getent hosts 1.2.3.4
getent hosts does some strange things. It tries the key against an IPv6
address, an IPv4 address, an IPv6 name and finally an IPv4 name. As you
correctly deduced. the DNS lookup happens when you're doing the IPv6 lookup.
You can restrict the query to IPv4 only with "getent ahostsv4 <key> ". That
uses getaddrinfo() rather than inet_pton, gethostbyaddr and gethostbyname2
and also restricts the address famility to IPv4.
If you're doing things programatically (rather than using getent) you need
to do a similar thing. IPv6 lookups happen regardless of whether you can
actually use an IPv6 socket.
Right, still the behavior seems erratic and causes nscd to not cache
anything when your DNS is unavailable and leads to DNS timeouts. Something
we would like to avoid.
If you look at the following output you can see the inconsistency, only
when doing a hosts database lookup you see the ipv6 DNS request being
made. Even when specifying ahostsv4 it doesn't do it because it is
resolved by /etc/hosts, and I assume ahostsv6 fails because ipv6 is
disabled.
[...@moria ~]$ strace -e connect getent hosts localhost
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1
ENOENT (No such file or directory)
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1
ENOENT (No such file or directory)
connect(3, {sa_family=AF_INET, sin_port=htons(53),
sin_addr=inet_addr("212.224.255.252")}, 28) = 0
127.0.0.1 localhost.localdomain localhost
[...@moria ~]$ strace -e connect getent ahostsv4 localhost
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1
ENOENT (No such file or directory)
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1
ENOENT (No such file or directory)
127.0.0.1 STREAM localhost.localdomain
127.0.0.1 DGRAM
127.0.0.1 RAW
[...@moria ~]$ strace -e connect getent ahostsv6 localhost6
[...@moria ~]$ strace -e connect getent -s files hosts localhost
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1
ENOENT (No such file or directory)
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1
ENOENT (No such file or directory)
127.0.0.1 moria localhost.localdomain localhost
[...@moria ~]$ strace -e connect getent -s dns ahostsv4 localhost
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1
ENOENT (No such file or directory)
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1
ENOENT (No such file or directory)
connect(3, {sa_family=AF_INET, sin_port=htons(53),
sin_addr=inet_addr("212.224.255.252")}, 28) = 0
[...@moria ~]$ strace -e connect getent -s dns ahostsv6 localhost6
--
-- dag wieers, [email protected], http://dag.wieers.com/ --
[Any errors in spelling, tact or fact are transmission errors]
_______________________________________________
rhelv5-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/rhelv5-list