Secondary DNS with Plesk Primary Server

Two scripts will be presented in this article:

  • Initially adding of Slave DNS zone in ClouDNS with Plesk Master
  • Plesk integration with ClouDNS

First one is written by our developers and it can be useful for initially adding Slave DNS zones in ClouDNS from your Plesk Master server.

Second one is developed by one of our customers and it can be used for integration and maintenance.

Initially adding of Slave DNS zone in ClouDNS with Plesk Master

About this script

ClouDNS has developed a PHP script especially for our customers, which are using Plesk. This script is designed to work with Master (Primary) DNS zones, hosted with Plesk panel. 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/run-root/var"); - 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 /var/named/run-root/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 Plesk 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/plesk-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.

Plesk integrations with ClouDNS

About this script

This project allows simple slave zone creation/deletion in ClouDNS for all created/deleted domains in a Plesk Onyx installation. The script is developed by one of our customers and it can be downloaded from here

How it works?

Every time a domain is created (or deleted) in Plesk, the relevant slave zone is created (or deleted) in ClouDNS.

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 here.

When you download it, place the ClouDNS.php file in the following directory:

/usr/local/psa/admin/plib/registry/EventListener/

Please, open it with your preferable PHP/text editor. You will have to edit these lines in the script:

// Get your API user settings in https://www.cloudns.net/api-settings/

private $authid = ''; // Add your API auth-id

private $authkey = ''; // Add your API auth-key

private $masterip = ''; // (Optional) Add your server primary ip here (ClouDNS will talk with this IP)

private $baseurl = 'https://api.cloudns.net/';

(Optional) Define which IP should be the master IP that ClouDNS talks to. If left blank, the script will try to determine it automatically.

Let the script do the rest and enjoy


Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more