Plan 9 from Bell Labs’s /usr/web/sources/contrib/boyd/sys/src/cmd/rbl.html

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


<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&gt;&amp;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\\.\\$/ &amp;&amp; \\$3 == \\"A\\" { print \\$4 }\"`"

		case "$a" in
		'')
			echo "$myname: Unknown host $i". 1&gt;&amp;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" &gt; /dev/null
		then
			echo "$i $t"
			e=0
		fi
	done
done

exit $e
</tt>
</pre>
<HR>
&copy 1998,
Boyd Roberts:
<A HREF="mailto:boyd@fr.inter.net">boyd@fr.inter.net</A>
</body>
</html>

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.