# dns: DNS Zones on Domains

The `dns` utility is used to manage DNS zones on domains and domain aliases through CLI. By using this utility, you can perform the following tasks:

- adding resource records to or deleting them from a domain’s or domain alias’ DNS zone
- enabling or disabling a local DNS service on a domain or domain alias
- setting Plesk name server as the master or slave server for a DNS zone
- assigning external master DNS servers for a DNS zone
- enabling or disabling the www-prefixed alias (in the `www.<domain name>` form) support for canonical domain names
- updating the Start-of-Authority (SOA) record for a DNS zone

## Usage

    dns <command> [<domain_name>|<domain_alias>] [
    <option_1> [<param>]
    [<option_2> [<param>]]
    ... [<option_N> [<param>]]
    ]

## Example

The following command removes all pre-existing resource records from the DNS zone on the domain example.com and adds the following two records to the DNS zone:

- new `MX` resource record mail3.example.com specifying domain name mail.example.com as the mail exchanger and setting the mail exchanger’s priority to 15

- new `NS` resource record ns2.example.com setting domain ns.example.com as the name server

      plesk bin dns --set example.com -list "MX,mail3,mail.example.com,15;NS,ns2,ns.example.com"

## Commands

Command | Parameter | Description | Example
--- | --- | --- | ---
`--add` or `-a` | `<domain_name>|<domain_alias>` | Adds a resource record to a domain’s DNS zone. If a record already exists, the command returns code `2`. | To add an `MX` resource record mail3.example.com to the DNS zone on the domain example.com and specify mail exchanger mail.example.com for the record:
    plesk bin dns --add example.com -mx mail3 -mailexchanger mail.example.com
or
    plesk bin dns -a example.com -mx mail3 -mailexchanger mail.example.com
- `--set` or `-s` | `<domain_name>|<domain_alias>` | Adds specified resource records to and removes all pre-existing resource records from a domain’s DNS zone. Requires the `-list` option. | To add the following two resource records to the DNS zone of domain example.com, while removing all pre-existing resource records from the DNS zone: new `MX` resource record mail3.example.com specifying domain name mail.example.com as the mail exchanger for the record, and setting the mail exchanger’s priority to 15: new `NS` resource record ns2.example.com setting domain ns.example.com as the name server:
      plesk bin dns --set example.com -list "MX,mail3,example.com,15;NS,ns2,ns.example.com"
or
    plesk bin dns -s example.com -list "MX,mail3,example.com,15;NS,ns2,ns.example.com"
`--del` or `-d` | `<domain_name>|<domain_alias>` | Deletes a resource record from a domain’s DNS zone. | To delete an existing `MX` resource record mail3.example.com (for which mail exchanger mail.example.com is specified) from the DNS zone for the domain example.com:
    plesk bin dns --del example.com -mx mail3 -mailexchanger mail.example.com
or
    plesk bin dns -d example.com -mx mail3 -mailexchanger mail.example.com
`--del-all` or `-da` | `<domain_name>|<domain_alias>` | Deletes all resource records from a domain’s DNS zone. | To delete all existing resource records from the DNS zone for the domain example.com:
    plesk bin dns --del-all example.com
or
    plesk bin dns -da example.com
`--reset` or `-res` | `<domain_name>|<domain_alias>` | Restores the default resource records for a domain’s zone based on the Plesk server DNS zone template. Requires the `-ip` option. | To restore the default resource records for a domain’s zone based on the Plesk server DNS zone template:
    plesk bin dns --reset example.com -ip 192.0.2.9
or
    plesk bin dns -res example.com -ip 192.0.2.9
`--on` | `<domain_name>|<domain_alias>` | Enables DNS service on a domain or domain alias. | To enable DNS service on the domain example.com:
    plesk bin dns --on example.com
`--off` | `<domain_name>|<domain_alias>` | Disables DNS service on a domain or domain alias. | To disable DNS service on the domain example.com:
    plesk bin dns --off example.com
`--set-master` | `<domain_name>|<domain_alias>` | Sets the Plesk name server as the master server for domain’s or domain alias’ DNS zone. | To set the Plesk name server as the master server for DNS zone on the domain example.com:
    plesk bin dns --set-master example.com
`--set-slave` | `<domain_name>|<domain_alias>` | Sets the Plesk name server as the slave server for domain’s or domain alias’ DNS zone. | To set the Plesk name server as the slave server for DNS zone on the domain example.com:
    plesk bin dns --set-slave example.com
