I made couple scripts to created the RPT or reverse lookup. I'm not a programmer or scripting expert but the script help to me create the RPT. Remember run in you own risk. And modify the script according with you needs.
*** First bash to create the A records it extracts the A records from zone file. sort the records in sortarecords.dat. Remember to change the file zone and create empty files arecords.dat / sortarecords.dat
# lee archivo de registro y crea archivo ordenado por IP
#!/bin/sh
cat YOUR_FILE_ZONE | awk '{if ($2 == "A" && (substr($1,1,1)!=";") && (substr($1,1,1)!="#") ) print $1,$2,$3}' > arecords.dat
sort -u -k3 -V arecords.dat > sortarecords.dat
**** second script in PHP to create the reverse lookup. It read the sort file created in the firts scripts.
#scipts para crear los archivo necesarios para los reverse lookup.
$D= date("Ymd");
$nfile = "sortarecords.dat";
$afile = file($nfile);
# ********* IMPORTANT CHANGE TO YOU FILE PATH ***************
$path = "/xxxx/xxxxx/";
$IN = "IN";
$PRT = "PRT";
$T = '$TTL';
$R= "01";
$TTL = "$T 86400\n";
#*************** chango to you primary dns **************
$DNS = "123.123.123.1\n";
$INSOA = "@ IN SOA yourdomian. yourdomain. (\n";
$DAC = "; yyyymmddss\n";
$DAR = " $D$R ; serial number\n";
$RFT = " 10800 ; refresh after 3 hours\n";
$RAT = " 3600 ; retry after 1 hour\n";
$EPT = " 604800 ; expire after 1 week\n";
$MIT = " 86400 ) ; minimum TTL of 1 day\n\n";
# ************ CHANGE TO YOUR DOMAIN **********
$NS = " $IN NS dns.YOURDOMAIN.edu\n\n";
$COMEN = ";\n; Zone NS records\n;\n";
foreach ($afile as $aline) {
$ip = trim(substr(strrchr($aline, ' '), 1));
$DOM = explode(" ",$aline);
$DOMI = $DOM[0];
$ips = explode(".",$ip);
$pips = "$ips[0].$ips[1].$ips[2]";
$xarp = "$ips[0].$ips[1].$ips[2].arp";
$file = "$path/$xarp";
if (file_exists( "$file")){
$INAIP = " {$IN} A {$DNS}\n";
$RPRT = "{$ips[3]} {$IN} {$PRT} {$DOMI}\n";
file_put_contents($file, $RPRT, FILE_APPEND | LOCK_EX);}
else{
$new_file = "$file";
$INAIP = " {$IN} A {$DNS}\n";
$RPRT = "{$ips[3]} {$IN} {$PRT} {$DOMI}\n";
file_put_contents($file, $RPRT, FILE_APPEND | LOCK_EX);
$new_file = "$file";
$handle = fopen($new_file, 'w') or die('Cannot open file: '.$new_file); //implicitly creates file
file_put_contents($new_file, $TTL, FILE_APPEND | LOCK_EX);
file_put_contents($new_file, $INSOA, FILE_APPEND | LOCK_EX);
file_put_contents($new_file, $DAC, FILE_APPEND | LOCK_EX);
file_put_contents($new_file, $DAR, FILE_APPEND | LOCK_EX);
file_put_contents($new_file, $RFT, FILE_APPEND | LOCK_EX);
file_put_contents($new_file, $RAT, FILE_APPEND | LOCK_EX);
file_put_contents($new_file, $EPT, FILE_APPEND | LOCK_EX);
file_put_contents($new_file, $MIT, FILE_APPEND | LOCK_EX);
file_put_contents($new_file, $INAIP, FILE_APPEND | LOCK_EX);
file_put_contents($new_file, $COMEN, FILE_APPEND | LOCK_EX);
file_put_contents($new_file, $NS, FILE_APPEND | LOCK_EX);
file_put_contents($new_file, $RPRT, FILE_APPEND | LOCK_EX);
}}
?>
Reverse lookup
Issues related to applications and software problems
-
- Posts: 1
- Joined: 2016/09/20 15:10:17
Return to “CentOS 6 - Software Support”
Jump to
- CentOS General Purpose
- ↳ CentOS - FAQ & Readme First
- ↳ Announcements
- ↳ CentOS Social
- ↳ User Comments
- ↳ Website Problems
- CentOS 8 / 8-Stream / 9-Stream
- ↳ 8 /8-Stream / 9-Stream - General Support
- ↳ 8 /8-Stream / 9-Stream - Hardware Support
- ↳ 8 /8-Stream / 9-Stream - Networking Support
- ↳ 8 /8-Stream / 9-Stream - Security Support
- CentOS 7
- ↳ CentOS 7 - General Support
- ↳ CentOS 7 - Software Support
- ↳ CentOS 7 - Hardware Support
- ↳ CentOS 7 - Networking Support
- ↳ CentOS 7 - Security Support
- CentOS Legacy Versions
- ↳ CentOS 5
- ↳ CentOS 5 - General Support
- ↳ CentOS 5 - Software Support
- ↳ CentOS 5 - Hardware Support
- ↳ CentOS 5 - Networking Support
- ↳ CentOS 5 - Server Support
- ↳ CentOS 5 - Security Support
- ↳ CentOS 5 - Oracle Installation and Support
- ↳ CentOS 5 - Miscellaneous Questions
- ↳ CentOS 6
- ↳ CentOS 6 - General Support
- ↳ CentOS 6 - Software Support
- ↳ CentOS 6 - Hardware Support
- ↳ CentOS 6 - Networking Support
- ↳ CentOS 6 - Security Support