I had to change all SPF records for a client today from the Parallels Plesk default : “v=spf1 +a +mx -all” to something like “v=spf1 a mx a:server.name.tld -all” and the fun part was that the customer had something like 50+ domains on his server.
Since the Parallels Plesk Panel holds 99.99% of it’s data in the psa database, DNS settings are stored there as well, in two tables.
- dns_recs_t which holds the DNS template information, and
- dns_recs which holds the actual domain information.
I started with changing the template, then the domains info:
mysql>
mysql> UPDATE dns_recs_t SET val = ‘v=spf1 a mx a:server.name.tld -all’ WHERE val = ‘v=spf1 +a +mx -all’;
mysql> UPDATE dns_recs_t SET displayVal = ‘v=spf1 a mx a:server.name.tld -all’ WHERE displayVal = ‘v=spf1 +a +mx -all’;
mysql> UPDATE dns_recs SET val = ‘v=spf1 a mx a:server.name.tld -all’ WHERE val = ‘v=spf1 +a +mx -all’;
mysql> UPDATE dns_recs SET displayVal = ‘v=spf1 a mx a:server.name.tld -all’ WHERE displayVal = ‘v=spf1 +a +mx -all’;
you can now check the records if they match:
mysql> SELECT FROM dns_recs_t WHERE val LIKE ‘%spf%’;
If you got what you were looking for, now you need to change the actual DNS zone files using the dnsmng utility provided by Parallels Plesk Panel. I used the following script:
ADMIN_PASS=`cat /etc/psa/.psa.shadow`
MYSQL_BIN_D=`grep MYSQL_BIN_D /etc/psa/psa.conf | awk ‘{print $2}’`
mysql="${MYSQL_BIN_D}/mysql -N -uadmin -p${ADMIN_PASS} psa"
query="select name from domains;"
domains=`echo $query | $mysql `
for i in ${domains}; do
echo "found $i"
/usr/local/psa/admin/sbin/dnsmng update $i
echo "zone for $i updated"
done
Then just run the script:
Now all you have to do is a final check in the zones directory, I did something like:
-bash-3.2# grep -i spf *
Have fun, and use the above at your own risk.
