Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Added Version 1.1.1 information
  • Loading branch information
virus2500 committed May 4, 2014
1 parent 4da34c2 commit 3803d3c
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ Use at your own risk :)

Written and tested on Debian Wheezy!

Create an ipset based blocklist from an url to an blocklist text file e.g. blocklist.de.

As of Version 1.0.3 you can use multiple Sources at once!
Create an ipset/iptables based blocklist from an url to an blocklist text file e.g. blocklist.de.

Changes
--------
- V1.1.1: short Help (-h) and Cleanup (-c) available. Binary should now be found automatically
- V1.1.0: blocklist-with-ipset is now IPV6 compatible (Yayyy :) )
- V1.1.1: short Help (-h) and Cleanup (-c) available. Binary should now be found automatically.
- V1.1.0: blocklist-with-ipset is now IPV6 compatible (Yayyy :) )
- V1.0.4: Path to white and blacklist is now set automatically
- V1.0.3: Now you can set multiple blocklist sources
- V1.0.2: Added a whitelist and blacklist

<br>
**!!! IMPORTANT !!!!**

When upgrading from a version lower than 1.1.0 you might have to manually drop duplicated INPUT Rules.
When upgrading from a version lower than 1.1.0 you might have to manually drop duplicated INPUT Rules.

The script uses various binarys like iptables, ipset. If the script complains that it can't find an specific binary make sure it is in the ENV Path of the script. If not add the path to the binary.

Also you will have to specify where your binarys are located. This settings can be made in blocklist.pl .
$ENV{'PATH'}= '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin';

(You can find out where your binarys are with "which" e.g. "which iptables")
<br>

## INSTALL ##
<br>

1. Make sure you have ipset and the Data::Validate::IP Perl Module installed! If not you can usually install it with your distribution software management tool. E.g. apt for Debian/Ubuntu/Mint.

Expand All @@ -35,40 +37,44 @@ Also you will have to specify where your binarys are located. This settings can

3. Open blocklist.pl with your favorite text editor and set up your blocklist urls. Two are included as default. You can enhance or edit as you like. The destination URL should be an direct link to an Text file though.

my @listUrl = ("http://lists.blocklist.de/lists/all.txt", "http://www.infiltrated.net/blacklisted");
my @listUrl = ("http://lists.blocklist.de/lists/all.txt", "http://www.infiltrated.net/blacklisted");

*You can for example add an list like this*
*You can for example add an list like this*

my @listUrl = ("http://lists.blocklist.de/lists/all.txt", "http://www.infiltrated.net/blacklisted", "http://www.superblocksite.org/anotherBlocklist.txt");
my @listUrl = ("http://lists.blocklist.de/lists/all.txt", "http://www.infiltrated.net/blacklisted", "http://www.superblocksite.org/anotherBlocklist.txt");

4. Create an cronjob. I have mine in /etc/crontab

0 */1 * * * root /usr/bin/perl /path/to/the/script/blocklist.pl > /dev/null
0 */1 * * * root /usr/bin/perl /path/to/the/script/blocklist.pl > /dev/null

5. Create an logrotate for the logfile. E.g. under /etc/logrotate.d/blocklist

/var/log/blocklist
{
rotate 4
daily
missingok
notifempty
delaycompress
compress
rotate 4
daily
missingok
notifempty
delaycompress
compress
}

6. If you have an ip you definitly want to block just put it in blacklist.txt. If you have an IP you definitly never want to have blocked put it in whitelist.txt. This two files are just text lists seperated by new lines. So for example

#blacklist.txt
2.2.2.2
3.3.3.3
3.3.3.3

#and in whitelist.txt
4.4.4.4
5.5.5.5
5.5.5.5

That's it. If you want to manually run the script just cd to the folder where the script is located and run ./blocklist.pl

## CLEANUP ##
<br>
If you want to remove the iptables rules and ipset lists just run


./blocklist.pl -c

If you want to remove the iptables rules

0 comments on commit 3803d3c

Please sign in to comment.