Looking for DNS/Operational experience
Joe Abley
jabley at hopcount.ca
Mon May 11 13:24:52 CEST 2009
On 8-May-2009, at 08:28, Chris Caputo wrote:
> Not a complete command-line tool, but one could easily be made using
> this
> function I wrote... (below)
Here's one I wrote a while back in awk. You know, for that other
person in the observable universe who still likes to use awk.
# dealing with IPv6 addresses in awk is, well, awkward
# take advil now
function v6ptr(address) {
n = split(address, a, /:/);
m = split(address, b, /::/);
if (m == 2) {
# normalise :: notation
address = b[1];
for (i = 0; i < 9 - n; i++)
address = address ":0";
address = address ":" b[2];
}
# produce a dot-separated list of nybbles
nybbles = "";
split(address, a, /:/);
for (i = 1; i < 9; i++) {
for (j = 0; j < 4 - length(a[i]); j++)
nybbles = "0" (nybbles ? "." nybbles : "");
for (j = 1; j < length(a[i]) + 1; j++)
nybbles = substr(a[i], j, 1) (nybbles ? "." nybbles : "");
}
return nybbles;
}
This function was wrapped in a script that produced a full set of PTR
records from configs retrieved by rancid (I wrote parsers for IOS and
JUNOS).
Joe
More information about the ipv6-ops
mailing list