Use the Add DNS Records API to add a DNS record on the PowerDNS server database. These are name resolution record for resolving names to IP addresses. This API allows to define multiple types of DNS records viz. A record, CNAME record, MX record, TXT record, NS record and AAAA record. The API response will contain "done" as "true" on successful addition of the record.
HTTP Request
https://hostname:4085/index.php?act=add_dnsrecord&pdnsid=PDNSID
Parameters
Name Method Value Description Required act GET add_dnsrecord The action will edit a dns record Yes dns_type POST text The type of dns record to be added valid values are 'type_rdns' and 'type_dns' Yes zone_name POST text The name of the zone No host POST text The hostname of the dns record Yes record_type POST text The type of record that is being edited refer below table for valid values Yes content POST contect The content of the dns record Yes prio POST Int The priority of the dns record No ttl POST Int The value for which the record will be active Yes domain POST text The Fully Qualified domain name (Required if dns_type is type_rdns) which will be resolved to the below dns_ip No dns_ip POST text The dns server IP (Required if dns_type is type_rdns) No
Record Type
Name Value a_record A (host) cname_record CNAME (Aliases) mx_record MX (Mail Exchange) txt_record TXT (Text) ns_record NS (Name Servers) aaaa_record AAAA (IPV6 Hosts)
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['pdnsid'] = 6;
// $post['dns_type'] = 'type_rdns' ;
$post['dns_type'] = 'type_dns';
$post['record_type'] = 'A';
$post['host'] = '35.189.107.in-addr.arpa';
$post['content'] = '4.2.2.2';
$post['ttl'] = 90000;
$output = $admin->add_dnsrecord($post);
print_r(json_encode($output));
?>
Output
{
"title": "Virtualizor",
"done": "true",
"timenow": "1480924964",
"time_taken": "0.166"
}