Add check_ptr.sh
This commit is contained in:
parent
37825d9db5
commit
afbed48118
27
check_ptr.sh
Normal file
27
check_ptr.sh
Normal file
@ -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##*/} <hostname>"
|
||||
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
|
Loading…
Reference in New Issue
Block a user