How to use perl to do a mass update of a single A record for all domains


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » DNS

How to use perl to do a mass update of a single A record for all domainsLast Modified: Apr 22, 2008, 1:29 pm
If you're looking to change the IP value of 1 A record in all db files for all domains, perl will be your best friend.
In this example, we'll change the mail A record from any previous IP to a new value of 1.2.3.4.  This will make all mail get delivered to 1.2.3.4 when the MX record is looked up in the dns query.

First, you'll want to change to the directory where your db files live.
On redhat systems it's /var/named.
On debian /etc/bind
On freebsd /etc/namedb

So the example would be

cd /var/named
perl -pi -e 's#^mail\s14400\sIN\sA\s(.*)$#mail\t14400\tIN\tA\t1.2.3.4#' *.db

Then restart named so the new values take effect.

Note that these steps can be applied to other A record with different names (like pop and smtp), and even to other record types like MX, NS, TXT, etc.

2003 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST