Computer Software Tech Tips

Dual-stack IPv4 and IPv6 DNS Servers (Linux)

It is inevitable that the change to IPv6 will need to be done in the near future. But in the meantime, it is also inevitable that you will need to run both IPv4 and IPv6 at the same time (at least in most scenarios). This leads to some caveats when it comes to DNS resolvers/clients.

Under normal circumstances, reputable public DNS servers running on IPv4 are able to resolve and respond with AAAA records, despite running on IPv4. This allows you to continue using your regular DNS settings.

However, you might be thinking: Why not use IPv6 DNS servers? I mean, that’s the whole point of switching, right? You can definitely use IPv6 DNS servers (and I encourage you to do so), but there is a catch, which is especially noticeable on Linux based systems.

Given you are generally familiar with DNS and network technologies in *nix, using IPv6 DNS servers should just be a snap: just add them to /etc/resolv.conf and voila, they’re enabled!

Wrong! Well, not exactly. If you simply append your IPv6 DNS servers to the list and your IPv6 does indeed route to the internet properly, you will notice a very large delay when doing DNS resolutions. This is because the IPv6 protocol takes precedence by default and it won’t be able to connect to your IPv4 DNS servers, which were listed first. If you have multiple IPv4 namservers defined, DNS resolution may just timeout and everything that depends on it will break.

The resolution is to make sure your IPv6 DNS servers are listed FIRST, ahead of your IPv4 DNS servers. It is also a good idea to add “options single-request-reopen” to have the same socket used for both IPv4 and IPv6 lookups, to work around cases of broken implementations. An example of a resolv.conf with both IPv4 and IPv6 Google Public DNS servers looks like this:

options single-request-reopen
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844

Obviously, yours may vary. Hope this helps, and happy IPv6 surfing!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.