Skip to content

Instantly share code, notes, and snippets.

@nacx
Created March 30, 2011 10:45
Show Gist options
  • Save nacx/894192 to your computer and use it in GitHub Desktop.
Save nacx/894192 to your computer and use it in GitHub Desktop.
Simple chain to ban ip addresses
#!/bin/bash
BANFILE='/root/banned'
iptables -N BANNED
if [ -f ${BANFILE} ]; then
for IP in `sort -ru ${BANFILE}`; do
iptables -A BANNED -s ${IP} -j DROP
done
fi
iptables -A BANNED -j RETURN
iptables -A INPUT -i eth0 -m state --state NEW -j BANNED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment