#!/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 DNS="84.2.44.1" # Get IPs IPS="$(dig +short $1 A @$DNS | sort -u) $(dig +short $1 AAAA @$DNS | sort -u)" # Loop through IPs fails=0 for IP in $IPS; do # Performs the actual lookup against blacklists RESULT=$(host $IP $DNS | tail -1 | rev | cut -d" " -f1 | rev | sed 's/.$//') if [ "$RESULT" != "$1" ]; then ((fails++)) fi done echo $fails exit 0