Case Study - Global Reach, Local Touch: The Role of GeoDNS in eCommerce Expansion

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 does it work?

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/chroot/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 open your Slave DNS zone and click on the "Primary settings" button, and you will see your available IP addresses, which will be used for transfers. You must add all IP addresses of our Secondary servers for transfers and notifications in the Plesk user interface. You can follow the steps below:

  • Navigate to Tools & Settings > DNS Template.
  • Click on Transfer Restrictions Template. A screen will show all hosts to which DNS zone transfers for all zones are allowed.
  • Click on the Add Address button.
  • Add all IP addresses, which are listed in the Primary settings of your Slave DNS zone, and click OK.

Once you have entered your HTTP API credentials, IP address of your server, and you have allowed transfers and notifications to our IP addresses, save the script you can execute it.

Note: The IP addresses for allow-transfer and also-notify need to be added in the named.conf in BIND format. Example:

options {

    allow-transfer { “127.0.0.1”; };
    also-notify { “127.0.0.1”; };

}

Where you change 127.0.0.1 with your IP addresses.

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 does it work?

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


Last modified: 2023-08-28
Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more