Skip to content

Instantly share code, notes, and snippets.

View NotoriousPyro's full-sized avatar

NotoriousPyro

View GitHub Profile
@NotoriousPyro
NotoriousPyro / iptables-spamhaus.sh
Last active May 11, 2017 17:43
Spam IP blocker for iptables and bash (list by spamhaus.org). See how to use this here: https://pyronexus.com/2017/01/11/blocking-spammers-with-bash-and-iptables/
#!/usr/bin/env bash
# List variables
blocklist_name="Spamhaus" # MUST BE UNIQUE IN IPTABLES
blocklist="http://www.spamhaus.org/drop/drop.lasso"
# No more variables. Edit below here at your own risk.
PATH="/sbin:$PATH"
printf "Retrieving block list: %s... " "$blocklist"
list=`curl -sSL "$blocklist" | cut -d ";" -f 1 | grep -v "^$"`