Mass DNS Update

admonet

Verified User
Joined
Oct 30, 2005
Messages
35
Anyone know how to perform a mass DNS update for my mx records for all domains?
 
What do you mean mass dns update? You want to change mail servers or what do you want to do?
 
I just want to update all MX records for everyone hosted with me :)

Like from "mail.domain.com" to "mailfilter.host.com" and add another MX record to each domain for the secondary server.

Please let me know if there's an easy way to do this.
 
Last edited:
I have written a small shell script for you to use.

Put the following somewhere in your file system. Chmod it to 750 as root. Change the 2 variables on the top that say oldtext and newtext to what you want to replace and what you are replacing it to.

Make sure to also change the named_dir path to where your dns files are located.

Run the script as root and let it do the rest.

Let me know if you run into problems.

Thanks.

Code:
#!/bin/sh

named_dir=/etc/namedb # Set to path of your bind database files.
oldtext="mailbox.mytest.com" # Replace with original line to search for.
newtext="mailbox2.mytest.com" # Replace with new line to replace with.

#####################################

if [ `id -u` != "0" ]; then
        echo "You must run this as ROOT user only!"
        exit 1
else

echo ""

for file in $named_dir/*.db
do
        echo "Changing $oldtext to $newtext in file --> $file"
        sleep 1
        perl -pi -e s/$oldtext/$newtext/ $file
done
        echo ""
        echo "Now restarted the named service."
        echo ""
sleep 4

if [ -f /sbin/service ]; then

clear
/sbin/service named restart

elif [ -f /usr/local/etc/rc.d/named ]; then

clear
/usr/local/etc/rc.d/named restart

else

echo "Could not find the program to restart your version of named."
echo "Please restart it manually."
echo ""

fi
fi

exit 0
 
Oh yeah, I also am using the DNS clustering... I need to change mail 10 MX to mailcleaner.admo.net. 10 MX
mailcleaner2.admo.net 10 MX

Changing the first mx and adding a second one.

Adam
 
admonet said:
Is there any need to update the zone serial number?/QUOTE]
Try this:
Code:
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
It should update the serial numbers and restart BIND.

Jeff
 
I'm using DA in a multiserver setup.

How can I get the changed records to the other servers?

On one server i'm directly modifying the *.db files. After reloading bind the modified records should be synchronized...

How can I force that?
 
Pascal: depends on your method for synchronisation.

If you're using the default master/slave setup, it should automatically resync within the ttl of the zone.

(If you want to discuss this in more detail, please pm me in dutch, my dutch technobabble is a bit better than my english one)
 
Back
Top