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.
IPv6 unicast address assignment consists of the following forms: Aggregate global unicast address. Neutral-interconnect unicast address. NSAP address.
An IPv6 normal address must have eight segments; however, a short form notation can be used in the TS4500 management GUI for segments that are zero, or those that have leading zeros. The following are examples of valid IPv6 (normal) addresses: 2001:db8:3333:4444:5555:6666:7777:8888.
Both public and private addresses exist in IPv6, but they are totally different in definition and application.
You can use the nslookup command to display IPv6 name service information. Under your user account, run the nslookup command. The default server name and address appear, followed by the nslookup command's angle bracket prompt. Quit the nslookup command by typing exit .
With nslookup
, just query for the AAAA
record type used for IPv6 addresses:
nslookup -query=AAAA $hostname
You can also use dig or host:
host -t AAAA www.google.com dig www.google.com AAAA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With