Slave DNS with DirectAdmin Master

About this script

ClouDNS has developed a PHP script especially for our customers, which are using DirectAdmin. This script is designed to work with Master (Primary) DNS zones, hosted with DirectAdmin. You can download it from our GitHub repository.

How it works?

Once executed, the script will read all DNS zone files in the preconfigured folder on your server. Every filename, which is not a DNS zone will be written into the temporary file, configured in the script and ignored in future. All Master DNS zones which exist on your server will be created at ClouDNS as Slave DNS zones with the configured IP address as Master server.

How to configure it?

Before using this script, you must make sure that you have API access and API user at ClouDNS. To do it, please click on "API" button in your Dashboard. Next, click on "Add new user" in the upper right corner in section "API users". Once you add the API user, you have to download the script from our GitHub repository. When you download it, please open it with your preferable PHP/text editor. You will have to edit these lines in the script:

// Auth ID and Password
define("AUTH_ID", 0); - replace 0 with your API user ID
define("AUTH_PASS", "xxx"); - replace xxx with API user password
// IP address of the master server
define("MASTER_IP", "xxx.xxx.xxx.xxx"); - replace xxx.xxx.xxx.xxx with IP address of your server
// the directory with the zone files, their names are used to create the slave zones, not the content of the files
define("ZONES_DIR", "/var/named"); - DNS zone files location
// this file will contain a list of files that are not dns zone files and there won't be a request to be added the next time the script runs
define("TMPFILE", "/tmp/cloudns_invalid-zone-names.txt"); - temporary file

After you edit the script with your credentials, please add the IP addresses of our name servers in allow-transfer and also-notify in options{} at /etc/named.conf. The file should look like:

options {
     allow-transfer {
            109.201.133.61;
            185.136.96.96;
           # If you use IPv6:
            2a00:1768:1001:9::21;
            2a06:fb00:1::1:96;
      };
      also-notify {
            109.201.133.61;
            185.136.96.96;
            # If you use IPv6:
            2a00:1768:1001:9::21;
            2a06:fb00:1::1:96;
     };
};

Please have in mind that these are example IP addresses of our name servers. The servers available for you may differ and we recommend adding the IP addresses, listed on the right side of your Dashboard. Once you enter your credentials and IP address of your server, save the script and configure your DNS server, you can execute it.

Note: We recommend creating a cron job for this script in order to be executed every 30 minutes. This way it will automatically add all new DNS zones in the future. To add a cron job, please follow the steps below:

Connect to your DirectAdmin server through SSH and:

1) open the crontab with the following command:

crontab -e

2) add the following line to the end of the file:

*/30 * * * * php -f /path/to/directadmin-slave-zones-add.php

3) save the file, usually it is opened with the text editor "nano", so you can do this by Ctrl+X, Y and Enter.


Last modified: 2019-07-04
Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more