# server_dns: DNS Zone Template

The `server_dns` utility is used to manage the Plesk server’s DNS zone template through CLI. By using this utility, you can perform the following tasks:

- adding resource records to or replacing already existing resource records with new ones in the Plesk server’s DNS zone template.
- specifying the status to be set for a domain’s DNS zone upon creation of a domain.
- updating the Start-of-Authority (SOA) record for the DNS zone template.
- setting the Plesk name server DNS zone preferences regarding recursive DNS queries from different types of hosts.
- managing the Access control list (ACL records).

## Usage

    server_dns <command> [
    <option_1> [<param>]
    [<option_2> [<param>]]
    ... [<option_N> [<param>]]
    ]

## Example

The following command adds the following two resource records to the domain DNS zone template, while removing all pre-existing resource records from the domain DNS zone template:

- new `MX` resource record <domain> specifying mail.<domain> as the mail exchanger for the record, and setting the mail exchanger’s priority to 15.

- new `NS` resource record <domain> setting domain ns.<domain> as the name server.

      plesk bin server_dns --set "MX,"",mail.<domain>,15;NS,"",ns.<domain>"

## Commands

Command | Parameter | Description | Example
--- | --- | --- | ---
`--add` or `-a` |  | Adds a resource record to the Plesk server’s domain DNS zone template. If a record already exists, the command returns code `2`. | To add an `MX` resource record mail.<domain> to the domain DNS zone template and specify mail exchanger mail.<domain> and set the mail exchanger priority to 35 for the record:
    plesk bin server_dns --add -mx "" -mailexchanger "mail.<domain>" -priority 35
or
    plesk bin server_dns -a -mx "" -mailexchanger "mail.<domain>" -priority 35
`--set` or `-s` | `"<record_1>;<record_2>;...<record_N>"` where `<record> =` `NS,<<subdomain-prefix>|>,<<name-server-FQDN>|<prefix>.<domain>.>` `A,<<subdomain-prefix>|>,<<IP-address>|<ip>>` `MX,<<subdomain-prefix>|>,<<mail-exchanger-name>|<prefix>.<domain>.>,<priority>` `PTR,<<IP-address>|<ip>>,<<subdomain-prefix>|>,<subnet_mask>` `CNAME,<<subdomain-prefix>|>,<<canonical_domain_name>|<domain>.>` `SRV,<_service>.<_tcp|_udp>.<<subdomain-prefix>|>,<target_host>,<priority> <weight <port>` `TXT,<<subdomain-prefix>|>,<text>` | Adds specified resource records to and removes all pre-existing resource records from the Plesk server’s domain DNS zone template. For more details, consult descriptions of the options in the following table for adding resource records of respective types individually. | To add the following DNS zone template file to Plesk (for the presentation sake, we added the “.<domain>.” part to hosts like “ns.<domain>.” which normally are just “ns” in real zone files): HOSTRR typeVALUE <domain>.NSns.<domain>. ns.<domain>.A<ip> <domain>.A<ip> webmail.<domain>.A<ip> <domain>.MX10 mail.<domain>. mail.<domain>.A<ip> ftp.<domain>.CNAME<domain>. <ip>/24PTR<domain>. <domain>.TXTf1 +a +mx -all _SIP._tcp.megadomain.<domain>.SRV5 25 12 example.com.
    plesk bin server_dns --set 'NS,,ns.<domain>.;A,ns,<ip>;A,,<ip>;A,webmail,<ip>;MX,,mail.<domain>.,10;A,mail,<ip>;CNAME,ftp,<domain>.;PTR,<ip>,,24;TXT,,v=spf1 +a +mx -all;SRV,_SIP._tcp.megadomain,example.com,5 25 12;'
or.
    plesk bin server_dns -s 'NS,,ns.<domain>.;A,ns,<ip>;A,,<ip>;A,webmail,<ip>;MX,,mail.<domain>.,10;A,mail,<ip>;CNAME,ftp,<domain>.;PTR,<ip>,,24;TXT,,v=spf1 +a +mx -all;SRV,_SIP._tcp.megadomain,example.com,5 25 12;'
`--update-server` or `-u` |  | Updates the Plesk server’s DNS server settings. | To enable support for recursive DNS queries for hosts on the local network only:
    plesk bin server_dns -u -recursion localnets
`--update-soa` |  | Updates the SOA record settings the Plesk server’s domain DNS zone template. | To set the TTL parameter to 5 hours for the SOA record for the domain DNS zone template:
    plesk bin server_dns --update-soa -soa-ttl 5H
`--info` or `-i` |  | Displays the list of DNS server settings. | To view the list of DNS server settings:
    plesk bin server_dns --info
or
    plesk bin server_dns -i
`--enable-custom-backend` | `<path to the integration script>` | Enables Plesk integration with a third-party DNS using the specified script for the integration. | To switch on Plesk integration with a third-party DNS service:
    plesk bin server_dns --enable-custom-backend /home/route53.php
`--disable-custom-backend` |  | Disables Plesk integration with a third-party DNS. | To switch off Plesk integration with a third-party DNS service:
    plesk bin server_dns --disable-custom-backend
`--help` or `-h` |  | Displays help on the use of the utility. | To view help on the use of the dns utility:
    plesk bin server_dns --help
or
    plesk bin server_dns -h

## Options

Option | Parameter | Description | Example
--- | --- | --- | ---
`-recursion` | `any|localnets|localhost` | Sets the Plesk name server DNS zone preferences: `any` - will support recursive DNS queries for any requesting host. `localnets` - will support recursive DNS queries for any host on the local network only. `localhost` - will support recursive DNS queries for the local host only Used with the `--update-server` command only. | To enable support for recursive DNS queries for hosts on the local network only:
    plesk bin server_dns -u -recursion localnets
`-status` | `enabled|disabled` | Sets the status of a domain’s DNS zone when the domain DNS zone is created during domain creation. Only newly created domains will inherit the DNS zone status. Used with the `--update-server` command only. | To disable domain DNS zones for newly created domains:
    plesk bin server_dns -u -status disabled
`-add-acl` | `<IP_address_1>[[/<subnet_mask>],<IP_address_2>[/<subnet_mask>],...<IP address_N>[/<subnet_mask>]]` | Adds host or network IP addresses to the Access Control list (ACL). | To add records 192.0.2.78 and 192.0.2.0/24 to the ACL:
    plesk bin server_dns -u -add-acl 192.0.2.78,192.0.2.0/24
`-a` | `<subdomain_name>` | Specifies the `A` type resource record for a subdomain in Plesk server’s domain DNS zone template. Used with the `--add`. Requires the `-ip` option. | To add an `A` resource record sample.<domain> (specifying a placeholder for a domain IP address for the record) to the domain DNS zone template:
    plesk bin server_dns -a -a sample -ip "<ip>"
`-aaaa` | `<subdomain_name>` | Specifies the `AAAA` type resource record for a subdomain in Plesk server’s domain DNS zone template. Used with the `--add`. Requires the `-ip` option. |
`-ip` | `<IP_address>|"<ip>"` | Specifies an IP address or a placeholder for a domain’s IP address for creating a resource record in Plesk server’s domain DNS zone template. Used only with the `--add` command. |
`-ns` | `<subdomain_name>|""` | Specifies the `NS` type resource record in the Plesk server’s domain DNS zone template. Used only with the `--add` command. Requires the `-nameserver` option. | To add an `NS` resource record <domain> specifying domain name <domain> as the name server to the DNS zone template:
    plesk bin server_dns -a -ns "" -nameserver "ns.<domain>"
`-nameserver` | `<domain_name>|"[<subdomain_name>.]<domain>"` | Specifies the name of a nameserver or a placeholder for creating an `NS` type resource record in the Plesk server’s domain DNS zone template. |
`-mx` | `<subdomain_name>|""` | Specifies the `MX` type resource record in the Plesk server’s domain DNS zone template. Used with the `--add` command only. Requires the `-mailexchanger` option. | To add an `MX` resource record <domain> specifying domain name mail.<domain> as the mail exchanger for the record, and setting the mail exchanger’s priority to 15 to the domain DNS zone template:
    plesk bin server_dns -a -mx "" -mailexchanger "mail.<domain>" -priority 15
`-mailexchanger` | `<domain_name>|"[<subdomain_name>.]<domain>"` | Specifies the name of a mailexchanger or a placeholder for creating an `MX` type DNS record in the Plesk server’s domain DNS zone template. |
`-priority` | `<number>` | Specifies the mail exchanger priority for creating an `MX` type DNS record in the Plesk server’s domain DNS zone template. |
`-cname` | `<subdomain_name>|""` | Specifies the `CNAME` type resource record in the Plesk server’s domain DNS zone template. Used with the `--add` command only. Requires concomitant use of the `-canonical` option. | To add a `CNAME` type resource record subdom.<domain> for a canonical name <domain> to the domain DNS zone template:
    plesk bin server_dns -a -cname subdom -canonical "<domain>"
