Moved all clients from one server to another - need to mass update DNS

hostpc.com

Verified User
Joined
Aug 2, 2003
Messages
1,178
Location
Schenectady, NY
We've got a server failing - rapidly I might add, and I'm not sure we've got time for DNS propogation.

I took all the clients backups from the failing server, restored them to the new. The only issue noted was that when every client restored on the new server, they restored with the DNS of the old server (ns10a/ns10b). I need to be able to mass update to ns12a/ns12b.

I know I can redirect the IP's with the registrar - but there are some clients that went to one server, and some to another server (ns11a/ns11b) - so that's out of the question (as far as I can see).

Is there a way, to take all clients restored on each server, and have their DNS entries updated to the correct DNS? I'm thinking like a command line update?

I'm really desperate for help on this one... I'd sure appreciate any help you guys can offer.

Thanks
 
Forgot to mention - these servers are in different datacenters, so I can't just assign IP's from one server to another... that would have been too easy. :(
 
Hello,

To do a mass nameserver change, the easiest is to just use perl:

perl -pi -e 's/ns1.oldns.com/ns1.newns.com/' /var/named/*.db

Do that for both ns's you want to change. You'll probably also want to change the values for in the user.conf file for new domains, eg:

perl -pi -e 's/ns1.oldns.com/ns1.newns.com/' /usr/local/directadmin/data/users/*/user.conf
 
That was an easy one, I'da done something like this:

mkdir /root/var/named
cp /var/named/*.db /root/var/named
cd /root/var/named
for i in *
do
cat $i | sed -e s/'nsOLD.domain.com'/'nsNEW.domain.com'/g - > $i
done

Make sure the files are good

then (as an added precaution)
mkdir /root/var/named/old
mv /var/named/*.db /root/var/named/old/
cp /root/var/named/*.db /var/named/
service named restart
 
Thanks for making this post WDV, it helped me 10 years later :)

and to help someone else in the future:

if your server is FreeBSD then you might need to change the path to namedb directory

i.e. run both lines below, for each nameserver you want to do the global update for

perl -pi -e 's/oldns.domain.com./newns.domain.com./' /var/named/etc/namedb/*.db

perl -pi -e 's/oldns.domain.com./newns.domain.com./' /usr/local/directadmin/data/users/*/user.conf

and restart your named after that
 
Back
Top