`--update-soa` | `<domain_name>|<domain_alias>` | Updates the SOA record settings for domain’s or domain alias’ DNS zone. | To set the TTL value for the SOA record of the DNS zone on the domain example.com to 5 hours:
    plesk bin dns --update-soa example.com -soa-ttl 5H
`--info` | `<domain_name>|<domain_alias>` | Displays the list of resource records for a domain’s or domain alias’ DNS zone. | To view the list of resource records in the DNS zone for the domain example.com:
    plesk bin dns --info example.com
`--help` or `-h` |  | Displays help on the use of the utility. | To view help on the use of the `dns` utility:
    plesk bin dns --help
or
    plesk bin dns -h

## Options

Option | Parameter | Description | Example
--- | --- | --- | ---
`-a` | `''|` `<subdomain_name>` | Specifies the `A` type resource record for a subdomain in a domain’s DNS zone. Used with the `--add` and `--del` commands only. Requires the `-ip` option. | To add an `A` resource record sample.example.com specifying IP address 192.0.2.78 for the subdomain to the DNS zone on the domain example.com:
    plesk bin dns -a example.com -a sample -ip 192.0.2.78
To add an `AAAA` resource record sample.example.com specifying IP address 2001:db8:85a3:0:0:8a2e:370:7334 for the subdomain to the DNS zone on the domain example.com:
    plesk bin dns -a example.com -aaaa sample -ip 2001:db8:85a3:0:0:8a2e:370:7334
`-aaaa` | `''|` `<subdomain_name>` |  | Specifies the `AAAA` type resource record for a subdomain in a domain’s DNS zone. Used with the `--add` and `--del` commands only. Requires the `-ip` option.
`-ip` | `<IP_address>` |  | Specifies an address for creating a resource record (IPv4 for A type records and IPv6 for AAAA type records) in a domain’s DNS zone. Used with the `--add` and `--del` commands only.
`-ns` | `''|` `<subdomain_name>` | Specifies the `NS` type resource record in a domain’s DNS zone. Used with the `--add` and `--del` commands only. Requires the `-nameserver` option. | To add an `NS` resource record ns2.example.com specifying domain name example.net as the name server to the DNS zone on domain name example.com:
    plesk bin dns -a example.com -ns ns2 -nameserver example.net
`-nameserver` | `<domain_name>` |  | Specifies the name of a nameserver for creating an NS type resource record in a domain’s DNS zone.
`-mx` | `''|` `<subdomain_name>` | Specifies the `MX` type resource record in a domain’s DNS zone. Used with the `--add` and `--del` commands only. Requires the `-mailexchanger` option. | To add an `MX` resource record mail3.example.com specifying domain name mail.example.com as the mail exchanger for the record, and setting the mail exchanger’s priority to the DNS zone on the domain example.com to 15:
    plesk bin dns -a example.com -mx mail3 -mailexchanger mail.example.com -priority 15
`-mailexchanger` | `<domain_name>` |  | Specifies the name of a mail exchanger for creating an `MX` type DNS record in a domain’s DNS zone.
`-priority` | `[0-50]` |  | Specifies the mail exchanger priority (0 - the highest, 50 - the lowest) for creating an `MX` type DNS record in a domain’s DNS zone.
`-cname` | `''|` `<subdomain_name>` | Specifies the `CNAME` type resource record in a domain’s DNS zone. Used with the `--add` and `--del` commands only. Requires the `-canonical` option. | To add a `CNAME` type resource record sample.example.com for a canonical name example.org to the DNS zone on domain example.com:
    plesk bin dns --add example.com -cname sample -canonical example.org
`-canonical` | `<domain_name>` | Specifies a canonical name for creating a `CNAME` type DNS record in a domain’s DNS zone. |
`-ptr` | `''|` `<subdomain_name>` | Specifies the `PTR` type resource record in a domain’s DNS zone. Used with the `--add` and `--del` commands only. Requires the `-subnet` option. | To add a `PTR` type DNS record 192.0.2.1/16 for the subdomain sample to the DNS zone for the domain example.com:
    plesk bin dns -a example.com -ptr sample -subnet 192.0.2.1/16
`-subnet` | `<IP_address>` `|` `<subnet_mask>` | Specifies an IP address and a subnet mask for creating a `PTR` type DNS record in a domain’s DNS zone. |
`-srv` | `''|` `<subdomain_name>` | Specifies the SRV type resource record in a domain’s DNS zone. Used with the `--add` and `--del` commands only. Requires the use of options `-srv-service, -srv-target-host, -srv-port`. | To add an SRV record to make domain example.com 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 dns --add example.com -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 a domain’s DNS zone. Used with the `--add` and `--del` commands. Requires the `-domain` option if the record is created for a subdomain of a domain. | To specify the `TXT` type DNS record “This record is used to implement the Senders Policy Framework and DKIM specifications” for the subdomain name sample in the DNS zone for the domain example.com:
    plesk bin dns -a example.com -txt "This record is used to implement the Senders Policy Framework and DKIM specifications" -domain sample
`-domain` | `<subdomain_name>` |  | Specifies a subdomain name for creating a `TXT` or `DS` resource record in a domain’s DNS zone. Used with the `--add` and `--del` commands only.
`-ds` | `''|"<key-tag> <algorithm> <digest-type> <digest>"` | Specifies the `DS` resource record in a domain’s DNS zone. Used with the `--add` and `--del` commands. Requires the `-domain` option if the record is created for a subdomain or additional domain on a subscription. The information about the DS records that you need to add to the parent zone is available in Plesk UI in DNSSEC settings of a domain. | To specify the DNS record of the DS type for the subdomain sample in the DNS zone of the domain example.com:
    plesk bin dns --add example.com -domain sample -ds "62181 10 2 6CBB33AB0260421C08968A4384AE38778FC88E740B660336A5CF7900 8F3AF9AD"
`-www` | `true|false` | Enables/Disables support of the www-prefixed alias for a canonical domain name in a domain’s DNS zone. Used with the `--reset` command only. Creates/Deletes a `CNAME` type resource record in the `www.<domain_name>` form. | To enable support of the www-prefixed alias www.example.com (pointing to domain example.com) in the DNS zone on the domain example.com:
    plesk bin dns -res example.com -www true -ip 192.0.2.94
`-primary` | `<IP_address>` | Adds an IP address of a primary DNS server for a domain’s DNS zone. Used with the `--add` `--del` and `--reset` commands only. | To add the IP address 192.0.2.78 of the primary DNS server for DNS zone on the domain example.com:
    plesk bin dns -a example.com -primary 192.0.2.78
`-soa-ttl` | `<number>[S|M|H|D|W]` | Sets the TTL value for the SOA record of a domain’ or domain alias’ DNS zone. 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 DNS zone on the domain example.com:
    plesk bin dns --update-soa example.com -soa-ttl 5H -soa-refresh 4H -soa-retry 10S -soa-expire 2W -soa-minimum 2D
`-soa-refresh` | `<number>[S|M|H|D|W]` |  | Sets the Refresh value for the SOA record of a domain’ or domain alias’ DNS zone. Used with the `--update-soa` command only.
`-soa-retry` | `<number>[S|M|H|D|W]` |  | Sets the Retry value for the SOA record of a domain’ or domain alias’ DNS zone. Used with the `--update-soa` command only.
`-soa-expire` | `<number>[S|M|H|D|W]` |  | Sets the Expire value for the SOA record of a domain’ or domain alias’ DNS zone. Used with the `--update-soa` command only.
`-soa-minimum` | `<number>[S|M|H|D|W]` |  | Sets the Minimum value for the SOA record of a domain’ or domain alias’ DNS zone. 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 for domain example.com:
    plesk bin dns --update-soa example.com -soa-serial-format yyyymmddnn
- `-list` | `"<record_1>;<record_2>;...<record_N>"` where the `<record>` parameter is composed according to the following rules: for `MX` record: `MX,<subdomain_name>,<mail_exchanger_name>,<priority>` for `NS` record: `NS,<subdomain_name>,<name_server_name>` for `A` record: `A,<subdomain_name>,<IP_address>` for `PTR` record: `PTR,<IP_address/subnet_mask>,<subdomain_name>` for `CNAME` record: `CNAME,<subdomain_name>,<canonical_domain_name>` for `TXT` record: `TXT,<subdomain_name>,<text>` for `DS` record: `DS,<subdomain_name>,<key-tag> <algorithm> <digest-type> <digest>` For adding resource records of respective types individually, consult descriptions of the options in this table. | Specifies resource records to be included in a domain’s DNS zone. Used with the `--set` command only. | To add the following two resource records to the DNS zone of the domain example.com, while removing all pre-existing resource records from the DNS zone: new `MX` resource record mail3.example.com specifying domain name mail.example.com as the mail exchanger for the record, and setting the mail exchanger’s priority to 15: new `NS` resource record ns2.example.com setting domain ns.example.com as the name server:
      plesk bin dns -s example.com -list "MX,mail3,mail.example.com,15;NS,ns2,ns.example.com"