Welcome to the home page of Charles N Wyble. Charles is a 24 year old systems guy, hacker and entrepreneur currently living in El Monte CA, with his wife of 3 years.

He is currently employed as a system engineer for Ripple TV with responsibility for a nation wide advertising network.

In his spare time he serves as Chief Technology Officer for the SoCalWiFI.net project, runs a hacker space in the San Gabriel Valley and tries to save the local economy.

Monday, May 11, 2009

[Fwd: Re: Looking for DNS/Operational experience]

Awk for the win.

Other folks posted perl solutions to the nanog list. I didn't like em. :)

This one I'll share.

Cause it's awk, and awk is cool.

-------- Original Message --------
Subject: Re: Looking for DNS/Operational experience
Date: Mon, 11 May 2009 14:24:52 +0300
From: Joe Abley <jabley@hopcount.ca>
To: Chris Caputo <ccaputo@alt.net>
CC: Steve Bertrand <steve@ibctech.ca>, ipv6-ops@lists.cluenet.de
References: <4A03B4E6.9070104@ibctech.ca>

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


No comments: