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 ipset-update.sh 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 ipset-update.sh script to configure it to block the ip lists of your choosing.
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 http://www.example.com/guarding.p2p | ./pg2ipset | ipset restore
======== AUTOMATIC LIST UPDATING
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/ipset-update.sh >/dev/null 2>&1
pg2ipset.c - Convert PeerGuardian lists to IPSet scripts. Copyright (C) 2009-2010, email@example.com ipset-update.sh - Automatically update and import pg2 format and text based ipset blocklists. Copyright (C) 2012-2015, firstname.lastname@example.org 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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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.