[dns-operations] how to use dig command display integral IPV6 address

Viktor Dukhovni ietf-dane at dukhovni.org
Fri Dec 7 16:26:52 UTC 2018


> On Dec 7, 2018, at 10:39 AM, Stephane Bortzmeyer <bortzmeyer at nic.fr> wrote:
> 
> I don't think dig has a way to do that. It would be against RFC 5952.

Post-processing in Perl/Python/... works, here's the Perl version:

  $ dig +short -t aaaa www.ietf.org |
    perl -lne '
      use Socket qw(inet_pton AF_INET6);
      $a = inet_pton(AF_INET6, $_) or next;
      ($a = unpack("H*", $a)) =~ s{(....)(?=.)}{$1:}g;
      print $a'
  2606:4700:0010:0000:0000:0000:6814:0055
  2606:4700:0010:0000:0000:0000:6814:0155

Or without the colons:

  $ dig +short -t aaaa www.ietf.org |
    perl -lne '
      use Socket qw(inet_pton AF_INET6);
      $a = inet_pton(AF_INET6, $_) and print unpack("H*", $a);'
  26064700001000000000000068140055
  26064700001000000000000068140155

-- 
	Viktor.




More information about the dns-operations mailing list