diff --git a/check_ptr.sh b/check_ptr.sh new file mode 100644 index 0000000..15b3489 --- /dev/null +++ b/check_ptr.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Test if any IP4 and IP6 addresses of a hostname blocked on a DNSBL +# 2024-02-23 +# by Sandros + +# Parameter check +if [[ $# -ne 1 ]]; then + echo "Usage: ./${0##*/} " + exit 1 +fi + +# Get IPs +IPS="$(dig +short $1 A | sort -u) $(dig +short $1 AAAA | sort -u)" + +# Loop through IPs +for IP in $IPS; do + # Performs the actual lookup against blacklists + RESULT=$(host $IP | rev | cut -d" " -f1 | rev | sed 's/.$//') + if [ "$RESULT" != "$1" ]; then + echo 1 + exit 0 + fi +done + +echo 0 +exit 0 \ No newline at end of file