Script to find and replace only the MX entries of Specified dns zone files, with SpamExperts MX entries.
#!/bin/bash
for i in `cat domains.lst`; do
FileName=$i.db;
FileBack=$FileName"_bk";
if [ -f $FileName ]; then
find . -maxdepth 1 -type f -name $FileName | xargs sed 's/.*MX.*/'"$i."' 14400 IN MX 10 mx.spamexperts.com.\n'"$i."' 14400 IN MX 20 fallbackmx.spamexperts.eu.\n'"$i."' 14400 IN MX 30 lastmx.spamexperts.net./g' > $FileBack; mv -f $FileBack $FileName
else
echo $FileName " Doesnt Exists...................!!!!! ";
fi
done
Note:
Where domains.lst contains the domain names that needs to be replaced the MX entries with SpamExperts MX entries.
Comments