check-blacklist.sh: Added script to check DNSBL blacklist
authorMegaBrutal <code+git@megabrutal.com>
Sat, 4 Feb 2017 13:40:00 +0000 (14:40 +0100)
committerMegaBrutal <code+git@megabrutal.com>
Sat, 4 Feb 2017 13:40:00 +0000 (14:40 +0100)
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 [new file with mode: 0755]

diff --git a/host/check-blacklist.sh b/host/check-blacklist.sh
new file mode 100755 (executable)
index 0000000..76c6e70
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+if [ $# -lt 2 ]
+then
+       cat << END
+Usage $0 <hostname> <blacklist>
+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