DNS Zones on Domains: dns Utility

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:

Syntax

dns <command> <domain name>|<domain alias> [

<option_1> [<param>]

[<option_2> [<param>]]

…[<option_N> [<param>]]

]

Example

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

Commands

Command

Parameter

Description

Example

--add or -a

<domain name>| <domain alias>

Àdds a resource record to a domain's DNS zone. If a record already exists, the command returns code 2.

To add new MX resource record mail3.example.com to the DNS zone on domain example.com and specify mail exchanger mail.example.com for the record:

# ./dns --add example.com -mx mail3 -mailexchanger mail.example.com

or

# ./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 concomitant use of 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:

    # ./dns --set example.com -list "MX,mail3,example.com,15;NS,ns2,ns.example.com"

or

# ./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 domain example.com:

# ./dns --del example.com -mx mail3 -mailexchanger mail.example.com

or

# ./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 domain example.com:

# ./dns --del-all example.com

or

# ./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 concomitant use of the -ip option.

To restore the default resource records for a domain's zone based on the Plesk server DNS zone template:

# ./dns --reset example.com -ip 81.1.204.9

or

# ./dns -res example.com -ip 81.1.204.9

--on

<domain name>| <domain alias>

Enables DNS service on a domain or domain alias.

To enable DNS service on domain example.com:

# ./dns --on example.com

--off

<domain name>| <domain alias>

Disables DNS service on a domain or domain alias.

To disable DNS service on domain example.com:

# ./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 domain example.com:

# ./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 domain example.com:

# ./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 parameter to 5 hours for the SOA record for the DNS zone on domain example.com:

# ./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 display the list of resource records in the DNS zone for domain example.com:

# ./dns --info example.com

--help or -h

 

Displays help on the use of the utility.

To display help on the use of the dns utility:

# ./dns --help

or

# ./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 concomitant use of the -ip option.

To add new A resource record subdom.example.com specifying IP address 192.168.67.78 for the subdomain to the DNS zone on domain example.com:

# ./dns -a example.com -a subdom -ip 192.168.67.78

-ip

<IP address>

Specifies an IP address for creating an A type resource record 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 concomitant use of the -nameserver option.

To add a new NS resource record ns2.example.com specifying domain name example.net as the name server to the DNS zone on domain name example.com:

# ./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 concomitant use of the -mailexchanger option.

To add 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 to the DNS zone on domain example.com:

# ./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

<number>

Specifies the mail exchanger priority 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 concomitant use of the -canonical option.

To add new CNAME type resource record subdom.example.com for a canonical name example.org to the DNS zone on domain example.com:

# ./dns --add example.com -cname subdom -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 concomitant use of the -subnet option.

To add new PTR type DNS record 192.168.12.1/16 for subdomain subdom in the DNS zone for domain example.com:

# ./dns -a example.com -ptr subdom -subnet 192.168.12.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.

-txt

<text>

Specifies the TXT type resource record in a domain's DNS zone.

Used with the --add and --del commands only.

Requires concomitant use of the -domain option if the record is created for a subdomain of the domain.

To specify the TXT type DNS record "This record is used to implement the Senders Policy Framework and DomainKeys specifications" for subdomain name subdom in the DNS zone for domain example.com:

# ./dns -a example.com -txt "This record is used to implement the Senders Policy Framework and DomainKeys specifications" -domain subdom

 

-domain

<subdomain name>

Specifies a subdomain name for creating a TXT type resource record in a domain's DNS zone.

Used with the --add and --del commands only.

-www

<true/false>

Enables or disables support of the www-prefixed alias for a canonical domain name in a domain's DNS zone (the www parameter for a domain name under the Domain Administrator preferences).

Used with the --reset command only.

Creates or 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 domain example.com:

# ./dns -res example.com -www true

-primary

<IP address>

Adds an IP address of a primary DNS server for a domain's DNS zone.

Used with the --add and --del and --reset commands only.

To add IP address 192.168.67.78 of the primary DNS server for DNS zone on domain example.com:

# ./dns -a example.com -www true

-soa-ttl

<number>[S|M|H|D|W]

Sets the TTL parameter for the SOA record for a domain' or domain alias' DNS zone.

Used with the--update-soa command only.

To set the TTL parameter to 5 hours, the Refresh parameter to 4 hours, the Retry parameter to 10 seconds, the Expire parameter to 2 weeks, and the Minimum parameter to 2 days for the SOA record in the DNS zone on domain example.com:

# ./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 parameter for the SOA record for 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 parameter for the SOA record for 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 parameter for the SOA record for 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 parameter for the SOA record for a domain' or domain alias' DNS zone.

Used with the --update-soa command only.

-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>

Consult descriptions of the options in this table for adding resource records of respective types individually.

Specifies resource records to be included in a domain's DNS zone.

Used with the --update-soa command only.

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:

    # ./dns -s example.com -list "MX,mail3,mail.example.com,15;NS,ns2,ns.example.com"