• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Bulk nameserver change

vincenzot

Regular Pleskian
Hello,

there is any method to do an bulk nameserver change in all domains into my server (about 3 server with 400 domains for each one)?

I have need to change my old NS:

FROM

ns1.name_server.domain.tld
ns2.name_server.domain.tld
secondaryns.domain.tld

TO

name_server.domain.tld
2nd_ns.domain.tld
3nd_ns.domain.tld
4nd_ns.domain.tld

So, exist any functions on Plesk for do that?

Thanks you guys.
 
I doubt it can be done within Plesk, but you can script making the changes directly in the database and then push a complete reconfiguration of bind from the database, using this command :

mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -D psa -e 'select name from dns_zone' | awk '{print "/usr/local/psa/admin/sbin/dnsmng update " $1 }' | sh



(this is from some KB article that I can no longer find).
 
First you should update Server Settings > DNS Template in Plesk Panel.
Then you should make modifications in database psa table dns
mysql> update dns_recs set displayVal = 'ns1.new.tld.', val = 'ns1.new.tld.' where type = 'NS' and val='ns1.old.tld.';
After that you may use following script from your Plesk server:


#!/bin/bash

ADMIN_PASS=`cat /etc/psa/.psa.shadow`
MYSQL_BIN_D=`grep MYSQL_BIN_D /etc/psa/psa.conf | awk '{print $2}'`
mysql="${MYSQL_BIN_D}/mysql -N -uadmin -p${ADMIN_PASS} psa"
UNIXTST=`date +%s`
NORMTST=`date +%Y%m%d%M`

# Updating SOA serial record
querytimeu="update dns_zone set serial=$UNIXTST where serial_format='UNIXTIMESTAMP';"
querytimen="update dns_zone set serial=$NORMTST where serial_format='YYYYMMDDNN';"
echo $querytimeu | $mysql
echo $querytimen | $mysql

query="select name from domains;"
query2="select name from domainaliases;"
domains=`echo $query | $mysql `
daliases=`echo $query2 | $mysql `

echo "Updating zones for following domains"
echo "-----------------------------------------------------------------"
for i in ${domains}; do
echo "$i"
/usr/local/psa/admin/sbin/dnsmng update $i
done
echo "-----------------------------------------------------------------"
echo "All domains have been updated"
echo "Updating zones for following aliases"
echo "-----------------------------------------------------------------"
for i in ${daliases}; do
echo "$i"
/usr/local/psa/admin/sbin/dnsmng update $i
done
echo "-----------------------------------------------------------------"
echo "All aliases have been updated"
 
Hi Insider,

Your script worked great!
I used it to change bulk a-records.
But it allready changed after the rule: update dns_recs set displayVal = 'ns1.new.tld.', val = 'ns1.new.tld.' where type = 'NS' and val='ns1.old.tld.';

Why is there the need to run the script after?
Because when I run this script, then I get the following error:

dnsmng: Some parameters in command string are left unprocessed. Check parameters please.
System error 2: No such file or directory
domain.com


Did you know why? Or what to do.
And is there the need to run the script after?

Best regards,

-->> UPDATE
I find also the following script, and this works good!
Is this the same?

#!/bin/sh

ADMIN_PASS=`cat /etc/psa/.psa.shadow`
MYSQL_BIN_D=`grep MYSQL_BIN_D /etc/psa/psa.conf | awk '{print $2}'`
mysql="${MYSQL_BIN_D}/mysql -N -uadmin -p${ADMIN_PASS} psa"

query="select name from domains;"
domains=`echo $query | $mysql `

for i in ${domains}; do
echo "echo $i"
/usr/local/psa/admin/sbin/dnsmng --update $i
done


First you should update Server Settings > DNS Template in Plesk Panel.
Then you should make modifications in database psa table dns
mysql> update dns_recs set displayVal = 'ns1.new.tld.', val = 'ns1.new.tld.' where type = 'NS' and val='ns1.old.tld.';
After that you may use following script from your Plesk server:


#!/bin/bash

ADMIN_PASS=`cat /etc/psa/.psa.shadow`
MYSQL_BIN_D=`grep MYSQL_BIN_D /etc/psa/psa.conf | awk '{print $2}'`
mysql="${MYSQL_BIN_D}/mysql -N -uadmin -p${ADMIN_PASS} psa"
UNIXTST=`date +%s`
NORMTST=`date +%Y%m%d%M`

# Updating SOA serial record
querytimeu="update dns_zone set serial=$UNIXTST where serial_format='UNIXTIMESTAMP';"
querytimen="update dns_zone set serial=$NORMTST where serial_format='YYYYMMDDNN';"
echo $querytimeu | $mysql
echo $querytimen | $mysql

query="select name from domains;"
query2="select name from domainaliases;"
domains=`echo $query | $mysql `
daliases=`echo $query2 | $mysql `

echo "Updating zones for following domains"
echo "-----------------------------------------------------------------"
for i in ${domains}; do
echo "$i"
/usr/local/psa/admin/sbin/dnsmng update $i
done
echo "-----------------------------------------------------------------"
echo "All domains have been updated"
echo "Updating zones for following aliases"
echo "-----------------------------------------------------------------"
for i in ${daliases}; do
echo "$i"
/usr/local/psa/admin/sbin/dnsmng update $i
done
echo "-----------------------------------------------------------------"
echo "All aliases have been updated"
 
Last edited:
Back
Top