A shell script that grabs the latest Spamhaus DROP List and adds it to iptables. We use this (among other tools) on our Ubuntu proxy server at AppThemes to cut down on spam and other malicious activity.
Place the script somewhere on your server.
# find a nice home cd /home/YOUR-USERNAME/bin/ # create the file and paste vim spamhaus.sh # make it executable chmod +x spamhaus.sh # set it loose sudo ./spamhaus.sh # confirm the rules have been added sudo iptables -L Spamhaus -n
In order for the list to automatically update each day, you'll need to setup a cron job with crontab.
# fire up the crontab (no sudo) crontab -e # run the script every day at 3am 0 3 * * * /home/YOUR-USERNAME/bin/spamhaus.sh
If you need to remove all the Spamhaus rules, run the following:
sudo iptables -F Spamhaus