分类: LINUX
2012-01-06 14:58:42
yum grouplist
yum install "Development Libraries" "Development Tools"
tar zxvf linux-2.6.28.10.tar.gz -C /usr/src
tar zxvf netfilter-layer7-v2.22.tar.gz -C /usr/src
ln –s /usr/src/linux-2.6.28.10/ /usr/src/linux
cd /usr/src/linux/
patch -p1 < ../netfilter-layer7-v2.22/kernel-2.6.25-2.6.28-layer7-2.22.patch
cp /boot/config-2.6.18-164.el5 /usr/src/linux/.config
make menuconfig
yum install screen
screen
screen –r #查看screen
screen –r 3353 #调出
make
make modules_install
make install
make mrproper
make clean
uname –r
ifconfig
cp /etc/rc.d/init.d/iptables ~/iptables
cp /etc/sysconfig/iptables-config ~/
rpm -e iptables-ipv6 iptables iptstate --nodeps
tar jxvf iptables-1.4.6.tar.bz2 -C /usr/src
cd /usr/src/iptables-1.4.6
cp ../netfilter-layer7-v2.22/iptables-1.4.3forward-for-kernel-2.6.20forward/libxt_layer7.* ./extensions/
./configure --prefix=/usr --with-ksource=/usr/src/linux
make
make install
tar zxvf l7-protocols-2009-05-28.tar.gz
cd l7-protocols-2009-05-28
make install
mv ~/iptables /etc/rc.d/init.d/
mv ~/ iptables-config /etc/sysconfig/
which iptables
vi /etc/rc.d/init.d/iptables
-A FORWARD -s 192.168.1.128/26 -i eth1 -o eth0 -j ACCEPT
-A FORWARD -s 192.168.1.128/26 -i eth1 -o eth0 -j ACCEPT
#指定开放时间段
-A FORWARD -s 192.168.1.179/26 -i eth1 -o eth0 -m layer7 --l7proto qq -m time --timestart 11:00:00 --timestop 13:00:00 -j RE
JECT --reject-with icmp-port-unreachable
-A FORWARD -s 192.168.1.178/26 -i eth1 -o eth0 -m layer7 --l7proto qq -m time --timestart 11:00:00 --timestop 13:00:00 -j RE
JECT --reject-with icmp-port-unreachable
#-A FORWARD -s 192.168.1.129/26 -i eth1 -o eth0 -j ACCEPT
#-A FORWARD -s 192.168.1.128/26 -d 61.135.209.217/32 -i eth1 -o eth0 -j DROP
#-A FORWARD -s 192.168.1.128/26 -d 61.135.209.218/32 -i eth1 -o eth0 -j DROP
#-A FORWARD -s 192.168.1.128/26 -d 123.58.173.89/32 -i eth1 -o eth0 -p tcp -m tcp --dport 80 -j ACCEPT
#-A FORWARD -s 192.168.1.128/26 -d 123.58.173.106/32 -i eth1 -o eth0 -p tcp -m tcp --dport 80 -j ACCEPT
#-A FORWARD -s 192.168.1.128/26 -d 204.152.191.37/32 -i eth1 -o eth0 -p tcp -m tcp --dport 80 -j ACCEPT
#-A FORWARD -s 192.168.1.128/26 -d 199.6.1.164/32 -i eth1 -o eth0 -p tcp -m tcp --dport 80 -j ACCEPT
#-A FORWARD -s 192.168.1.128/26 -d 149.20.20.133/32 -i eth1 -o eth0 -p tcp -m tcp --dport 80 -j ACCEPT
#-A FORWARD -s 192.168.1.128/26 -d 130.239.17.4/32 -i eth1 -o eth0 -p tcp -m tcp --dport 80 -j ACCEPT
#-A FORWARD -s 192.168.1.128/26 -d 123.129.214.98/32 -i eth1 -o eth0 -p tcp -m tcp --dport 80 -j ACCEPT
#-A FORWARD -i eth0 -o eth1 -p tcp -m tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
#-A FORWARD -i eth1 -o eth0 -m time --timestart 09:00:00 --timestop 19:00:00 -j REJECT --reject-with icmp-port-unreachable
#限制7层应用程序
#-A FORWARD -i eth1 -o eth0 -m layer7 --l7proto qq -j REJECT --reject-with -icmp-port-unreachable
#-A FORWARD -i eth1 -o eth0 -m layer7 --l7proto msnmessenger -j REJECT --reject-with -icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m layer7 --l7proto edonkey -j REJECT --reject-with -icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m layer7 --l7proto bittorrent -j REJECT --reject-with -icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m layer7 --l7proto xunlei -j REJECT --reject-with -icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m layer7 --l7proto kugoo -j REJECT --reject-with -icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m layer7 --l7proto pplive -j REJECT --reject-with icmp-port-unreachable
#通过字符串限制
-A FORWARD -i eth1 -o eth0 -m string --string(以下关键字都要加上此选项,才生效) "qq.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m string "verycd.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m string "funsion.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m string "pptv.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m string "ppstream.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m string "uusee.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m string "youku.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m string "xunlei.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m string "tudou.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m string "56.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m string "ku6.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i eth1 -o eth0 -m string "6.cn.com" --algo bm --to 65535 -j REJECT --reject-with icmp-port-unreachable
#限速
#-A FORWARD -i eth0 -d 192.168.0.2 -m limit --limit 10/s --limit-burst 10 -j ACCEPT