Add DNS Server

Use the Add DNS Server API to add a new PowerDNS Server to the Virtualizor panel. PowerDNS servers allows you to manage your zones and records. Virtualizor uses repository provided by PowerDNS itself. The VPS should have Power DNS installed on it, before it is added to the Virtualizor panel. The API response will contain “done” as “true” after the server is added successfully.

For installation, please refer Configure PowerDNS guide.

HTTP Request

https://hostname:4085/index.php?act=addpdns

Parameters

NameMethodValueDescriptionRequired
actGETaddpdnsThe action specified to perform the operation and return “done” as “true” on successful addition of the serverYes
namePOSTtextName given to the serverYes
descrPOSTtextA short description given to the serverNo
ipaddressPOSTtextIP Address to be given for connectionYes
sqlportPOSTIntPort given to the server for remote connectionYes
sqlusernamePOSTtextSpecifying username of the sql database in the PDNS serverYes
sqlpasswordPOSTtextSpecifying the SQL Password of the PDNS serverYes
sqldbPOSTtextSpecifying the SQL database nameYes
encrypt_sql_passPOST1/0This will encrypt the user passwordNo
use_sslPOST1/0The powerdns using a secure connectionNo

Sample Code

<?php

    require_once('/usr/local/virtualizor/sdk/admin.php');

    $key =  'your_api_key';
    $pass = 'your_api_pass';
    $ip = 'your_server_ip';

    $admin = new Virtualizor_Admin_API($ip, $key, $pass);

    $post = array();
    $post['name'] = 'api-test';
    $post['descr'] = 'apidesc';
    $post['ipaddress'] = '127.0.5.5';
    $post['sqldb'] = 'apidb';
    $post['sqlpassword'] = 'password';
    $post['encrypt_sql_pass'] = 1;
    $post['sqlport'] = '3306';
    $post['sqlusername'] = 'user';
    $post['use_ssl'] = 1;

    $output = $admin->addpdns($post);

    print_r(json_encode($output));

?>

Output

{
    "title": "Add DNS Server",
    "done": "true",
    "timenow": "1471398668",
    "time_taken": "0.112"
}
Was this helpful to you?