DirectAdmin mass add IP or setting to SPF record

Modified on Wed, 13 Oct 2021 at 08:53 PM

Replace NEW_VALUE with the new setting. For example, configure ip6:your-ipv6-address to add IPv6 or include:spf.yourwebhoster.eu. It will only add the value to domains who do not have this record yet to prevent duplicates.

#!/bin/bash
# Copyright 2018 Yourwebhoster.eu

# CONFIGURATION
# Directory containing the .db files
named_dir='/var/named'

# String that should be in the txt record.
spf_add_value='NEW_VALUE'

# DO NOT CHANGE ANYTHING BELOW

# Change working dir
cd $named_dir

# List domains without provided string
domains=`grep -L $spf_add_value *.db`

for domainDB in $domains; do
        echo "Updating $domainDB";
        perl -pi -e "s/v=spf1 a mx/v=spf1 a mx $spf_add_value/" $domainDB
done

echo "Updating serials in named files"
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d800

echo "Restart Named"
/usr/local/directadmin/dataskq d800

echo "Done"

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article