Question
How to update all DNS records for multiple domains at once?
Answer
Click on a section to expand
For one record:
-
Connect to the server via RDP.
-
Prepare the list of the domains. For example, in order to put all the domains on the server into the
C:domains.txt
file, use the following Command Prompt command:C:> "%plesk_bin%dbclient.exe" --direct-sql --sql="SELECT name FROM domains" > C:domains.txt
-
Remove the existing A records from the domains:
C:> for /f "skip=1" %i in (C:domains.txt); do ("%plesk_cli%dns.exe" -d %i -a "" -ip 203.0.113.2)
-
Run the following command to add the new A records for the domains:
C:> for /f "skip=1" %i in (C:domains.txt); do ("%plesk_cli%dns.exe" -a %i -a "" -ip 203.0.113.2).
For all records:
-
Connect to the server via RDP.
-
Prepare the list of the domains. For example, in order to put all the domains on the server into the C:domains.txt file, use the following Command Prompt command:
C:> "%plesk_bin%dbclient.exe" --direct-sql --sql="SELECT name FROM domains" > C:domains.txt
-
Remove all records for all domains:
C:>for /f "skip=1" %i in (C:domains.txt); do ("%plesk_cli%dns.exe" --del-all %i)
-
Run the following command to add all records for all domains specified in "":
C:>for /f "skip=1" %i in (C:domains.txt); do ("%plesk_cli%dns.exe" -s %i -list "A,example.com,203.0.113.2;MX,mail3,mail.example.com,15;NS,ns2,ns.example.com").