In notice my newly installed Ubuntu 10.10 always does an AAAA DNS lookup before A record lookups. Is there any way I can configure the system to do A lookups first ?
(While various browsers and other applications might contain their own resolvers, i'm talking about the ones in glibc)
23 Answers
It's the standard to prioritize IPv6 over IPv4 to allow next-generation IP take over :)
You can change this by editing the precedence blocks in /etc/gai.conf (gai stands for getaddrinfo, the standard system call for resolving host names). Just comment out the line as described in the file:
# For sites which prefer IPv4 connections change the last line to
#precedence ::ffff:0:0/96 100
A detailed explanation on gai.conf can be found in the man gai.conf(5).
My problem was the same, i had IPv6 queries made before IPv4 and they where wasting resources, so I did changed my /etc/gai.conf file as freddyb posted, but my scenario is a little bit different, my server is Natted, so IPv4 will not have precedence over IPv6 with only that line. The solution is also commenting out others lines at /etc/gai.conf so it will look like this
# For sites which prefer IPv4 connections change the last line to
precedence ::ffff:0:0/96 100
...
# For sites which use site-local IPv4 addresses behind NAT there is
# the problem that even if IPv4 addresses are preferred they do not
# have the same scope and are therefore not sorted first. To change
# this use only these rules:
#
scopev4 ::ffff:169.254.0.0/112 2
scopev4 ::ffff:127.0.0.0/104 2
scopev4 ::ffff:0.0.0.0/96 14So your server will try first ipv4 even if you are Natted!
1If you don't want IPv6 enabled at all, you can disable IPv6 to accomplish this.
if not, you can try addding
options single-requestTo your /etc/resolv.conf file. (see for gory details)
2