<html>
<body>
<pre>
<tt>
#!/bin/sh
#
# rbl [@rbl] address ...
#
# Lookup an IP address/host in the Realtime Blackhole List
#
rbl=rbl.maps.vix.com
myname="`basename \"$0\"`"
case $# in
0)
echo "usage: $myname [@rbl] address ..." 1>&2
exit 1
esac
e=1
for i
do
case "$i" in
@*)
# specify alternate blackhole
rbl="`expr \"$i\" : '.\(.*\)'`"
continue
;;
[0-9]*.[0-9]*.[0-9]*.[0-9]*)
# dotted quad
a="$i"
;;
*)
# hostname
a="`dig \"$i\" a | awk \"\\$1 ~ /^$i\\.\\$/ && \\$3 == \\"A\\" { print \\$4 }\"`"
case "$a" in
'')
echo "$myname: Unknown host $i". 1>&2
e=2
continue
;;
esac
;;
esac
for t in $a
do
q="`echo \"$t\" | awk -F. '{ print $4 FS $3 FS $2 FS $1 }'`.$rbl"
if dig "$q" a | grep "^$q" > /dev/null
then
echo "$i $t"
e=0
fi
done
done
exit $e
</tt>
</pre>
<HR>
© 1998,
Boyd Roberts:
<A HREF="mailto:boyd@fr.inter.net">boyd@fr.inter.net</A>
</body>
</html>
|