Our secondary DNS service, DNS Unlimited, has a simple API that allows users to automate the creation, deletion, and refreshing of secondary zones. This is useful if you want to integrate our service with a hosting control panel or other third-party system.
Overview
The API uses simple HTTP POST calls and can be easily implemented by anyone with some scripting knowledge. The return value of all functions is "OK" if the command succeeded and "ERROR: " followed by a description of the error if there was a problem.
API URL: https://www.dnsunlimited.com/api/
Functions
Add Secondary Zone
This function creates a new secondary zone on the system and immediately queues a zone transfer from the master server.
Required POST Values:
- action - "add_secondary_zone"
- username - your DNS Unlimited username
- password - your DNS Unlimited password
- zone - name of the zone you want to add
- master_ip - IP address of the master server (or a coma-separated list for zones with multiple masters)
Delete Zone
This function removes a zone from the system.
Required POST Values:
- action - "delete_zone"
- username - your DNS Unlimited username
- password - your DNS Unlimited password
- zone - name of the zone you want to delete
Change Master
This function changes the master IP of a zone.
Required POST Values:
- action - "change_secondary_zone_master"
- username - your DNS Unlimited username
- password - your DNS Unlimited password
- zone - name of the zone you want to edit
- master_ip - new IP address of the master server (or a coma-separated list for zones with multiple masters)
Serial Refresh
This function causes all DNS Unlimited name servers to check their serial number against the master server. If the master server has a newer serial number, a zone transfer will be initiated. This can be used to force an update when one of the servers misses a notification or to force an update immediately after making changes to a zone.
Required POST Values:
- action - "serial_refresh"
- username - your DNS Unlimited username
- password - your DNS Unlimited password
- zone - name of the zone you want to refresh
Force Transfer
This function causes all DNS Unlimited name servers to transfer a zone even if the serial number hasn't been incremented.
Required POST Values:
- action - "force_transfer"
- username - your DNS Unlimited username
- password - your DNS Unlimited password
- zone - name of the zone you want to transfer
List Secondary Zones
This function returns a list of all secondary zones associated with an account and their master server(s).
Required POST Values:
- action - "list_secondary_zones"
- username - your DNS Unlimited username
- password - your DNS Unlimited password
- format - "json" (other formats will be supported in the future)
{
"result":"success",
"zones":[
{
"name":"exampledomain1.com",
"master":[
"1.2.3.4"
]
},
{
"name":"exampledomain2.com",
"master":[
"1.2.3.4",
"2.3.4.5"
]
}
]
}
Sample Code (PHP)
The following is some simple PHP code to add a new secondary zone:
<?
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "https://www.dnsunlimited.com/api/");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// don't perform a CA check - otherwise this connection may fail with no notice on newer version of curl
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$values["username"] = "USERNAME";
$values["password"] = "PASSWORD";
$values["action"] = "add_secondary_zone";
$values["zone"] = "mynewzone.com";
$values["master_ip"] = "1.2.3.4";
// Configure CURL to POST
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $values);
// $output contains the output string
$output = curl_exec($ch);
if ($output == "OK")
echo "Command succeeded";
else
echo $output; // error!
// close curl resource to free up system resources
curl_close($ch);
?>