From 7447893196d364b8a567225c00353c200284f7a7 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Sat, 4 Feb 2017 14:40:00 +0100 Subject: [PATCH] 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 --- host/check-blacklist.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 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 -- 2.34.1