Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add install script, whitelist file, and update IP/CIDR sources #15 #16

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added bash install script
  • Loading branch information
xeoncross committed Jan 21, 2015
commit fcc636315b2b92046158693bb2830774a95914e7
45 changes: 45 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# See also:
# http://autoshun.org/
# http://doc.emergingthreats.net/bin/view/Main/EmergingFirewallRules
# http://adityamukho.com/blog/2014/06/18/using-ipset-manage-blacklists-firewall/
# http://daemonkeeper.net/781/mass-blocking-ip-addresses-with-ipset/
# http://www.stopforumspam.com/downloads/toxic_ip_cidr.txt

# Require git, ipset, and iptables
apt-get -qq --assume-yes install git ipset iptables > /dev/null

if [[ ! -e /usr/local/bin/update-blacklist.sh ]]; then

git clone https://github.com/trick77/ipset-blacklist.git
cd ipset-blacklist

# Install in system
mv update-blacklist.sh /usr/local/bin/
chmod +x /usr/local/bin/update-blacklist.sh

cd ../
rm -R ipset-blacklist
fi

# Create a CRON script that runs each day to update our blacklists
if [[ ! -e /etc/cron.d/update-blacklist ]]; then
cat > /etc/cron.d/update-blacklist <<END
# Run at 3:33am each day
MAILTO=root
33 3 * * * root /usr/local/bin/update-blacklist.sh
END

fi

# Check that this set exists (if not, create it)
ipset -L blacklist >/dev/null 2>&1
if [ $? -ne 0 ]; then
ipset create blacklist hash:net
fi

echo "Please add the following line to IPTables to enable this blacklist"
echo "iptables -I INPUT -m set --match-set blacklist src -j DROP"

# Done