Get IPv4 and IPv6 with one command

dig
user3645265 picture user3645265 · May 16, 2014 · Viewed 77.8k times · Source

I would like to know if it's possible to get IPv4 and IPv6 addresses with just one invocation of dig?

For example, this gives the IPv4 address:

dig hostname A

And this command will give me the IPv6 address:

dig hostname AAAA

How can I get both addresses, IPv4 and IPv6, with just one command?

Answer

user3166580 picture user3166580 · Sep 4, 2015

It may be that this has been added to dig since the question was asked, but for completeness this can be accomplished through the following query:

dig hostname A hostname AAAA +short

Source: http://linux.die.net/man/1/dig -- under the 'Multiple Queries' section