I had a need to add slave zone information to non-ISPConfig secondary bind name servers. For those that need to do this also, thought I'd post my patch and script here for everyone.
First, you need to setup an ssh login from the ISPConfig server to your secondary DNS server such that an ssh login is done by a key rather than using a password. I also have this set between the 'primary' secondary server (the one the ISPConfig 'talks' to) and my other 2 secondary servers.
Then, for the ispconfig_bind.lib.php file here's my patch:
--- ispconfig_bind.lib.php.orig 2005-10-10 14:17:06.661812492 -0600
+++ ispconfig_bind.lib.php 2005-10-09 19:43:38.139079442 -0600
@@ -169,6 +169,9 @@
$new_serial = date("Ymd")."01";
}
+ // set domain name for use to setup secondary
+ $domain_name = $dns["dns_soa"];
+
// Variablen zuweisen
$mod->tpl->assign( array('DNS_SOA' => $dns["dns_soa"],
'DNS_ADMINMAIL' => str_replace("@", ".", $dns["dns_adminmail"]),
@@ -296,6 +299,10 @@
$server = $mod->system->server_conf;
+ // setup domain on secondaries
+ error_log(date("Y-m-d H:i:s")." Adding $domain_name to secondary server ns1.axint.net\n",3,"/var/tmp/ispconfig.log");
+ exec("ssh
root@ns1.axint.net /root/scripts/webcp/add-dns-webcp.pl $domain_name");
+
$server_bind_user = $server["server_bind_user"];
$server_bind_group = $server["server_bind_group"];
exec("chown $server_bind_user:$server_bind_group $bind_file &> /dev/null");
On the secondary, in /root/scripts/webcp directory I have the following script for add-dns-webcp.pl - note too that this script also updates 2 other secondary servers with the new domain also):
=====================================
#!/usr/bin/perl
#############################
# Check for Correct Input #
#############################
if (!$ARGV[0]) {
chop ($timestamp = `/bin/date`);
$error = "Failed user input check. Valid arguments (domain name) not passed to script!";
$combine = $timestamp . " - " . $error;
writelog ($combine);
exit 0;
}
#############################
# Define Needed Variables #
#############################
my $domain = $ARGV[0];
my $filename = $domain . ".dns";
my $savefilename = $filename . ".old";
####################################
# Check if Domain Already Exists #
####################################
dupcheck();
sub dupcheck {
chop($dupcheck = `grep -ic $domain /var/named/named.conf`);
if ($dupcheck >= 1) {
chop ($timestamp = `/bin/date`);
$error = "Failed dupcheck. Domain, $domain, already exists in /var/named/named.conf!";
$combine = $timestamp . " - " . $error;
writelog ($combine);
# refresh since apparently the 'duped' domain has been updated on master
system("/usr/sbin/rndc reload");
exit 0;
}
}
#######################################
# Add New Domain Name to named.conf #
#######################################
open(NAMEDFILE, ">>/var/named/named.conf") or die("\n");
print NAMEDFILE <<EOF;
zone "$domain" {
type slave;
file "slaves/$filename";
masters {
38.116.133.20;
};
};
EOF
close(NAMEDFILE);
###################################
# Write confirmation to logfile #
###################################
chop ($timestamp = `/bin/date`);
open(LOG, ">>/var/log/dns-scripts.log") or die "failed on temp file open";
print LOG ("$timestamp - $domain successfully added to /var/named/named.conf.\n");
close(LOG);
###################
# Reload Namedb #
###################
system("/usr/sbin/rndc reload");
#############################################
# Add New Domain to Secondary Name Servers #
#############################################
system("/usr/bin/ssh -b 38.116.133.2 root\@ns2.axint.net /root/scripts/dns/add-dns-webcp.pl $domain $filename");
system("/usr/bin/ssh -b 38.116.133.2 root\@ns3.axint.net /root/scripts/dns/add-dns-webcp.pl $domain $filename");
exit 0;
##############################
# Write logfile Subroutine #
##############################
sub writelog {
open(LOG, ">>/var/log/dns-scripts.log") or die "failed on temp file open";
print LOG ("@_\n");
close(LOG);
};
exit 0;
=====================================
All works quite well - YMMV.
Chris
Recent comments
1 day 4 hours ago
1 day 9 hours ago
1 day 13 hours ago
1 day 15 hours ago
2 days 5 hours ago
2 days 6 hours ago
2 days 10 hours ago
2 days 17 hours ago
2 days 18 hours ago
2 days 19 hours ago