Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to use perl to do a mass dns update through direct admin  (Read 21719 times)

0 Members and 1 Guest are viewing this topic.

Aby

  • Guest
How to use perl to do a mass dns update through direct admin
« on: January 16, 2014, 07:23:31 am »
If you need to change all of your dns servers through DirectAdmin one by one, it's easier to use perl to do a regex (regular expression) to do the replace for us with one command.  To do this, you can run the following.  (replace the bold items with your own)

Code: [Select]
cd /usr/local/directadmin/data/users
perl -pi -e 's/ns1.old.com/ns1.new.com/' */user.conf
perl -pi -e 's/ns2.old.com/ns2.new.com/' */user.conf
perl -pi -e 's/ns1.old.com/ns1.new.com/' */reseller.conf
perl -pi -e 's/ns2.old.com/ns2.new.com/' */reseller.conf

cd /var/named   #(or whatever the path to your *.db files is, eg: /etc/bind, /etc/named)
perl -pi -e 's/ns1.old.com/ns1.new.com/' *.db
perl -pi -e 's/ns2.old.com/ns2.new.com/' *.db

once your changes are done, it's a good idea to rewrite all .db files to update your serials, and also to trigger any syncs to remote dns systems:

Code: [Select]
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue