使用Iptables的功能扩展全面封杀P2P流量

豆豆网   技术应用频道   2007年07月20日  【字号: 收藏本文

内容摘要:一种更简单的方法可以完全实现对P2P流量的完全控制, 该方法最大的特点是不用任何重新编译内核和模块。

  #cd /usr/src/iptables-1.2.9

  #export KERNEL_DIR=/usr/src/linux-2.4

  #export IPTABLES_DIR=/usr/src/iptables-1.2.9

  #make BINDIR=/sbin LIBDIR=/lib MANDIR=/usr/share/man install

  4.安装IPP2P软件包

  #cd /usr/src/ipp2p-0.8.0

  #make

  #cp libipt_ipp2p.so /lib/iptables

  #insmod ipt_ipp2p.o

  5.安装iptables-p2p软件包

  #cd /usr/src/iptables-p2p-0.3.0a

  #cp –a /usr/src/iptables-1.2.9/include/* /usr/include

  #make

  #cp kernel/ipt_p2p.o /lib/modules/2.4.20-8/kernel/net/ipv4/netfilter

  #cp iptables/libipt_p2p.o /lib/iptables/

  所有安装工作完成了,是不是很简单!

  五、功能简介

  1.ipp2p的使用说明

  #iptables -m ipp2p –help

  关于ipp2p段的说明:

IPP2P v0.8.0 options:
--ipp2p    Grab all known p2p packets
--edk     [TCP&UDP]    All known eDonkey/eMule/Overnet packets
--dc      [TCP]      All known Direct Connect packets
--kazaa    [TCP&UDP]    All known KaZaA packets
--gnu     [TCP&UDP]    All known Gnutella packets
--bit     [TCP&UDP]    All known BitTorrent packets
--apple    [TCP]      All known AppleJuice packets
--winmx    [TCP]      All known WinMX
--soul     [TCP]      All known SoulSeek
--ares     [TCP]      All known Ares
Note that the follwing options will have the same meaning:
'--ipp2p' is equal to '--edk --dc --kazaa --gnu --bit --apple --winmx --soul --ares'
IPP2P was intended for TCP only. Due to increasing usage of UDP we needed to change this.
You can now use -p udp to search UDP packets only or without -p switch to search UDP and TCP packets.
See README included with this package for more details or visit http://www.ipp2p.org
Examples:
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

  2.iptables-p2p的使用说明

  #iptables -m p2p –help

  P2P段的说明:

P2P match v0.3.0a options:
 --p2p-protocol [!] protocol[,...]
 --p2p ...
                match application-layer protocol
Valid p2p protocols:
    fasttrack
    gnutella
    edonkey
    dc
    bittorrent
    openft

  OK,一切准备就绪,就等你使用了,有专门识别包类型的控制(ipp2p),也有专门对准协议的控制(iptables-p2p),一切允许与否就看你的几条命令了!

  注:以上所有过程本人都经过测试通过,没发现任何问题,本人初次原创,不足之处希望大家谅解,如果能对一些朋友有帮助,在下非常荣幸!另外本人参考过网上多篇文章,再此对他们表示感谢!

  后记:写这篇文章的目的并不是要求所有网络管理人员全部屏蔽P2P下载软件,本人也是P2P软件使用的爱好者,但是使用软件时从来都是先设置连接数量和下载速度限制,以免影响别人的网络使用.由于深深感受到不加限制使用P2P下载软件对整个网络系统性能造成的严重影响,所以建议大家能在使用P2P下载软件时考虑网络环境,先设置连接数量和下载速度限制.同时也建议网络管理同行们根据情况到最后再考虑是否完全屏蔽掉P2P.

责编:豆豆技术应用

正在加载评论...