Filtering P2P network traffic with ipp2p
Posted by rak on Wed 14 Nov 2007 at 12:10
Large and medium size corporate institutional networks suffer now a days from "smart" users who try to get their latest Movie/soft/Music/TVShow downloaded in their office.
Beside the moral/legal dispute these activities present the network admins with some troubles. To begin with a considerable downgrade in the network performance, and the need to comply with local policy and legal restrictions, and of course the admins needs to have full band with for they own downloads.
ipp2p is a reasonable stable product, I 've use it for 2 years in a large network 4 class C networks in an university environment. Users were use to abuse the network for personal downloads, and after chasing and punishing them for some time we chose to block the traffic once and for all.
ipp2p works by recognizing patterns in the payload of packages, thus allowing the admin, to restrict, prioritize or even block, as we did, the traffic.
It has 2 components a kernel module ipt_ipp2p.o (for v2.4.x) or ipt_ipp2p.ko (for 2.6.x) and an iptables module libipt_ipp2p.so, both must be compiled from source package downloaded from the ipp2p site. (There are no packages for debian stable, testing or unstable.)
There are some thing you must take into consideration, when compiling this program under Debian since, there are some requirements involved..
The headers package for your kernel must be installed, and so must the source code of the kernel and the iptables package. (It should be able to compile with the iptables-dev package but I haven't tried that so far.)
apt-get intall linux-kernel-header apt-get install linux-source-(kernel version) apt-get source iptables
(Remember to add a source repository to your /etc/apt/source.list if you've not already got them present.)
For the kernel there is not much trouble if you are running the standard debian kernel. If you are not doing so, you will need to ensure that the headers are accessible to the Makefile. You can either make a symlink to the kernel source directory or edit the Makefile, with your favourite editor, I'll use joe, go to line 6 and set the appropriate path for it.
For iptables
ln -s (path_to_iptables_source)/iptables-1.3.6.0debian1/iptables /usr/src/iptables-1.3.6
For the kernel
ln -s /usr/src/linux-source-(you_kernel_version) /usr/src/linux
With these links in place you should be able to compile the ipp2p without trouble, well almost.
The first time I install this package it took some work, the second was almost impossible. As I later discovered googling around to have the Makefile working you need to change line 67 from this:
ld -shared -o libipt_ipp2p.so libipt_ipp2p.o
to this:
$(CC) -shared -o libipt_ipp2p.so libipt_ipp2p.o
Yes it is almost the same line no I dont know why, but it works..
Now you only have to install the kernel module and the iptables lib in the corresponding way.
For iptables]
cp libipt_ipp2p.so /lib/iptables
Test iptables
iptables -m ipp2p --help
This should retune lots of info about ipp2p and and example ending line as follows:
iptables -A FORWARD -m ipp2p --ipp2p -j MARK --set-mark 0x01 iptables -A FORWARD -p udp -m ipp2p --kazaa --bit -j DROP iptables -A FORWARD -p tcp -m ipp2p --edk --soul -j DROP
For your kernel
insmod ipt_ipp2p.o insmod ipt_ipp2p.ko [ depending on version ] depmod -a
You can test the module by running:
lsmod | grep ipp2p
This should return:
ipt_ipp2p 6592 6 x_tables 12676 7 xt_mac,ipt_ipp2p,xt_tcpudp,ip_tables,ipt_owner,ipt_REJECT,ipt_LOG
Or something similar, depending on your kernel configuration, what matter is that the ipt_ipp2p module is present.
So now you are set to go, the only thing left is setting up your firewall rules a simple drop everything rule would be like this:
iptables -A FORWARD -m ipp2p --bit -j DROP
Taken from the README example, more complex rules may be necessary according the firewall setup.
An admin friendly rule would be like:
iptables -I FORWARD -d admin_ip -m ipp2p --ipp2p -j ACCEPT
but if your co workers find out you will be in trouble ;)
Ejoy,
[ Parent | Reply to this comment ]
It also looks like the ipp2p project is not being maintained so I don't think the .22 version will get supported.
What are you thoughts?
thanks
[ Parent | Reply to this comment ]
http://kambing.ui.edu/gentoo-portage/net-firewall/ipp2p/files/ipp 2p-0.8.2-kernel-2.6.22.patch
[ Parent | Reply to this comment ]
suply: ld -shared -o libipt_ipp2p.so libipt_ipp2p.o
by: $(CC) -shared -o libipt_ipp2p.so libipt_ipp2p.o
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Cya
[ Parent | Reply to this comment ]
# iptables -A FORWARD -m ipp2p --bit -j DROP
iptables: Invalid argument
[ Parent | Reply to this comment ]
Did you try this command to test the install?
iptables -m ipp2p --help
If you have it configured correctly you should get some ipp2p output.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
SSL
SSH Port forwarding
Bittorent header encryption
I guess it won't work, nevertheless article is still useful.
Cheers,
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Never try to solve social problems with technology. This has always failed in history.
[ Parent | Reply to this comment ]
This was the best I could came with for now. Any better idea is always well came.
[ Parent | Reply to this comment ]
this test is OK!
This problem:
iptables -A FORWARD -m ipp2p --ipp2p -j DROP
iptables: Invalid argument
and
kernel: ip_tables: ipp2p match: invalid size 16 != 8
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
I'm in the same situation (the command line error and messages log record are the same).
Both, the ipp2p compilation and ipp2p kernel module loading performed without error. Trying the lsmod I obtained:
[root@srv ~]# lsmod | grep ipp2p
ipt_ipp2p 16128 0
x_tables 29257 7
Any idea?
Thanks
Andrew
[ Parent | Reply to this comment ]
# iptables -A FORWARD -m ipp2p --ipp2p -j DROP
iptables: Invalid argument
from /var/log/syslog:
kernel: ip_tables: ipp2p match: invalid size 16 != 8
# uname -r
2.6.18-6-amd64
[ Parent | Reply to this comment ]
http://gentoo.mirror.solnet.ch/net-firewall/ipp2p/files/ipp2p-0.8 .2-matchsize.patch
It worked for me.
[ Parent | Reply to this comment ]
Router:/usr/src/ipp2p-0.8.2# make
make -C /usr/src/linux SUBDIRS=/usr/src/ipp2p-0.8.2 modules
make[1]: Entering directory `/usr/src/linux-source-2.6.18'
WARNING: Symbol version dump /usr/src/linux-source-2.6.18/Module.symvers
is missing; modules will have no dependencies and modversions.
Building modules, stage 2.
MODPOST
/bin/sh: scripts/mod/modpost: No such file or directory
make[2]: *** [__modpost] Error 127
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/usr/src/linux-source-2.6.18'
make: *** [ipt_ipp2p.ko] Error 2
why ? Please help me !
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
code
aptitude build-essential linux-headers-`uname -r`
[ Parent | Reply to this comment ]
Good article! Thanks.
I faced some problem in order to be able to block the p2p traffic.
Here are my additional tasks:
apt-get install libncurses5
apt-get install libncurses5-dev
apt-get install gcc-3.3
make CC=gcc-3.3 menuconfig && make CC=gcc-3.3 prepare \
&& make CC=gcc-3.3 modules_prepare
Jorge Isaac Davila Lopez
Nicaragua Open Source
+505 430 5462
davila@nicaraguaopensource.com
[ Parent | Reply to this comment ]