Adding DNS Record

Resource Records define data types in the Domain Name System (DNS). Resource Records identified by RFC 1035 are stored in binary format internally for use by DNS software. But resource records are sent across a network in text format while they perform zone transfers. The following record types are available in Plesk:

Note: You can add a DNS record for the specified site or to the DNS zone template. On creation of a new site, Plesk automatically generates zone file for the site or site alias based on the server template.

 

In this chapter:

Request Packet Structure

Response Packet Structure

Samples

 
Request Packet Structure

A request XML packet adding a new DNS record to Plesk database includes the add_rec operation node:

<packet>
<dns>
   <add_rec>
   ...
   </add_rec>
</dns>
</packet>

 

The add_rec node is presented by the dnsRecord type (plesk_dns.xsd). Its graphical representation is as follows:

 

Note: If the site-id and site-alias-id parameters are omitted, the DNS record will be added to the DNS zone template.

You can add multiple DNS records using a single packet. Add as many <add-rec> operations as the number of DNS records you want to add.

<dns>
   <add_rec>
   ...
   </add_rec>
...
   <add_rec>
   ...
   </add_rec>

</dns>

Note: In case of SRV record, the opt node can contain additional XML code in the following format:<Srv Protocol="" Port="" Priority="" Weight=""/>.

Important: When creating request packets, put nodes and elements in the order they follow in the packet structure.

 
Response Packet Structure

The add_rec node of the output XML packet is structured as follows:

 

 
Samples
Adding a single DNS record

This request packet adds an NS record.

<packet>
<dns>
   <add_rec>
      <site-id>1</site-id>
      <type>NS</type>
      <host>Mysite.com</host>
      <value>ns.Mysite.com</value>
 
   </add_rec>
</dns>
</packet> 

Response:

<packet>
<dns>
<add_rec>
<result>
    <status>ok</status>
    <id>17</id>
</result></add_rec>
</dns>
</packet> 
Adding multiple DNS records

This request packet adds A DNS record to DNS zone template and MX record to site with ID 1.

<packet>
<dns>
  <add_rec>
      <site-id>1</site-id>
      <type>NS</type>
      <host>Mysite.com</host>
      <value>ns.Mysite.com</value>
    </add_rec>
   <add_rec>
      <type>A</type>
      <host>example.com</host>
      <value>192.0.2.0</value>
   </add_rec>
</dns>
</packet>

Response:

<packet>
<dns>
  <add_rec>
   <result>
     <status>ok</status>
     <id>10</id>
   </result>
  </add_rec>
<add_rec>
  <result>
     <status>error</status>
     <errcode>1015</errcode>
     <errtext>Site does not exist</errtext>
  </result>
</add_rec>
</dns>
</packet>