Integration with Third-Party DNS Services

By default, a Plesk server acts as a master DNS server for websites hosted on it. Alternatively, you can use external third-party DNS services to resolve domain names hosted in Plesk, for example, Amazon Route 53 (http://aws.amazon.com/route53/), DynECT (http://dyn.com/dns/dynect-managed-dns/), or Godaddy Premium DNS (http://www.godaddy.com/domains/dns-hosting.aspx). Using such services has certain advantages:

  • Reduced load on your Plesk server.
  • Improved DNS hosting reliability.

If you plan to use an external third-party DNS service, you can configure your Plesk so that it uses this service instead of its own DNS server. This will not affect website owners: From their perspective, Plesk stays a master DNS server for their domains.

To make your Plesk automatically provision DNS zones to a third-party DNS, you should write an integration script.

DNS Integration Script

The integration script is a script (written in any language supported by your server) that propagates changes made to DNS zones in Plesk UI to the selected third-party DNS service. The script should communicate with the external service by means of the service's API.

After you register the script in Plesk, the latter will pass to the script information about any change in DNS zones, for example, adding or removing resource records or entire zones.

integration_script

The script must meet the following requirements:

  • It should be able to process the input parameters given in the table below.
  • If the actions are completed successfully, the script should return errorcode0.
  • If you want your script to write information about its execution to Plesk log files, send this information to the script's stdout and sterr.

An example of the script that integrates Plesk with the Amazon Route 53 is available on our GitHub page.

Note that to use this script, you should take two steps:

  • Download the library for working with Amazon Web Services in PHP - aws.phar from http://aws.amazon.com/sdkforphp/ and place it in the same directory with the script.
  • Specify your Amazon security credentials in the script (lines 23 and 24):

    'client' => array(

    'key' => '<key>',

    'secret' => '<secret>',

    ),

Integration Script Input Parameters

Note: All parameters are of the string type.

Parameter Description Example
 

 

 

The operation that should be performed on the specified zone (create, update, or delete) or reverse (PTR) record (createPTRs or deletePTRs)

create

zone

 

 

 

Information about the zone on which the operation is performed. Provided if the command is create, update, or delete

 

name

 

The name of the zone.

d10.tld.

displayName

 

The name of the zone without IDN to ASCII conversion.

d10.tld.

soa

 

 

Information about the SOA resource record in the zone. Provided if the command is create.

 

email

Contact email

domainowner@samplemail.com

status

Always 0.

0

type

Type of the DNS server. Always master.

master

ttl

The amount of time in seconds that other DNS servers should store the record in a cache.

86400

refresh

Time in seconds how often the secondary name servers check with the primary name server to see if any changes have been made to the domain's zone file.

10800

retry

Time in seconds a secondary server waits before retrying a failed zone transfer.

3600

expire

Time in seconds before a secondary server stops responding to queries, after a lapsed refresh interval where the zone was not refreshed or updated.

604800

minimum

Time in seconds a secondary server should cache a negative response

10800

serial

The number that identifies the state of the zone. Plesk uses the Unix time stamp of the moment when the request is sent.

1363228965

serial_format

Always "UNIXTIMESTAMP"

 

rr

 

 

Information about resource records within the specified zone. Provided if the command is create or update.

 

host

The host name of a node within the zone.

www.d10.tld.

displayHost

The host name of a node without IDN to ASCII conversion.

www.d10.tld.

type

The type of the record.

CNAME

opt

The part of the value without IP or hostname.

 

value

A value (IP address of host name) of the resource that will be available on the specified host.

d10.tld.

displayValue

A value (IP address of host name) of the resource that will be available on the specified hostwithout IDN to ASCII conversion.

d10.tld.

ptr

 

 

 

Information about the reverse (PTR) records. Provided if the command is createPTRs or deletePTRs.

 

ip_address

 

The reverse record's IP address. May be IPv4 or IPv6 address.

10.52.59.29

hostname

 

The reverse record's host name.

d10.tld

Integrating Plesk with a Third-Party DNS

To switch on Plesk integration with third-party DNS:

  1. Put your integration script into your extension's /plib/scripts/ directory. For example: /plib/scripts/route53.php.
  2. Make sure that your script can be executed successfully from command line:

On Linux: plesk bin extension --exec <extension_id> <script_name>

On Windows: <plesk_dir>\bin\extension.exe --exec <extension_id> <script_name>

For example: plesk bin extension --exec route53 route53.php

  1. Setup post-install.php script to register custom DNS backend with the following command line utility:

On Linux: plesk bin server_dns --enable-custom-backend <script_execution>

On Windows: <plesk_dir>\bin\server_dns.exe --enable-custom-backend <script_execution>

For example:

$script = 'plesk bin extension --exec route53 route53.php';
$result = pm_ApiCli::call('server_dns', ['--enable-custom-backend', $script]);

To switch off Plesk integration with third-party DNS and restore the default settings:

  1. Setup the pre-uninstall.php script to disable custom DNS backend with the following command line utility:

On Linux: plesk bin server_dns --disable-custom-backend

On Windows: <plesk_dir>\bin\server_dns.exe --disable-custom-backend

For example:

$result = pm_ApiCli::call('server_dns', ['--disable-custom-backend']);

You can find a complete example of the integration on github: https://github.com/plesk/ext-route53