Skip to content

Instantly share code, notes, and snippets.

@SVilgelm
Created September 30, 2014 11:47
Show Gist options
  • Save SVilgelm/3c373f846ad7b0441c17 to your computer and use it in GitHub Desktop.
Save SVilgelm/3c373f846ad7b0441c17 to your computer and use it in GitHub Desktop.
server hints
#/etc/rc.local
ipset create black_ips hash:ip
iptables -A INPUT -m set --match-set black_ips src -j DROP
grep "Failed password for" /var/log/auth.log | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort | uniq -c | awk '$1 > 5 { print $2}' | xargs -I{} ipset add black_ips {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment