From: MegaBrutal Date: Sat, 4 Feb 2017 13:40:00 +0000 (+0100) Subject: check-blacklist.sh: Added script to check DNSBL blacklist X-Git-Url: http://git.megabrutal.com/?a=commitdiff_plain;h=7447893196d364b8a567225c00353c200284f7a7;p=mgsautils.git check-blacklist.sh: Added script to check DNSBL blacklist The new check-blacklist.sh script can be used to check if your mail server appears on a DNSBL blacklist, because if such thing happens, it worth your attention. Can be easily integrated with monitoring systems like Zabbix. Requires DiG to be installed. new file: host/check-blacklist.sh --- diff --git a/host/check-blacklist.sh b/host/check-blacklist.sh new file mode 100755 index 0000000..76c6e70 --- /dev/null +++ b/host/check-blacklist.sh @@ -0,0 +1,18 @@ +#!/bin/sh +if [ $# -lt 2 ] +then + cat << END +Usage $0 +Where + hostname - host to check on blacklist + blacklist - DNSBL blacklist (e.g. "zen.spamhaus.org") +END + exit 255 +fi + +ip=$(dig a "$1" +short) +if [ -n "$ip" ] +then + bl=$(dig a "$(printf "%s." "$ip" | tac -s.)$2" +short) + [ -n "$bl" ] && { echo "$ip is blacklisted."; exit 1; } || echo "$ip is not blacklisted." +fi