Sender Policy Framework (SPF) is an email validation system designed to prevent spam by detecting email spoofing.
# get spf record domain from google
dig TXT +short google.com
# get spf record from google
dig @8.8.8.8 TXT +short _spf.google.com
# get part of google ip ranges
dig TXT +short _netblocks.google.com
# beautify the results
dig TXT +short _netblocks{,2,3}.google.com | tr ' ' '\n' | grep '^ip4:'
# script for counting ips of google
total=0
for slash in $(dig TXT +short _netblocks{,2,3}.google.com | tr ' ' '\n' | grep '^ip4:' | cut -d '/' -f 2); do
total=$((total+$(echo "2^(32-$slash)" | bc -l)))
done
echo $total
# script for counting ips of baidu
total=0
for slash in $(dig TXT +short spf{,2,3}.baidu.com | tr ' ' '\n' | grep '^ip4:' | cut -d '/' -f 2); do
if [[ $slash =~ ^ip+ ]] ; then
total=$((total+1))
else
total=$((total+$(echo "2^(32-$slash)" | bc -l)))
fi
done
echo $total