Search code examples
linuxsocketsnetwork-programmingipv6

IPv6 address by hostname


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.


Solution

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

    nslookup -query=AAAA $hostname