X-Git-Url: http://git.megabrutal.com/?p=mgsautils.git;a=blobdiff_plain;f=host%2Fcheck-blacklist.sh;fp=host%2Fcheck-blacklist.sh;h=76c6e708543be9f32650d6b7f97c0529b1041e46;hp=0000000000000000000000000000000000000000;hb=7447893196d364b8a567225c00353c200284f7a7;hpb=076ff6605e618e3bf0fdb0bd9f9f6df56f7b35e4

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 <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