手机版
你好,游客 登录 注册
背景:
阅读新闻

Linux下为iptables增加layer7补丁(Linux2.6.25内核) 图文详解

[日期:2013-08-10] 来源:Linux社区  作者:hucwuhen [字体:大 中 小]

二、重新编译iptables
    1、卸载现有iptables
shell> rpm -e iptables iptstat --nodeps

 
 
 2、合并iptables+layer7补丁

shell> tar jxvf iptables-1.4.2.tar.bz2 -C /usr/src/


 
shell> cd /usr/src/netfilter-layer7-v2.20/iptables-1.4.1.1-for-kernel-2.6.20forward/
shell> cp libxt_layer7.c libxt_layer7.man /usr/src/iptables-1.4.2/extensions/

 
 
3、编译安装
    shell> cd /usr/src/iptables-1.4.2/


 
4、安装l7-protocols模式包
shell> tar zxvf l7-protocols-2008-10-04.tar.gz -C /etc/
shell> mv /etc/l7-protocols-2008-10-04 /etc/l7-protocols


 
三、layer7规则示例
    1、layer7 match
shell> iptables -A FORWARD -m layer7 --l7proto qq -j DROP
shell> iptables -A FORWARD -m layer7 --l7proto msnmessenger -j DROP
shell> iptables -A FORWARD -m layer7 --l7proto msn-filetransfer -j DROP
shell> iptables -A FORWARD -m layer7 --l7proto xunlei -j DROP
shell> iptables -A FORWARD -m layer7 --l7proto edonkey -j DROP
shell> iptables -A FORWARD -m layer7 --l7proto bittorrent -j DROP

    2、string match
shell> iptables -A FORWARD -p udp --dport 53 -m string --string "tencent" --algo bm -j DROP
shell> iptables -A FORWARD -p udp --dport 53 -m string --string "verycd" --algo bm -j DROP
shell> iptables -A FORWARD -p tcp --dport 80 -m string --string "sex" --algo bm -j DROP

    3、state match
shell> iptables -A FORWARD -m state --state NEW -p tcp ! --syn -j DROP
shell> iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

    4、connlimit match
shell> iptables -A FORWARD -p tcp --syn -m connlimit --connlimit-above 100 --connlimit-mask 24 -j DROP

    5、time match
shell> iptables -A FORWARD -p tcp --dport 80 -m time --timestart 8:00 --timestop 17:00 --weekdays Mon,Tue,Wed,Thu,Fri -j ACCEPT

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款