#!/bin/bash # Script to auto update bogons file for use with firewall script VERSION="0.1" WGET=/usr/bin/wget PREFIX=`pwd` BOGONSFILE=$PREFIX/bogon-bn-agg.txt BOGONSURL="http://www.cymru.com/Documents/bogon-bn-agg.txt" REMOVECIDR="(192.168.0.0|10.0.0.0|172.16.0.0)" if [ ! -x $WGET ]; then echo "wget command not found or executable. Please" echo "edit the update-bogons script." exit 1 fi echo "Bogons update script - Version $VERSION" echo -e "Part of Firewall/SOSDG - http://www.sosdg.org \n" echo "Uses The Team Cymru Bogon List located at:" echo -e "http://www.cymru.com/Documents/bogon-list.html\n" if `wget -q -O $BOGONSFILE.new $BOGONSURL`; then echo "Downloaded new bogons file..." mv $BOGONSFILE $BOGONSFILE.old &>/dev/null echo "Backed up $BOGONSFILE to .old..." if [ $REMOVECIDR ]; then grep -vE -e "$REMOVECIDR" $BOGONSFILE.new > $BOGONSFILE echo "Removed blocks listed in REMOVECIDR..." rm -f $BOGONSFILE.new else mv $BOGONSFILE.new $BOGONSFILE echo "Replaced old bogons file with new one." fi else echo "Error downloading bogons file. Please try again later." rm -f $BOGONSFILE.new exit 1 fi exit 0