pg2ipset - Converts PG2 IP Blocklists into lists that ipset under Linux can consume
Shell C Makefile
Switch branches/tags
Nothing to show
Latest commit 2b14fdf Dec 26, 2014 2 @ilikenwf don't block localhost

======== ABOUT


pg2ipset takes the contents of PG2 IP Blocklists and outputs lists that ipset under Linux can consume, for more efficient blocking than most other methods.

The script helps import these and plain text based blocklists easily, for scheduling via cron.


make build && make install

(or just run make as root)


See the comments above each variable and array in the script to configure it to block the ip lists of your choosing.

======== USAGE

To manually import from a .txt list from bluetack:

cat /path/to/blocklist.txt | pg2ipset - - listname | ipset restore

To manually import from a .gz list:

zcat /path/to/blocklist.gz | pg2ipset - - listname | ipset restore

To manually import a txt list of only IP addresses and/or CIDR ranges, make sure to remove all comments and empty lines, then do the following:

awk '!x[$0]++' /path/to/blocklist.txt | sed -e "s/^/\-A\ \-exist\ listname\ /" | grep -v \# | grep -v ^$ | ipset restore

Help text: Usage: ./pg2ipset [ [ []]] Input should be a PeerGuardian .p2p file, blank or '-' reads from stdin. Output is suitable for usage by 'ipset restore', blank or '-' prints to stdout. Set name is 'IPFILTER' if not specified. Example: curl | ./pg2ipset | ipset restore


Be friendly and don't update more than once every 24 hours. Bluetack likely changes the obfuscated list URLS regularly, too.

0 0 * * * sh /path/to/ >/dev/null 2>&1

======== LICENSE

pg2ipset.c - Convert PeerGuardian lists to IPSet scripts.
Copyright (C) 2009-2010, - Automatically update and import pg2 format
and text based ipset blocklists.
Copyright (C) 2012-2015,

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.