Today I was asked for a way of reversing an IPv6 address. We all know that, unlike IPv4, the IPv6 addresses are hard to reverse, because you need to dot-separate each “nibble” (4 bits, an hexadecimal single character), obtaining a domain name of 34 levels depth! (32 plus 2 of the ip6.arpa suffix).
I always use dig for this, but I also tried two more, just for research purposes!
Surely there’re scripts and tools that make it a simple command, but using what I have in hand, how hard could it be using my IDE of choice, vi?
That’s 45 seconds of work! (and to be fair, is vi with some linux base commands)
Next I used a library in perl, Net::IP:
$ perl -MNet::IP -E '$i=new Net::IP("2800:3f0:4003:c03::6a"); say $i->reverse_ip;'
A surprising 24 seconds mark!
And finally, my tool of choice: sending a dig query with -x. It doesn’t matter the answer, just the “question section” line:
And of course dig is the undisputed winner, with 4 seconds ;)
UPDATE: of course it had to be a better tool and didn’t know!
Thanks to JPMens on Mastodon now I know of “arpaname”, which just
accepts a number and gives the reverse almost instantaneously (I
didn’t like the uppercasing though, so had to pipe it to
awk '{print tolower($0)}'
to have an equivalent output).
Next post: La Ceremonia de Firma de la Raíz del DNS
Previous post: Limit to the number of iterations in NSEC3