Department of Defense
High Performance Computing Modernization Program

Since IPv6 addresses are so long, creating the .IP6.ARPA reverse lookup PTR records can be tedious. Fortunately, there are several ways of automating this task.

If the AAAA record for a domain name has not yet been entered in any Domain Name Service server, the venerable nslookup command built-in to most operating systems can be used to display the reverse address, as in
nslookup 2001:480:430:dddd::246:9

… (usual command sign-on remarks) …
** server can’t find
9.0.0.0.6.4.2.0.0.0.0.0.0.0.0.0.d.d.d.d.0.3.4.0.0.8.4.0.1.0.0.2.ip6.arpa:NXDOMAIN

This works in most versions of Linux and Unix, including the Apple macOS and OS X, but it won’t work in Microsoft Windows. If nslookup has been deprecated on your system, the successor host command can often be used instead.

Tools to generate IPv6.ARPA PTR records, or even build a Berkeley Internet Name Daemon (BIND) reverse Domain Name System (rDNS) Zone record, are available on the Reverse DNS v6 website.

The ipv6calc tool is available for many versions of Linux. It is a utility written in the C programming language, and can do a variety of address manipulations.

Simple tools written in both perl and php are also available (originally developed by DREN personnel).

This perl script can be used:

#!/bin/perl

if ( $#ARGV == -1 ) {
$address = ;
chomp $address;
} else {
$address = $ARGV[0];
}

$pos = index($address, “::”);

if ($pos >= 0) {
for ($i=0; $i < length $address; $i++) {
if (substr($address, $i, 1) eq ":") {
$numcolons++;
}
}
$expansion = ":" . "0:" x (8 - $numcolons);
$address =~ s/::/$expansion/;
print "Expanded address: $address\n";
print "\n";
}

@octets = split ':', $address;

$octets[0] = reverse($octets[0]);
$octets[1] = reverse($octets[1]);
$octets[2] = reverse($octets[2]);
$octets[3] = reverse($octets[3]);
$octets[4] = reverse($octets[4]);
$octets[5] = reverse($octets[5]);
$octets[6] = reverse($octets[6]);
$octets[7] = reverse($octets[7]);

for ($i=7; $i>=3; $i--) {
for ($j=0; $j<4; $j++) {
$char = substr($octets[$i], $j, 1);
if ($char eq “”) {
print “0″;
} else {
print “$char”;
}
print “.”;
}
}
print “\b/48\n”;
print “\n”;

for ($i=7; $i>=0; $i--) {
for ($j=0; $j<4; $j++) {
$char = substr($octets[$i], $j, 1);
if ($char eq “”) {
print “0″;
} else {
print “$char”;
}
print “.”;
}
}
print “/128\n”;

 

and this php class can be used:

 

class dnsManipulation {
public $hostname;
public $ipv4;
public $ipv6;

public function __construct($hostname='',$ipv4='',$ipv6=''){
$this->hostname=$hostname;
$this->ipv4=$ipv4;
$this->ipv6=$ipv6;
$this->ptr=$this->ipv6Ptr();
}

private function ipv6Ptr() {
$arr=explode(':',$this->ipv6);
array_shift($arr);
array_shift($arr);
array_shift($arr);
$ip=implode('',$arr);
$arr2=array_reverse(str_split($ip,1));
$ptr=implode('.',$arr2);
return $ptr;
}

function getPtrRecord() {
$this->ipv6Ptr();
$str=$this->ptr." IN PTR ".$this->hostname;
return $str;
}

function getAAAARecord() {
$str=$this->hostname . " IN AAAA ".$this->ipv6;
return $str;
}
}

Top