Hi, I want to use my own nameserver pair. ISPconfig is the primary nameserver. Now I want to get a list of domains to build the slave zonefiles on the secondary nameserver. Normally I do this like this, for instance on a VHCS2 Primary: PHP: header("Content-type: text/plain"); $output = ''; $SQL = "SELECT domain_name AS domain, ip_number AS ip FROM domain, server_ips WHERE domain.domain_ip_id = server_ips.ip_id ORDER BY domain_id"; $query = mysql_query($SQL); while($row = mysql_fetch_assoc($query)) { $output .= "zone \"".$row['domain']."\" IN {\n". "\ttype slave;\n". "\tfile \"/var/cache/bind/".$row['domain'].".db\";\n". "\tmasters {".$row['ip'].";};\n". "};\n\n"; } echo $output; How is this done with ISPconfig? There must be a way to retrieve those information in order to build the slave files?
You may get them from the MySQL database in ISPConfig too, they are in the dns_isp_dns database table.
What do you think about the following? PHP: <?phpheader("Content-type: text/plain");define('DB_HOST','localhost');define('DB_USER','2ndDNSUser');define('DB_PASSWD','xxxx');mysql_connect(DB_HOST, DB_USER, DB_PASSWD);$output = '';$SQL = "SELECT domain_domain AS domain, domain_ip AS ip FROM ispconfig.isp_isp_domain WHERE domain_domain != '' && domain_dns = 1 GROUP BY domain_domain ORDER BY domain_domain ASC"; $query = mysql_query($SQL);while($row = mysql_fetch_assoc($query)) { $output .= "zone \"".$row['domain']."\" IN {\n". "\ttype slave;\n". "\tfile \"/var/cache/bind/".$row['domain'].".db\";\n". "\tmasters {".$row['ip'].";};\n". "};\n\n"; }echo $output;?> It should work this way. I don't like the table you told because I don't see any possibility to strip off those subdomain entries there.
The domains in the isp_isp_domain table are not nescessarily identical with the domains where a primary DNS record exists in ISPConfig. This table contains just the alis domains of the apache configuration. Better use the dns_isp_dns table as I described above.
And how should I strip off the subdomains there? RegExp? And… in the isp_isp_domain table… there's the field "domain_dns" - shouldn't it refer to 0 if there's no DNS entry?
There are no subdomains in this table. the field dns_soa contains always the SOE (Start Of Authority) tha you will have to use for the slave records as domain. No, this field indicates if the dns_record in the dns_isp_dns table is created by the autodns feature of the co-domain or not.
I have four rows in this table. dns_soa: 1. domain-A.tld 2. domain-B.tld 3. sub.domain-A.tld 4. sub.domain-C.tld How could this be? I've activated DNS for the toplevel domain and also checked this feature for the subdomains. But… a subdomain is configured in the zonefile of an existing toplevel domain... there's no need to create an own zonefile as far as I know.
ISPConfig does not create dns_soa records for subdomains. Maybe you creted them in the dns manager manually.
OK, you're (of course) right. Another user of the server created those records. I removed them manually and told him not do so anymore So now I can use the table you recommended. Here's the code… maybe someone would like to use it too: PHP: <?php header("Content-type: text/plain"); define('DB_HOST','localhost'); define('DB_USER','username'); define('DB_PASSWD','*****'); mysql_connect(DB_HOST, DB_USER, DB_PASSWD); $output = ''; $SQL = "SELECT dns_soa AS domain, dns_soa_ip AS ip FROM ispconfig.dns_isp_dns ORDER BY dns_soa ASC"; $query = mysql_query($SQL); while($row = mysql_fetch_assoc($query)) { $output .= "zone \"".$row['domain']."\" IN {\n". "\ttype slave;\n". "\tfile \"/var/cache/bind/".$row['domain'].".db\";\n". "\tmasters {".$row['ip'].";};\n". "};\n\n"; } echo $output; ?> You can protect the directory in which the script is via mod_auth, so that nobody except the secondary ns can get your domainlist: Code: AuthName "Bind" AuthType Basic <Limit GET POST> order deny,allow deny from all allow from 123.456.789.009 </Limit> And on the secondary nameserver you can drop a script in /etc/cron.daily Code: logger "Updating secondary nameserver configuration..."; wget -q -O /etc/bind/named.conf.slave http://11.11.11.11/SDNS/index.php; /etc/init.d/bind9 reload; or for a couple or primarys to serve for: Code: #!/bin/sh logger "Updating secondary nameserver configuration..."; rm /etc/bind/named.conf.slave && touch /etc/bind/named.conf.slave; wget -q -O /tmp/bind http://11.11.11.11/SDNS/index.php && cat /tmp/bind >> /etc/bind/named.conf.slave && rm /tmp/bind; wget -q -O /tmp/bind http://22.22.22.22/SDNS/index.php && cat /tmp/bind >> /etc/bind/named.conf.slave && rm /tmp/bind; /etc/init.d/bind9 reload;