IPv6 address by hostname

user44273 picture user44273 · May 9, 2013 · Viewed 81.2k times · Source

Is there any command in Linux to get the IPv6 address of a hostname?

I tried NSLookup, but it doesn't seem to have an option to get the IPv6 address for the specified hostname or perhaps I missed it.

I have a C program that deals with IPv6 and I want to check if I am getting correct results by using a different method to obtain the IPv6 address of a host.

Answer

earl picture earl · May 9, 2013

With nslookup, just query for the AAAA record type used for IPv6 addresses:

nslookup -query=AAAA $hostname