How to add a new dns record to all existing domains and pointer zones


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


Top Level » DNS

How to add a new dns record to all existing domains and pointer zonesLast Modified: Nov 19, 2009, 7:38 pm
This guide contains a script which goes through all domains and domain pointers, and will add a new A record with a specific value you want, using that User's existing IP address.

Replace mynewrecord with the value that you want.
Adjust the /var/named path if you're running FreeBSD or Debian.
Don't forget to restart named after running the script.

#!/bin/sh
DATAU=/usr/local/directadmin/data/users
for u in `ls $DATAU`; do
{
      IP=`grep ip= $DATAU/$u/user.conf | cut -d= -f2`
      for d in `cat $DATAU/$u/domains.list $DATAU/$u/domains/*.pointers 2>/dev/null | cut -d= -f1`; do
      {
            echo "adding new record with IP $IP to $d";
            echo "mynewrecord   14400    IN   A   $IP" >> /var/named/${d}.db
      };
      done;
};
done;
exit 0;

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