Commit c7bc69e3 authored by tbrehm's avatar tbrehm

Updated the dns_export_to_bind.php script.

parent c15e6275
<?php
$host="IP";
$host="IP-ADRESS";
$user="root";
$password="PASSWORD";
mysql_connect($host,$user,$password) or die(mysql_error());
......@@ -22,80 +22,80 @@ function hostname2ipfunktion($tmp1, $timeout = -1) {
while($row = mysql_fetch_array($result))
{
### Hier ALLES Aktivieren bei Primary Nameserver ########################################################################################
#$tmp1 = substr($row["origin"],0,-1);
#fwrite($fx,"zone \"");
#fwrite($fx,substr($row["origin"],0,-1));
#fwrite($fx,"\" in { type master; file \"");
#fwrite($fx,substr($row["origin"],0,-1));
#fwrite($fx,"\"; };\n");
#$result2 = mysql_query("select name,type,aux,data from dns_rr where zone=$row[id];");
#exec("rm -f /var/cache/bind/$tmp1");
#$f = fopen("/var/cache/bind/$tmp1", "a+");
#fwrite($f,"\$TTL ");
#fwrite($f,$row['ttl']);
#fwrite($f,"\n");
#fwrite($f,"@ IN SOA ");
#fwrite($f,$row['ns']);
#fwrite($f," ");
#fwrite($f,$row['mbox']);
#fwrite($f," (");
#fwrite($f,"\n");
#fwrite($f," ");
#fwrite($f,$row['serial']);
#fwrite($f," ;Serial");
#fwrite($f,"\n");
#fwrite($f," ");
#fwrite($f,$row['refresh']);
#fwrite($f," ;Refresh");
#fwrite($f,"\n");
#fwrite($f," ");
#fwrite($f,$row['retry']);
#fwrite($f," ;Retry");
#fwrite($f,"\n");
#fwrite($f," ");
#fwrite($f,$row['expire']);
#fwrite($f," ;Expire");
#fwrite($f,"\n");
#fwrite($f," ");
#fwrite($f,$row['minimum']);
#fwrite($f," )");
#fwrite($f," ;Minimum");
#fwrite($f,"\n");
#fwrite($f,"\n");
#while($row2 = mysql_fetch_row($result2))
#{
#fwrite($f,$row2['0']);
#fwrite($f," IN ");
#fwrite($f,$row2['1']);
#fwrite($f," ");
#if ($row2['2']>0)
#{
#fwrite($f,$row2['2']);
#fwrite($f," ");
#}
#fwrite($f,$row2['3']);
#fwrite($f,"\n");
#}
#fclose($f);
#### ENDE Primrer Namerserver ###########################################################################################################
### Hier ALLES Aktivieren bei Secondary Nameserver ######################################################################################
$tmp1 = substr($row["ns"],0,-1);
$tmp2 = substr($row["origin"],0,-1);
$nsip = hostname2ipfunktion($tmp1);
if ($nsip == $tmp1) {
echo "$tmp2 $tmp1 Not a valid Nameserver";
echo "\n";
}
else {
$tmp1 = substr($row["origin"],0,-1);
fwrite($fx,"zone \"");
fwrite($fx,substr($row["origin"],0,-1));
fwrite($fx,"\" in { type slave; file \"");
fwrite($fx,"\" in { type master; file \"");
fwrite($fx,substr($row["origin"],0,-1));
fwrite($fx,"\"; masters {");
fwrite($fx,"$nsip; }; };");
fwrite($fx,"\n");
fwrite($fx,"\"; };\n");
$result2 = mysql_query("select name,type,aux,data from dns_rr where zone=$row[id] ORDER BY name ASC;");
exec("rm -f /var/cache/bind/$tmp1");
$f = fopen("/var/cache/bind/$tmp1", "a+");
fwrite($f,"\$TTL ");
fwrite($f,$row['ttl']);
fwrite($f,"\n");
fwrite($f,"@ IN SOA ");
fwrite($f,$row['ns']);
fwrite($f," ");
fwrite($f,$row['mbox']);
fwrite($f," (");
fwrite($f,"\n");
fwrite($f," ");
fwrite($f,$row['serial']);
fwrite($f," ;Serial");
fwrite($f,"\n");
fwrite($f," ");
fwrite($f,$row['refresh']);
fwrite($f," ;Refresh");
fwrite($f,"\n");
fwrite($f," ");
fwrite($f,$row['retry']);
fwrite($f," ;Retry");
fwrite($f,"\n");
fwrite($f," ");
fwrite($f,$row['expire']);
fwrite($f," ;Expire");
fwrite($f,"\n");
fwrite($f," ");
fwrite($f,$row['minimum']);
fwrite($f," )");
fwrite($f," ;Minimum");
fwrite($f,"\n");
fwrite($f,"\n");
while($row2 = mysql_fetch_row($result2))
{
fwrite($f,$row2['0']);
fwrite($f," IN ");
fwrite($f,$row2['1']);
fwrite($f," ");
if ($row2['2']>0)
{
fwrite($f,$row2['2']);
fwrite($f," ");
}
fwrite($f,$row2['3']);
fwrite($f,"\n");
}
fclose($f);
### ENDE Primrer Namerserver ###########################################################################################################
### Hier ALLES Aktivieren bei Secondary Nameserver ######################################################################################
#$tmp1 = substr($row["ns"],0,-1);
#$tmp2 = substr($row["origin"],0,-1);
#$nsip = hostname2ipfunktion($tmp1);
#if ($nsip == $tmp1) {
#echo "$tmp2 $tmp1 Not a valid Nameserver";
#echo "\n";
#}
#else {
#fwrite($fx,"zone \"");
#fwrite($fx,substr($row["origin"],0,-1));
#fwrite($fx,"\" in { type slave; file \"");
#fwrite($fx,substr($row["origin"],0,-1));
#fwrite($fx,"\"; masters {");
#fwrite($fx,"$nsip; }; };");
#fwrite($fx,"\n");
#}
### ENDE Secondary Nameserver ###########################################################################################################
}
fclose($fx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment