Original: http://noe.wikidot.com/automat…ndary-dns-for-ispcp-howto
It was revised for i-MSCP.
[size=x-large]1. on i-MSCP server (primary DNS)[/size]
[size=large]1.1. domain list query[/size]
Create the /var/www/imscp/gui/public/domainlist.php file with the following content:
- <?phprequire 'imscp-lib.php';$cfg = iMSCP_Registry::get('config');$db = iMSCP_Registry::get('db');$count_query = " SELECT COUNT(`domain_id`) AS cnt FROM `domain`";$query = " SELECT `domain_name` FROM `domain` ORDER BY `domain_id` ASC";$rs = execute_query($db, $count_query);$records_count = $rs->fields['cnt'];$rs = execute_query($sql, $query); if ($rs->rowCount() == 0) { echo "//NO DOMAINS LISTED"; } else { echo "//$records_count HOSTED DOMAINS LISTED ON $cfg->SERVER_HOSTNAME [$cfg->BASE_SERVER_IP]\n"; echo "//CONFIGURATION FOR MAIN DOMAIN\n"; echo "zone \"$cfg->BASE_SERVER_VHOST\"{\n"; echo "\ttype slave;\n"; echo "\tfile \"/var/cache/bind/$cfg->BASE_SERVER_VHOST.db\";\n"; echo "\tmasters { $cfg->BASE_SERVER_IP; };\n"; echo "\tallow-notify { $cfg->BASE_SERVER_IP; };\n"; echo "};\n"; while (!$rs->EOF){ echo "zone \"".$rs->fields['domain_name']."\"{\n"; echo "\ttype slave;\n"; echo "\tfile \"/var/cache/bind/".$rs->fields['domain_name'].".db\";\n"; echo "\tmasters { $cfg->BASE_SERVER_IP; };\n"; echo "\tallow-notify { $cfg->BASE_SERVER_IP; };\n"; echo "};\n"; $rs->moveNext(); } }echo "//END DOMAINS LIST\n";?>
Change the owner of the file:
To protect the domainlist.php create the /var/www/imscp/gui/public/.htaccess file with following content:
After that only the secondary DNS server can reach the file.
[size=large]1.2. BIND9 setup[/size]
Go to the directory of bind9 in order to create the communication key between the two bind9:
To speed up the generation type something on the keyboard!
After the key was created to view the key in base64 encoding form type the following command:
It will be neccessary later!
Append the following content to the /etc/bind/named.conf.options file (after the options {} content)
After that restart the BIND9:
[size=x-large]2. On the secondary DNS server[/size]
[size=large]2.1. BIND9 setup[/size]
Append the following content to the /etc/bind/named.conf.local file:
Append the following content to the /etc/bind/named.conf.options file (after the options {} content)
After that restart the BIND9:
Let's test to get the domain list from the primary server:
If we can see the DNS-zone definitions everything works well and we can set the automatic update by cron.
Create the /etc/cron.d/imscp_dns_update file with the following content:
So the DNS-zone definitions are automatically updated every 5 minutes from the primary server. If we do everything properly, we can see the <domain>.db files in the /var/cache/bind/ directory.
Finally hurray!