• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Plesk API - dns.sh - how ?

madsere

Regular Pleskian
Nameservers changed for all sites on one of my Plesk servers and I now have to modify all the NS records.

Rather than spending the rest of my life doing the point and click shuffle I was trying to use the dns.sh script from ftp://download1.sw-soft.com/Plesk/Plesk7.5/Doc/plesk-7.5r-sdk-html/docs/cu/unix/ch08.html - but the documentation might as well have been in Russian.

dns.sh command <domain_name> [-a -ip | -ns -nameserver | -mx -mailexchanger -priority | -cname -canonical | -ptr -subnet | -txt -domain ]

Logically I'd expect something like

dns.sh -d mydomain.com -ns myoldnameserver.com

to delete an old nameserver entry but it complains about missing -nameserver. Adding that just gives another error. Maybe one of the Plesk gurus can clarify the syntax (and fix the documentation) ?
 
The dns.sh is for creating one DNS record at a time. Examples:

dns.sh --add "domain.com" -a "mail" -ip "xx.yy.zz.aa"

dns.sh --add "domain.com" -a "webmail" -ip "xx.yy.zz.aa"

dns.sh --add "domain.com" -mx "mail" -mailexchanger "domain.com" -priority "10"

These would create 3 records.

Each option such as -mx <value> may require an additional option, in this case -priority <value>

Their docs could use a lot more polishing, but if you read it very very literally, you'll get it.


dns.sh command <domain_name> [-a -ip | -ns -nameserver | -mx -mailexchanger -priority | -cname -canonical | -ptr -subnet | -txt -domain ]
(remember, the pipe char means 'or')
This means that on each run of the command, you would pick one of the following combinations (and only a single combination):

-a -ip
-ns -nameserver
-mx -mailexchanger -priority
-cname -canonical
-ptr -subnet
-txt -domain

And whichever one you pick, you must include all parts (mx has 3 parts). So if you want to create 10 DNS records, you will have to do 10 calls to dns.sh with the appropriate arguments...

Clear as mud, right? Hope this helps.
 
I think perhaps my question wasn't clear enough.

I just wanted to know the proper syntax for adding/deleting NS records. Some trial and error and I found it to be this:

dns.sh --del <zone> -ns "" -nameserver <nameserver>
dns.sh --add <zone> -ns "" -nameserver <nameserver>

It is curious that the -ns switch must have an empty quote for this command to work, but this is how it works for me.
 
Originally posted by madsere
I think perhaps my question wasn't clear enough.

I just wanted to know the proper syntax for adding/deleting NS records. Some trial and error and I found it to be this:

dns.sh --del <zone> -ns "" -nameserver <nameserver>
dns.sh --add <zone> -ns "" -nameserver <nameserver>

It is curious that the -ns switch must have an empty quote for this command to work, but this is how it works for me.

This is due to fact that names after -ns and other similar options are relative to the domain name. See the corresponding actions in web-interface.
 
Back
Top