Add to Favourites Add to Favourites    Print this Article Print this Article

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

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;


Was this answer helpful?

Also Read