ldns icon indicating copy to clipboard operation
ldns copied to clipboard

drill does not respect IPv4/IPv6 precedence in gai.conf

Open n-st opened this issue 4 years ago • 1 comments

One of my systems can only access the IPv6 internet via a tunnel, so I have increased the precedence of IPv4 over IPv6 in /etc/gai.conf:

$ cat /etc/gai.conf
# Configuration for getaddrinfo(3).
# […]
# precedence  <mask>   <value>
#    Add another rule to the RFC 3484 precedence table.  See section 2.1
#    and 10.3 in RFC 3484.  The default is: […]
#
#    For sites which prefer IPv4 connections change the last line to
precedence ::ffff:0:0/96  100

Most programs (including, for example, dig) respect this and use IPv4 to connect to dual-stack hosts (a.iana-servers.net in this example):

$ dig example.com @a.iana-servers.net.
;; ANSWER SECTION:
example.com.		86400	IN	A	93.184.216.34
;; SERVER: 199.43.135.53#53(199.43.135.53)

drill, however, does not:

$ drill example.com @a.iana-servers.net.
;; ANSWER SECTION:
example.com.	86400	IN	A	93.184.216.34
;; SERVER: 2001:500:8f::53

The same happens in trace mode (-T), which is where I originally discovered this behaviour.

n-st avatar Mar 18 '20 22:03 n-st

Yes, dig probably uses getaddrinfo which takes along gai.conf. Drill uses a ldns_resolver for the purpose. I suppose we could use getaddrinfo too, when no alternative /etc/resolv.conf file was given...

wtoorop avatar Mar 19 '20 07:03 wtoorop