`-canonical` | `<domain_name>|[<subdomain_name>.]<domain>"` | Specifies a canonical name or a placeholder for creating a `CNAME` type DNS record in the Plesk server’s domain DNS zone template. |
`-ptr` | `<subdomain_name>|""` | Specifies the `PTR` type resource record in the Plesk server’s domain DNS zone template. Used with the `--add` command only. Requires concomitant use of the `-subnet` option. | To add a `PTR` type DNS record “<ip>”/16 for <domain> to the domain DNS zone template:
    plesk bin server_dns -a -ptr "" -subnet "<ip>"/16
`-subnet` | `<IP_address>/<subnet_mask>|"<ip>"/<subnet_mask>` | Specifies an IP address and a subnet mask or a placeholder for creating a PTR type DNS record in the Plesk server’s domain DNS zone template. |
`-srv` | `''|<subdomain_name>` | Specifies the SRV type resource record in the Plesk server’s domain DNS zone template. Used with the `--add` command only. Requires the use of options `-srv-service, -srv-target-host, -srv-port`. | To add to the DNS zone template an SRV record for <domain> to handle SIP protocol connections, that will point to a server named sipserver.sample.com listening on TCP port 5060. The priority given here is 0, and the weight is 5:
    plesk bin server_dns --add -srv '' -srv-service sip -srv-target-host sipserver.sample.com. -srv-protocol TCP -srv-port 5060 -srv-priority 0 -srv-weight 5
`-srv-priority` | `[0-50]` | Specifies priority of the SRV record (0 - the highest, 50 - the lowest). |
`-srv-weight` | `[0-50]` | Specifies relative weight of the SRV record among records with the same priority (0 - the lowest, 50 - the highest). |
`-srv-port` | `[0-65535]` | Specifies the port on which the service is to be found (for SRV record). |
`-srv-target-host` | `<host>` | Specifies canonical hostname of the machine providing the service (for SRV record) |
`-srv-protocol` | `TCP|UDP` | Specifies the service protocol for SRV record. |
`-srv-service` | `<service>` | Specifies symbolic name of the service for SRV record. |
`-txt` | `<text>|""` | Specifies the `TXT` type resource record in the Plesk server’s domain DNS zone template. Used with the `--add` only. Requires the `-domain` option if the record is created for a specific subdomain name. | To specify the `TXT` type DNS record “This record is used to implement the Senders Policy Framework and DKIM specifications” for the specific subdomain name subdom in the domain DNS zone template:
    plesk bin server_dns -a -txt "This record is used to implement the Senders Policy Framework and DKIM specifications" -domain subdom
`-domain` | `<subdomain_name>|""` | Specifies a subdomain name for creating a `TXT` type resource record in the Plesk server’s domain DNS zone template. Used with the `--add` command only. |
`-soa-ttl` | `<number>[S|M|H|D|W]` | Specifies the TTL value for the SOA record in the Plesk server’s domain DNS zone template. Used with the `--update-soa` command only. | To set the TTL value to 5 hours, the Refresh value to 4 hours, the Retry value to 10 seconds, the Expire value to 2 weeks, and the Minimum value to 2 days for the SOA record in the domain DNS zone template:
    plesk bin server_dns --update-soa -soa-ttl 5H -soa-refresh 4H -soa-retry 10S -soa-expire 2W -soa-minimum 2D
`-soa-refresh` | `<number>[S|M|H|D|W]` | Specifies the Refresh value for the SOA record in the Plesk server’s domain DNS zone template. Used with the `--update-soa` command only. |
`-soa-retry` | `<number>[S|M|H|D|W]` | Specifies the Retry value for the SOA record in the Plesk server’s domain DNS zone template. Used with the `--update-soa` command only. |
`-soa-expire` | `<number>[S|M|H|D|W]` | Specifies the Expire value for the SOA record in the Plesk server’s domain DNS zone template. Used with the `--update-soa` command only. |
`-soa-minimum` | `<number>[S|M|H|D|W]` | Specifies the Minimum value for the SOA record in the Plesk server’s domain DNS zone template. Used with the `--update-soa` command only. |
`-soa-serial-format` | `timestamp|yyyymmddnn` | Specifies format of SOA record serial number: UNIX timestamp or recommended by IETF and RIPE. Used with the `--update-soa` command only. | To change the SOA record serial format to recommended by IETF and RIPE in the domain DNS zone template:
    plesk bin server_dns --update-soa -soa-serial-format yyyymmddnn