13/10/2010
AAAA records with Plesk
Plesk is surely not ready for IPv6. Despite that fact, many people – me included, have the DNS records of their favorite domains managed by Plesk and still want to be able to add some IPv6 records to those.
Some time ago I had posted on my twitter account a link to another blog that had a “hackish way” to add AAAA records to Plesk. I have written a slightly more elegant shell script (to be run by root only) than the one provided by experimentalworks.
First of all you _need_ to alter dns_recs table of the psa database to allow AAAA records:
# mysql -u admin -p psa mysql> alter table dns_recs modify column type enum('NS','A','AAAA','CNAME','MX','PTR','TXT','SRV','master','none') NOT NULL default 'A';
Then download my plesk-AAAA.sh script and use it like the following example.
To add www.foobar.gr to point to 2001:db8:1001::1
Usage: ./plesk-AAAA.sh
[zone serial]
#./plesk-AAAA.sh foobar.gr www 2001:db8:1001::1
#./plesk-AAAA.sh foobar.gr ipv6 2001:db8:1001::1 12
Known bug/feature:
If you add a record without adding a serial, for the soa record, at the end, it will add the serial of the domain in the form:
YYYYMMDD10
So if you add two ipv6 hosts in the same day for the same domain you _have_ to manually add a serial >10 for the second host (and so forth).
For the ones who don’t like downloading but would like to see the script source, here it is:
1 #!/bin/sh 2 3 usage () { 4 echo "Usage: $0 <domain> <hostname> <v6 IP> [zone serial]" 5 echo "Usage: $0 foobar.gr www 2001:db8:1001::1" 6 exit 1 7 } 8 9 if [ $# -lt 3 ]; then 10 usage 11 fi 12 DOMAIN=$1 13 HOSTNAME=$2 14 v6IP=$3 15 INPUT_SERIAL=${4:-10} 16 FULLHOST="$2.$1." 17 18 ADMIN_PASS=`cat /etc/psa/.psa.shadow` 19 MYSQL_BIN_D=`grep MYSQL_BIN_D /etc/psa/psa.conf | awk '{print $2}'` 20 PRODUCT_ROOT_D=`grep PRODUCT_ROOT_D /etc/psa/psa.conf | awk '{print $2}'` 21 SERIAL=`date +%Y%m%d${INPUT_SERIAL}` 22 mysql="${MYSQL_BIN_D}/mysql -N -uadmin -p${ADMIN_PASS} psa" 23 24 query1="SELECT dns_zone_id FROM dns_recs where host like \"$DOMAIN%\" LIMIT 0,1" 25 ZONE_ID=`echo "$query1" | $mysql` 26 echo "ZONE_ID=$ZONE_ID" 27 query2="INSERT INTO dns_recs (displayHost, host, displayVal, val, type, dns_zone_id) VALUES ('$FULLHOST', '$FULLHOST', '$v6IP', '$v6IP', 'AAAA',$ZONE_ID)" 28 echo "$query2" | $mysql 29 30 query3="UPDATE dns_zone SET serial=\"$SERIAL\" WHERE id=$ZONE_ID LIMIT 1;" 31 echo "$query3" | $mysql 32 33 echo "REBUILDING zone file for $DOMAIN" 34 $PRODUCT_ROOT_D/admin/sbin/dnsmng update $DOMAIN
The script has been tested with bash and zsh. I have no idea whether it works under any other shells.
The script probably won’t delete your databases, but…use it at your own risk 🙂 I hope someone finds it useful.
Filed by kargig at 20:10 under Internet,Linux,Networking
Tags: aaaa, aaaa record, bash, dns, ipv6, Linux, Networking, plesk, script, shell, zsh
2 Comments | 8,317 views