Wednesday, June 29, 2011

Reversing in-addr addresses

The following perl code will take entries that look like a.b.c.in-addr.arpa and make it into c.b.a

In the case where you have only a b.c.in-addr.arpa, then simply vi the file and remove the in-addr at the beginning of the line using [escape] to get to the edit functions and then
:%s/^in-addr.// [enter]


while () {
chomp ($_);
@sub_atom = split (/\./); #split the fields on the . character
print "$sub_atom[2].$sub_atom[1].$sub_atom[0]\n";
}

No comments: