Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips > Outdated Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Outdated Tutorials & Tips
Outdated Tutorials & Tips

 
Thread Tools Display Modes
Old November 27th, 2005   #1
Kokanee
5 Cups of Ubuntu
 
Kokanee's Avatar
 
Join Date: Oct 2005
Location: Regina, SK
Beans: 38
Ubuntu Breezy 5.10
Send a message via ICQ to Kokanee Send a message via AIM to Kokanee
Lightbulb HOWTO: Peerguardian Installation and automatic updates

PeerGuardian is a free and open source IP address blocking software programs capable of blocking incoming and outgoing addresses. The application uses a blocklist of IP addresses to filter the computers of several organisations, including the RIAA and MPAA while using filesharing networks such as FastTrack and BitTorrent. The system is also capable of blocking advertising, spyware, government and educational ranges, depending upon user preferences.

More at WikiPedia.

PeerGuardian is not a firewall. It filters your incoming/outgoing connections. It is usefull when on P2P networks because it blocks the RIAA, MPAA and other evile empires from seeing you. This helps because they can not collect evidence against you and will help in filtering the bogus seeded files they litter the P2P networks with.

Okey, lets get started. Download and install PeerGuardian. There is a .DEB package and source code posted on their SoureForge site. This HOWTO will use the DEB.

http://sourceforge.net/project/showf...kage_id=148849

Code:
sudo dpkg -i peerguardnf-1.5beta.i386.deb
Now that it's installed blocklists need to be setup.

Code:
sudo mkdir /etc/peerguardian
Create a blank text file and save it as peerguardian.sh.

Code:
sudo cp peerguardian.sh /usr/local/bin
Code:
sudo chmod -c 755 /usr/local/bin/peerguardian.sh
Now open peerguardian.sh wth gedit....

Code:
sudo gedit /usr/local/bin/peerguardian.sh
Now paste the following into it then save and close:

Code:
# version for bluetack.co.uk lists!
#!/bin/sh
# Update new blocklists and start/stop/restart PeerGuardian
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# testdescription
#
#CONFIGURATION
# Make sure PG_ETC points to the directory where
# you want to put your downloaded blocklists.
PG_ETC=/etc/peerguardian/
# Remove the lists you don't want to download and
# use from BLOCKLISTS.
BLOCKLISTS="level1"
PG_CONF=/etc/PG.conf
PG_LOG=/var/log/PG.log
PG_LIST=/etc/p2p.p2b.p2p
#The URL where the blocklists reside
URL=http://www.bluetack.co.uk/config
#The format of the lists to download
SUFFIX=gz
#The format after unpacking
SUFFIX2=txt

endscript () {
date +"------------ "%F" "%X" "%Z" End PeerGuardian Script"
exit $1
}
date +"------------ "%F" "%X" "%Z" Begin PeerGuardian $1"


case "$1" in
'start')
    cd "$PG_ETC"
    # check if blockfiles were updated:
    UPDATED=""
    for i in $BLOCKLISTS ; do
    TIMESTAMP=0
    if [ -e $i.$SUFFIX ] ; then
    TIMESTAMP=`stat --format=%y $i.$SUFFIX`
    echo "File $i.$SUFFIX last updated $TIMESTAMP"
    TIMESTAMP=`stat --format=%Y $i.$SUFFIX`
    fi
    wget -N $URL/$i.$SUFFIX
    if [ `stat --format=%Y $i.$SUFFIX` -gt $TIMESTAMP ] ; then
    UPDATED=$i
    fi
    done
    
    # if none of the blockfiles were updated:
    if [ -z $UPDATED ] ; then
    echo "No blocklists needed updating."
    echo "Starting PeerGuardian"
    mv $PG_LOG $PG_LOG.backup
    peerguardnf -h -m -d -c "$PG_CONF" -l "$PG_LOG"
    endscript 0
    fi
    
    # if any blockfiles were updated:
    for i in $BLOCKLISTS ; do
    gunzip -c $i.$SUFFIX > $i.$SUFFIX2
    BLOCKLISTSCAT="$BLOCKLISTSCAT $i.$SUFFIX2"
    done
    cat $BLOCKLISTSCAT | peerguardnf -f merged.p2b.p2p
    for i in $BLOCKLISTS ; do
    rm $i.$SUFFIX2
    done
    # uncomment below to unblock Yahoo! Mail and whatever
    # else needs unblocking here. Do this also in the
    # restart section.
    grep -v -i "yahoo\!" merged.p2b.p2p | grep -v -i "Microsoft" | grep -v "Google" > merged.p2b.p2p.tmp
    mv merged.p2b.p2p.tmp merged.p2b.p2p
    mv $PG_LIST $PG_LIST.backup
    mv merged.p2b.p2p $PG_LIST
    mv $PG_LOG $PG_LOG.backup
    echo "Starting PeerGuardian"
    peerguardnf -h -m -d -c "$PG_CONF" -l "$PG_LOG"
    endscript 0
    ;;

'stop')
    echo "Stopping PeerGuardian"
    killall peerguardnf > /dev/null 2>&1
    endscript 0
    ;;

'restart')
    cd "$PG_ETC"
    # check if blockfiles were updated:
    UPDATED=""
    for i in $BLOCKLISTS ; do
    TIMESTAMP=0
    if [ -e $i.$SUFFIX ] ; then
    TIMESTAMP=`stat --format=%y $i.$SUFFIX`
    echo "File $i.$SUFFIX last updated $TIMESTAMP"
    TIMESTAMP=`stat --format=%Y $i.$SUFFIX`
    fi
    wget -N $URL/$i.$SUFFIX
    if [ `stat --format=%Y $i.$SUFFIX` -gt $TIMESTAMP ] ; then
    UPDATED=$i
    fi
    done
    
    # if none of the blockfiles were updated:
    if [ -z $UPDATED ] ; then
    echo "No blocklists needed updating."
    echo "Stopping PeerGuardian"
    killall peerguardnf > /dev/null 2>&1
    mv $PG_LOG $PG_LOG.backup
    sleep 4
    echo "Starting PeerGuardian"
    peerguardnf -h -m -d -c "$PG_CONF" -l "$PG_LOG"
    endscript 0
    fi
    
    # if any blockfiles were updated:
    for i in $BLOCKLISTS ; do
    gunzip -c $i.$SUFFIX > $i.$SUFFIX2
    BLOCKLISTSCAT="$BLOCKLISTSCAT $i.$SUFFIX2"
    done
    cat $BLOCKLISTSCAT | peerguardnf -f merged.p2b.p2p
    for i in $BLOCKLISTS ; do
    rm $i.$SUFFIX2
    done
    # uncomment below to unblock Yahoo! Mail and whatever
    # else needs unblocking here. Do this also in the
    # restart section.
    grep -v -i "yahoo\!" merged.p2b.p2p | grep -v -i "Microsoft" | grep -v "Google" > merged.p2b.p2p.tmp
    mv merged.p2b.p2p.tmp merged.p2b.p2p
    echo "Stopping PeerGuardian"
    killall peerguardnf > /dev/null 2>&1
    mv $PG_LIST $PG_LIST.backup
    mv merged.p2b.p2p $PG_LIST
    mv $PG_LOG $PG_LOG.backup
    sleep 4
    echo "Starting PeerGuardian"
    peerguardnf -h -m -d -c "$PG_CONF" -l "$PG_LOG"
    endscript 0
    ;;

*)
    echo "Usage: $0 { start | stop | restart }"
    ;;
esac
exit 0
You can now handle PeerGuardian by just typing in a console one of the following commands:

Code:
sudo peerguardian.sh start
IF there are updates for the blocklists available they are updated, the old blocklist and the log-file are backuped and PeerGuardian is started.

Code:
sudo peerguardian.sh restart
If there are updates for the blocklists available they are updated, the old blocklist and the log-file are backuped, old PeerGuardian processes are killed and after 4 seconds PeerGuardian is started again.

Code:
sudo peerguardian.sh stop
PeerGuardian is stopped.

This following section is optional. If you want Peerguardian to run at startup and update the blocklists daily.

Code:
ln -s /usr/local/bin/peerguardian.sh /etc/init.d/peerguardian.sh
ln -s /etc/init.d/peerguardian.sh /etc/rc0.d/K20peerguardian.sh
ln -s /etc/init.d/peerguardian.sh /etc/rc2.d/S95peerguardian.sh
ln -s /etc/init.d/peerguardian.sh /etc/rc3.d/S95peerguardian.sh
ln -s /etc/init.d/peerguardian.sh /etc/rc4.d/S95peerguardian.sh
ln -s /etc/init.d/peerguardian.sh /etc/rc5.d/S95peerguardian.sh
ln -s /etc/init.d/peerguardian.sh /etc/rc6.d/K20peerguardian.sh
Now we need to create a CRON entry to update and restart Peerguardian daily. Create a blank text file called pg.

Code:
sudo gedit pg
Paste the following into it:

Code:
#!/bin/sh

/usr/local/bin/peerguardian.sh restart
Save and close then we need to copy it and set permissions.

Code:
sudo cp pg /etc/cron.daily
Code:
sudo chmod -c 755 /etc/cron.daily/pg
Now we're done. You will notice in the script that connections to Yahoo, Microsoft and Google are allowed. I was having issues with connecting to MSN and Gtalk in Gaim along with connectiong to various Google sites. If you don't use these service you can leave that out.

Everything will be logged in /var/log/PG.log

This is the original source for this info. I just changed it a bit.
Kokanee is offline   Reply With Quote
Old November 28th, 2005   #2
ounas
A Carafe of Ubuntu
 
ounas's Avatar
 
Join Date: Aug 2005
Location: North of the Artic
Beans: 89
Ubuntu Intrepid Ibex (testing)
Re: HOWTO: Peerguardian Installation and automatic updates

Thanks, I shall try this out.

_ounas
__________________
I forgot that love existed - Van Morrison
ounas is offline   Reply With Quote
Old November 28th, 2005   #3
Arktis
Quad Shot of Ubuntu
 
Arktis's Avatar
 
Join Date: Jan 2005
Beans: 290
Re: HOWTO: Peerguardian Installation and automatic updates

Oh crap... I just completed a howto on this covering installation from source. In my defense, I didn't see this, and I did search.. but I realize now that when searching, I spelled guardian as "gaurdian" by mistake and thus only came up with 3 results. Ah well. Sorry. Maybe it won't be approved by the mods.
__________________
...
Arktis is offline   Reply With Quote
Old November 29th, 2005   #4
ephman
Way Too Much Ubuntu
 
ephman's Avatar
 
Join Date: Jun 2005
Beans: 230
Re: HOWTO: Peerguardian Installation and automatic updates

Never mind below, all is well, i had to start the script again and it worked fine.


hi,

thanks for the howto, i've been looking for something like this. here's an error i get when i start peerguardian, at least i think it's an error, any help would be appreciated.

root@wintermute:/home/ephman/Desktop# sudo peerguardian.sh start
------------ 2005-11-29 05:54:48 AM EST Begin PeerGuardian start
--05:54:49-- http://www.bluetack.co.uk/config/level1.gz
=> `level1.gz'
Resolving www.bluetack.co.uk... failed: Name or service not known.
stat: cannot stat `level1.gz': No such file or directory
/usr/local/bin/peerguardian.sh: line 57: [: -gt: unary operator expected
No blocklists needed updating.
Starting PeerGuardian
mv: cannot stat `/var/log/PG.log': No such file or directory
------------ 2005-11-29 05:54:59 AM EST End PeerGuardian Script
root@wintermute:/home/ephman/Desktop#


thanks for the bandwidth,
ephman

Last edited by ephman; November 29th, 2005 at 07:16 AM..
ephman is offline   Reply With Quote
Old November 30th, 2005   #5
ubuntu27
May the Ubuntu Be With You!
 
ubuntu27's Avatar
 
Join Date: Apr 2005
Location: USA
My beans are hidden!
Ubuntu 9.10 Karmic Koala
Re: HOWTO: Peerguardian Installation and automatic updates

In this how to for "PeerGuardian 2" or "PeerGuardian Lite" or neither?
ubuntu27 is offline   Reply With Quote
Old December 1st, 2005   #6
Grimlock
5 Cups of Ubuntu
 
Grimlock's Avatar
 
Join Date: Oct 2005
Beans: 33
Re: HOWTO: Peerguardian Installation and automatic updates

I've installed it but I can still get on the riaa website?????
__________________
Micro$oft I fart in your general direction!!!
Grimlock is offline   Reply With Quote
Old December 1st, 2005   #7
ephman
Way Too Much Ubuntu
 
ephman's Avatar
 
Join Date: Jun 2005
Beans: 230
Re: HOWTO: Peerguardian Installation and automatic updates

same here.
ephman is offline   Reply With Quote
Old December 2nd, 2005   #8
Kokanee
5 Cups of Ubuntu
 
Kokanee's Avatar
 
Join Date: Oct 2005
Location: Regina, SK
Beans: 38
Ubuntu Breezy 5.10
Send a message via ICQ to Kokanee Send a message via AIM to Kokanee
Re: HOWTO: Peerguardian Installation and automatic updates

Quote:
Originally Posted by ubuntu27
In this how to for "PeerGuardian 2" or "PeerGuardian Lite" or neither?
PeerGuardian for Linux is actually the Lite version. PeerGuardian 2 is an awful Windows app with a useless gui.
Kokanee is offline   Reply With Quote
Old December 2nd, 2005   #9
Kokanee
5 Cups of Ubuntu
 
Kokanee's Avatar
 
Join Date: Oct 2005
Location: Regina, SK
Beans: 38
Ubuntu Breezy 5.10
Send a message via ICQ to Kokanee Send a message via AIM to Kokanee
Re: HOWTO: Peerguardian Installation and automatic updates

Quote:
Originally Posted by Grimlock
I've installed it but I can still get on the riaa website?????
Visiting a website is harmless. Open up a torrent or connect to aMule or something then check your /var/log/PG.log file. It should show lots of dropped connections.
Kokanee is offline   Reply With Quote
Old December 4th, 2005   #10
ace2005
Gee! These Aren't Roasted!
 
Join Date: Aug 2005
Beans: 182
Re: HOWTO: Peerguardian Installation and automatic updates

Um... guys

Do a scan:

http://scan.sygatetech.com/stealthscan.html

Who here thinks there is a problem
ace2005 is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:11 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry