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.
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
andsterr
.
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 ( |
|
|
|
|
|
Information about the zone on which the operation is performed. Provided if the |
|
|
|
The name of the zone. |
|
|
|
|
The name of the zone without IDN to ASCII conversion. |
|
|
|
|
Information about the SOA resource record in the zone. Provided if the |
|
|
|
Contact email |
|
||
|
Always |
|
||
|
Type of the DNS server. Always |
|
||
|
The amount of time in seconds that other DNS servers should store the record in a cache. |
|
||
|
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. |
|
||
|
Time in seconds a secondary server waits before retrying a failed zone transfer. |
|
||
|
Time in seconds before a secondary server stops responding to queries, after a lapsed refresh interval where the zone was not refreshed or updated. |
|
||
|
Time in seconds a secondary server should cache a negative response |
|
||
|
The number that identifies the state of the zone. Plesk uses the Unix time stamp of the moment when the request is sent. |
|
||
|
Always |
|
||
|
|
Information about resource records within the specified zone. Provided if the |
|
|
|
The host name of a node within the zone. |
|
||
|
The host name of a node without IDN to ASCII conversion. |
|
||
|
The type of the record. |
|
||
|
The part of the |
|
||
|
A value (IP address of host name) of the resource that will be available on the specified |
|
||
|
A value (IP address of host name) of the resource that will be available on the specified |
|
||
|
|
|
Information about the reverse (PTR) records. Provided if the |
|
|
|
The reverse record's IP address. May be IPv4 or IPv6 address. |
|
|
|
|
The reverse record's host name. |
|
Integrating Plesk with a Third-Party DNS
To switch on Plesk integration with third-party DNS:
- Put your integration script into your extension's
/plib/scripts/
directory. For example:/plib/scripts/route53.php
. - 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
- 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:
- 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