日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Iptables Layer7禁止QQ、MSN、p2p软件(解决iptable 无法启动)

發布時間:2025/1/21 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Iptables Layer7禁止QQ、MSN、p2p软件(解决iptable 无法启动) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?弄了好幾天總算是解決了配置OK后,iptables?服務無法啟動的問題

?

1、下載所需要軟件包

linux-2.6.28.tar.gz?????????????
http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.28.tar.gz

iptables-1.4.5.tar.bz2??????????
http://netfilter.org/projects/iptables/files/iptables-1.4.5.tar.bz2

netfilter-layer7-v2.22.tar.gz???
http://sourceforge.net/projects/l7-filter/files/l7-filter%20kernel%20version/2.22/netfilter-layer7-v2.22.tar.gz/download

l7-protocols-2009-05-28.tar.gz??
http://sourceforge.net/projects/l7-filter/files/Protocol%20definitions/2009-05-28/l7-protocols-2009-05-28.tar.gz/download


2、把以上內核和軟件包解壓到/usr/src下
tar?-zxvf?linux-2.6.28.tar.gz?-C?/usr/src
tar?-zxvf?netfilter-layer7-v2.22.tar.gz?-C?/usr/src
tar?-zxvf?l7-protocols-2009-05-28.tar.gz?-C?/usr/src
tar?-jxvf?iptables-1.4.5.tar.bz2?-C?/usr/src

3、備份iptable?相關文件

??cp?/etc/rc.d/init.d/iptables?~/iptables

??cp?/etc/sysconfig/iptables-config??~/iptables-config

?

4、卸載原有的iptable

rpm?-e?iptables-ipv6??iptables?iptstate?--nodeps?

?

5、給新內核安裝layer7補丁?
cd?/usr/src/linux-2.6.28/

給新內核安裝layer7補丁?
cd?/usr/src/linux-2.6.28/
patch?-p1?<?/usr/src/netfilter-layer7-v2.22/kernel-2.6.25-2.6.28-layer7-2.22.patch

?

6、編譯新內核,修改內核配置項?

make?oldconfig?

注意:??
全部保持默認,直接回車。
(如果之前曾經編譯過,需要先執行?make?mrproper?。make?oldconfig會自動對比之前的kernel?config,根據之前版本的配置生成一個kernel?config,這樣方便我們在編譯新核心的時候,無須在從頭修改所有的核心設置)

make?menuconfig??(*為編譯到內核,M為編譯成模塊)

General?setup??--->
Prompt?for?development?and/or?incomplete?code/drivers??必選(M)

?

Networking??--->
Networking?options??--->
Network?packet?filtering?framework?(Netfilter)??--->
Core?Netfilter?Configuration??--->???該項下的所有項目建議都選上(M)

<M>?Netfilter?connection?tracking?support??這個項目必需選上,下面才會出現layer7的選項
<M>???"layer7"?match?support?????????必選???????????????????????????????
??????????Layer?7?debugging?output?????????????必選?

IP:?Netfilter?Configuration??--->????該項下的所有?項目必需都選上(M)

?

7、編譯并安裝新內核?
make
make?modules_install
make?install

8、設置新內核為默認啟動的內核
vi?/etc/gurb.conf

default=1?????把1改為0?
timeout=9?????設置等候時間為9秒

保存退出,重新啟動系統
reboot
編譯內核重啟后會報出?insmod:?error?inserting?‘/lib/dm-region-hash.ko’:?–1?File?exits,解決方法見下文。

重啟登錄后檢查內核版本:uname?-a

Linux?bogon?2.6.28?#1?SMP?Sat?Aug?24?20:31:54?EDT?2013?i686?i686?i386?GNU/Linux

?

9、編譯安裝iptables并支持layer7?
cd?/usr/src/iptables-1.4.5/
cp?/usr/src/netfilter-layer7-v2.22/iptables-1.4.3forward-for-kernel-2.6.20forward/*.*?extensions/

./configure?--prefix=/usr??--with-ksource=/usr/src/linux-2.6.28

make

make?install

mv?~/iptables?/etc/rc.d/init.d/

mv?~/iptables-config?/etc/sysconfig/iptables-config??

ln?–sv?/usr/sbin/iptables?/sbin/iptables

?

2.6.28.10?內核中?ip_conntrack_ftp?改名為?nf_conntrack_ftp

加模塊:?modprobe?nf_conntrack_ftp

?

?

10、安裝Layer7協議文件


cd?l7-protocols-2009-05-28
make?install

10、測試iptables版本是否生效?
/usr/local/sbin/iptables?-V

顯示如下,說明安裝成功:
iptables?v1.4.5

再來測試layer7模塊是否安裝成功
/usr/lptables?-m?layer7?--help

顯示如下,說明安裝成功:
[root@localhost?src]#?/usr/local/sbin/iptables?-m?layer7?--help
iptables?v1.4.5

Usage:?iptables?-[AD]?chain?rule-specification?[options]
???????iptables?-I?chain?[rulenum]?rule-specification?[options]
???????iptables?-R?chain?rulenum?rule-specification?[options]
???????iptables?-D?chain?rulenum?[options]
???????iptables?-[LS]?[chain?[rulenum]]?[options]
???????iptables?-[FZ]?[chain]?[options]
???????iptables?-[NX]?chain
???????iptables?-E?old-chain-name?new-chain-name
???????iptables?-P?chain?target?[options]
???????iptables?-h?(print?this?help?information)
。。。。。。。。。。。。。
。。。。。。。。。。。。。
。。。。。。。。。。。。。

layer7?match?options:
????--l7dir?<directory>?:?Look?for?patterns?here?instead?of?/etc/l7-protocols/
??????????????????????????(--l7dir?must?be?specified?before?--l7proto?if?used)
[!]?--l7proto?<name>:?Match?named?protocol?using?/etc/l7-protocols/.../name.pat

至此安裝過程完全完成。(看看你的iptables?能不能通過service?iptables?start?啟動)

?

編譯內核重啟后會報出?insmod:?error?inserting?‘/lib/dm-region-hash.ko’:?–1?File?exits
其實不影響啟動,解決方法如下:

1、解壓initrd?
cp?/boot/initrd-2.6.28.img?/tmp?
cd?/tmp/?

mkdir?newinitrd?
cd?newinitrd/?
zcat?../initrd-2.6.28.img?|?cpio?-i?
11264?blocks?


2、編輯init,刪掉其中重復的兩行
echo?"Loading?dm-region-hash.ko?module"?
insmod?/lib/dm-region-hash.ko?
echo?"Loading?dm-region-hash.ko?module"?
insmod?/lib/dm-region-hash.ko?


3、重新打包initrd?
find?.?|?cpio?-c?-o?>?../initrd?
11169?blocks?

cd?..?
gzip?-9?<?initrd?>?initrd-2.6.28.img

initrd-2.6.28.img就是重新打包的initrd了,然后把initrd.img拷貝到/boot就可以了,再reboot,就不會有之前的錯誤了。

?

以下是L7的限制語句

?iptables?-A?FORWARD?-m?layer7?--l7proto?xunlei?-j?DROP

?

轉載于:https://blog.51cto.com/andy110/1282324

總結

以上是生活随笔為你收集整理的Iptables Layer7禁止QQ、MSN、p2p软件(解决iptable 无法启动)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。