TL;DR – If you’re using a dual-stacked machine and have multiple search domains in your resolv.conf, you can potentially end up resolving multiple addresses which correspond to completely different hosts.

At OpenDNS we care a lot about DNS and issues related to DNS resolution, so when we came across some odd behaviors in resolving hosts on dual-stacked machines (meaning they have both IPv4 and IPv6 addresses), we wanted the world to know. Hopefully the following can help prepare users for some of the gotchas and maybe even inspire certain operating-system maintainers to release a few patches.

Our test environment was fairly straight forward, we set up an authoritative nameserver with 3 different sub-domains defined. We gave the first sub-domain an IPv4 address only, the second an IPv6 address only, and the third was given both IPv4 and IPv6 addresses.

# Domain  TTL  Type  Address  30  a  30  aaaa  2001:470:b:1fc::1  30  a  30  aaaa  2001:470:b:1fc::2

We then went onto four different machines with four different operating system, configured them to be dual-stacked, and configured their resolv.conf to have network{1,2,3} in their search domains:

# configuration syntax varies across OS’s

We then ran tcpdump to watch the outbound DNS requests and used a simple wrapper program around getaddrinfo() to perform the lookups.

What should happen when we try to resolve the hostname “gw”?

We would expect, if an OS is following the “prefer IPv6” standard that we should get “2001:470:b:1fc::1” (the IPv6 address of We expect this because according to the specified search domains, the OS should go through the search domains in the order network1, network2, network3, but also because the OS should be preferring IPv6.

For OS’s that follow the Happy-Eyeballs RFC / style we would expect to get “” as this would be the first thing that would be found as defined by the search domains order. So let’s have a look at what the OS’s actually did…

OSX – 10.9.3

# sudo tcpdump -n -s 1500 -i en0 udp port 53 > 4769+ A? (41) > 4925+ AAAA? (41) > 4769 1/0/0 A (57) > 4925 0/0/0 (41) > 3489+ AAAA? (41) > 3489 1/0/0 AAAA 2001:470:b:1fc::1 (69)

From the tcpdump output we can see that OSX has decided to send out A (IPv4) and AAAA (IPv6) requests to the first search domain ( simultaneously. When the A request gets a valid response, but the AAAA response receives a NODATA response, the OS continues down the search domains list to try and resolve a AAAA answer. The OS then requests a AAAA from network2.opendns, which responds with a valid AAAA answer. Lets now look at what was actually returned by the getaddrinfo call:

# ./getaddrinfo gw
AF_INET6 (IPv6) - SOCK_STREAM - IPPROTO_TCP - 2001:470:b:1fc::1

This where things get odd, the OS’s underlying resolving library has returned us two answers to our request for the domain “gw”, but the actual corresponding host behind each IP are completely different. The IPv4 “” is for and the IPv6 “2001:470:b:1fc::1” answer is for “”. At this point, it would be up to the calling application to choose which answer or protocol it prefers, but there is no indication that these correspond to completely different hosts… That’s bad…

Linux – Ubuntu 12.04 > 1096+ AAAA? (41) > 1096 0/0/0 (41) > 51327+ AAAA? (41) > 51327 1/0/0 AAAA 2001:470:b:1fc::1 (69) > 50275+ A? (41) > 50275 1/0/0 A (57)
AF_INET6 (IPv6) - SOCK_STREAM - IPPROTO_TCP - 2001:470:b:1fc::1

Linux doesn’t fair much better. Although it does start resolving for an IPv6 host first, once it’s found one, it continues to resolve an IPv4 address as well. Also, just like OSX, Linux’s getaddrinfo() returns addresses for both and

FreeBSD 10.* > 44935+ A? (41) > 44935 1/0/0 A (57) > 44936+ AAAA? (41) > 44936 0/0/0 (41)

FreeBSD restores our faith in resolving principals. From the tcpdump we can see that it has tried to resolve both an A and AAAA record for the first domain in the resolve search list, and because it found a match (on the A record) it stops there. The getaddrinfo() has returned only the matching IPv4 address.

If we repeat this test but move the search domain of “network2” ahead of “network1”, we can see that now (correctly) only the IPv6 address is returned. > 44935+ A? (41) > 44935 NXDomain 0/1/0 (116) > 44936+ AAAA? (41) > 44936 1/0/0 AAAA[|domain]
AF_INET6 (IPv6) - SOCK_STREAM - IPPROTO_TCP - 2001:470:b:1fc::1

If the test is then repeated with “network3” as the first search domain, we (correctly) get both the IPv4 and IPv6 addresses of

AF_INET6 (IPv6) - SOCK_STREAM - IPPROTO_TCP - 2001:470:b:1fc::2

Windows 8.1

Microsoft’s current offering also gets a passing grade for dual-stacked search domain use. Windows 8.1 performed exactly the same as FreeBSD in all tests scenarios, giving all the expected answers. This shouldn’t come as a big surprise as most of the Windows network stack is derived from BSD source, and we’d be surprised if the resolving libraries weren’t used as well.

As we can see from the above results, resolving domains on a dual-stacked machine that uses search domains can lead to some confusing results. The recent OS offerings from OSX and Ubuntu leaves the onus on the calling application to decide how to deal with the coming dual stacked world. Fortunately though, the offerings from FreeBSD and Windows do show that some implementations foresaw this issue and implemented the expected functionality.

This post is categorized in: