DNS Unlimited API Print

  • 36

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)
Return value is "OK" on success or "ERROR" followed by the error message.


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
Return value is "OK" on success or "ERROR" followed by the error message.


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)
Return value is "OK" on success or "ERROR" followed by the error message.


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
Return value is "OK" on success or "ERROR" followed by the error message.


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
Return value is "OK" on success or "ERROR" followed by the error message.


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)
Example output:

{
   "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);

?>


Was this answer helpful?

« Back