brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: dig -6 sends the query itself over IPv6, whatever record type you ask for

Dig
~/tips/tip-dns-dig-ipv6-transport

dig -6 example.com A

Forces dig to reach the resolver over IPv4 or IPv6, independent of the record type asked.

I used to mix these up. Asking for an AAAA record is a question about the name. Using -6 decides how the question travels to the resolver.

The manual says -4 indicates that only IPv4 should be used, and -6 that only IPv6 should be used. When you do not give a server, dig uses the ones in /etc/resolv.conf, and with either flag only addresses of the matching family are tried. Compare the two:

dig -6 example.com A
dig -4 example.com AAAA

The first asks for an IPv4 address while the query itself goes out over IPv6. The second asks for an IPv6 address over IPv4. Because the two things are independent, you can test the path to your resolver and the answer you get separately.

That helps when IPv6 on your network is only half working. If /etc/resolv.conf lists a resolver with an IPv6 address, this fails or times out when the IPv6 path is broken, while the same query with -4 works:

dig -6 example.com

The SERVER: line in the output shows which address answered, which is worth a look every time.

The caveat comes from the manual: if dig finds no usable server address for the family you chose, it sends the query to the local host. An answer from ::1 or 127.0.0.1 in that line means your real resolver was never asked. Give the server explicitly with @ and a name or address to rule that out.

Further reading: dig manual (-4, -6)

Going deeper: Guide: dig for beginners, look up DNS records and read the answer

More Dig tips dig +noall +answer DS example.com dig nope.iana.org @9.9.9.9 | grep -E 'status|SOA' dig +search nas dig @8.8.8.8 www.google.com +subnet=203.0.113.0/24 dig +yaml example.com A All Dig tips (36) All topics

Link