netfilter/iptables模块功能中文介绍
功能介绍 获取最新patch-o-matic-ng的地址:ftp://ftp.netfilter.org/pub/patch-o-matic-ng/snapshot/
wget ftp://ftp.netfilter.org/pub/patch-o-matic-ng/snapshot/patch-o-matic-ng-20050331.tar.bz2
解压:
tar xjvf patch-o-matic-ng-20050331.tar.bz2 后,在/usr/src/下生成目录patch-o-matic-ng-20050331
进入该目录
# cd patch-o-matic-ng-20050331
统计一下
# ls |wc -l
99
其中共94个目录,就是说有九十多个拓展功能.这里只对部分感兴趣,对这些进行介绍.
patch-o-matic-ng-20050331目录下有README 和README.newpatches.不过都是英文的,大概是介绍怎么应用这些补丁和使用约定.里面每个拓展功能为一个目录,每个目录下面都有info(信息) 和help(使用帮助)文件,info里面一般是这样的:
Title: terse description of the patch 标题: 这个补丁的简单描述
Author: author (name, E-mail address) 作者(名字,email地址)
Status: Testing|Experimental|Alpha|Beta|Stable 状况:试验的|根据实验的|测试一版|测试二版|稳定的
Repository: submitted|pending|base|extra贮仓库:顺从的|未决的|基础的|额外的
Requires: repository-entry ==|>|<|>=|<= kernel-version|iptables-version 要求: 贮仓库==|>|<|>=|<=内核版本|iptables版本
Depends: patch-name 依赖性:(否)补丁名字
Recompile: kernel|netfilter|iptables 重新编译:内核|netfilter|iptables
Successor: patch-name 继承者: 补丁名字
1. string(字符串匹配,可以用做内容过滤)
# cat string/info
Title: iptables string match (标题: iptables 字符串匹配)
Author: Emmanuel Roger (作者:名字,email地址)
Status: Working, not with kernel 2.4.9 (状况:正常工作, 但不能在内核2.4.9工作)
Repository: extra (贮仓库: 额外的)
Requires: linux < 2.6.0 (要求: linux < 2.6.0)
# cat string/help
This patch adds CONFIG_IP_NF_MATCH_STRING which allows you to
match a string in a whole packet.
THIS PATCH DOES NOT WORK WITH KERNEL 2.4.9 !!!
翻译:这个补丁增加CONFIG_IP_NF_MATCH_STRING,允许在一整个包里面匹配一个字符串.
译者:这个功能真是值得一用,实际上应该说是可以做内容过滤吧,令人兴奋啊.我测试过,连中文也支持,我是这样测试它的:
iptables -I FORWARD -m string --string "腾讯" -j DROP
iptables -I FORWARD -s 192.168.3.159 -m string --string "qq.com" -j DROP
iptables -I FORWARD -d 192.168.3.0/24 -m string --string "宽频影院" -j DROP
iptables -I FORWARD -d 192.168.3.0/24 -m string --string "×××" -j DROP
iptables -I FORWARD -d 192.168.3.0/24 -p tcp --sport 80 -m string --string "广告" -j DROP
至于怎么灵活运用就要看自己的需要了.
2. comment (备注匹配,可以支持最多256个字符)
# cat comment/info
Title: iptables comment match (标题: iptables 注释匹配)
Author: Brad Fisher (作者(名字,email地址brad@info-link.net))
Status: Part of 2.6.x mainline(状况:2.6.x主流版本的一部分)
Repository: submitted (贮仓库: 顺从的)
Requires: linux == 2.4 (要求: linux == 2.4)
Recompile: netfilter, iptables(重新编译:netfilter|iptables)
# cat comment/help This option adds CONFIG_IP_NF_MATCH_COMMENT, which supplies a comment
match module. This match allows you to add comments (up to 256 characters)
to any rule.
Supported options:
--comment COMMENT
翻译:这个选项增加CONFIG_IP_NF_MATCH_COMMENT,补充一个注释匹配模块.这个匹允许你增加一个备注都任何规则,这个备注最多支持256个字符,例如
Example:(例子:)
-A INPUT -s 192.168.0.0/16 -m comment --comment "A privatized IP block"
译者:我是这样测试使用这个comment
iptables -I FORWARD -s 192.168.3.159 -p tcp --dport 80 -j DROP -m comment --comment "the bad guy can not online"
iptables -I FORWARD -s 192.168.3.159 -m string --string "qq.com" -j DROP -m comment --comment "denny go to qq.com"
这样在iptables -L时,就看到每条规则后面出现备注的内容.可以提高可读和理解该条规则的作用.
这个comment 在2.6.x中已经被正式收录.
3. connlimit(同时连接个数限制匹配)
# cat connlimit/info
Title: iptables connlimit match (标题: iptables同时连接个数限制匹配)
Author: Gerd Knorr (作者:名字,email地址)
Status: ItWorksForMe (状态:我可以运作)
Repository: base (贮仓库: 基础的)
# cat connlimit/help
This adds an iptables match which allows you to restrict the number of parallel TCP connections to a server per client IP address(or address block).
翻译:这个增加一个iptables匹配允许你限制每个客户ip地址的并发tcp连接,即同时连接到一个服务器个数.
Examples: 例子:
# allow 2 telnet connections per client host (允许每个客户机同时两个telnet连接)
iptables -p tcp --syn --dport 23 -m connlimit --connlimit-above 2 -j REJECT
# you can also match the other way around:(你也可以匹配其他的方法:)
iptables -p tcp --syn --dport 23 -m connlimit ! --connlimit-above 2 -j ACCEPT
# limit the nr of parallel http requests to 16 per class C sized (这下面例子限制80端口最多同时16个连接请求)
# network (24 bit netmask)
iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 16 --connlimit-mask 24 -j REJECT
模块 connlimit 作用:连接限制
--connlimit-above n 限制为多少个
--connlimit-mask n 这组主机的掩码,默认是connlimit-mask 32 ,即每ip.
这个主要可以限制内网用户的网络使用,对服务器而言则可以限制每个ip发起的连接数...比较实用
例如:只允许每个ip同时5个80端口转发,超过的丢弃:
iptables -I FORWARD -p tcp --syn --dport 80 -m connlimit --connlimit-above 5 -j DROP
例如:只允许每组C类ip同时10个80端口转发:
iptables -I FORWARD -p tcp --syn --dport 80 -m connlimit --connlimit-above 10 --connlimit-mask 24 -j DROP
例如:为了防止DOS太多连接进来,那么可以允许最多15个初始连接,超过的丢弃.
/sbin/iptables -A INPUT -s 192.186.1.0/24 -p tcp --syn -m connlimit --connlimit-above 15 -j DROP
/sbin/iptables -A INPUT -s 192.186.1.0/24 -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT
4. time(时间匹配)
# cat time/info Title: iptables ``time'' match (标题: iptables时间匹配)
Author: Fabrice MARIE (作者:名字,email地址)
Status: Works within it's limitations (状况:运作)
Repository: base (贮仓库: 基础的)
# cat time/help
This option adds CONFIG_IP_NF_MATCH_TIME, which supplies a time match module.
This match allows you to filter based on the packet arrival time/date(arrival time/date at the machine which the netfilter is running on) or
departure time/date (for locally generated packets).
翻译:这个选项增加一个时间匹配模块,这个匹配允许你过滤基于包到达时间/日期(这个到达时间和日期是指这个netfilter运行的机器上的)或者发出时间/日期(本地产生的信息包)
Supported options are: (支持选项有:)
(开始时间 值)
Match only if it is after `value' (Inclusive, format: HH:MM ; default 00:00).
(只是匹配在这个值之后)(包括格式HH:MM ; 默认 00:00)
(结束时间 值)
Match only if it is before `value' (Inclusive, format: HH:MM ; default 23:59).
(只是匹配在这个值之前的)(包括格式HH:MM ; 默认 23:59)
(--天 天列表)
Match only if today is one of the given days. (format: Mon,Tue,Wed,Thu,Fri,Sat,Sun ; default everyday)
(只是匹配已经给出的天,格式Mon,Tue,Wed,Thu,Fri,Sat,Sun ;默认每天)
(开始日期 日期)
Match only if it is after `date' (Inclusive, format: YYYY]]]] h,m,s start from 0 ; default to 1970)
(只是匹配这个开始日期值之后的(包括,格式: YYYY]]]] h,m,s start from 0 ; 默认是1970):
Match only if it is before `date' (Inclusive, format: YYYY]]]] h,m,s start from 0 ; default to 2037)
(只是匹配这个开始日期值之前的(包括,格式: YYYY]]]] h,m,s start from 0 ; 默认是2037):
Example: (例子:)
-A INPUT -m time --timestart 8:00 --timestop 18:00 --days Mon,Tue,Wed,Thu,Fri
will match packets that have an arrival timestamp in the range 8:00->18:00 from Monday to Friday.
(上面将匹配从到达日期是星期一至星期五时间从8:00至18:00的包)
-A OUTPUT -m time --timestart 8:00 --timestop 18:00 --Days Mon --date-stop 2010
will match the packets (locally generated) that have a departure timestamp in the range 8:00->18:00 on Monday only, until 2010
(上面将匹配本地产生的时间范围直到2010年为止的每个星期一8:00至18:00的包)
NOTE: the time match does not track changes in daylight savings time

5. iprange (ip范围匹配)
# cat iprange/info
Title: iptables iprange match (标题: iptables范围匹配)
Author: Jozsef Kadlecsik (作者:名字,email地址)
Status: Works (状况:运作)
Repository: base (贮仓库: 基础的)
# cat iprange/help
This patch makes possible to match source/destination IP addresses against inclusive IP address ranges.
翻译: 这个补丁令匹配源/目标 IP地址可以倚着给出的地址范围进行匹配
Examples:(例子)
iptables -A FORWARD -m iprange --src-range 192.168.1.5-192.168.1.124 -j ACCEPT
这个例子是允许源ip地址范围192.168.1.5-192.168.1.124的包通过
iptables -A FORWARD -m iprange --dst-range 10.0.0.0-10.255.255.255 -j ACCEPT
这个例子是允许目标ip地址范围10.0.0.0-10.255.255.255的包通过

6. geoip(根据地理位置匹配)
# cat geoip/info
Title: iptables geoip match (标题: iptables国家地区匹配)
Author: Samuel Jean ; Nicolas Bouliane (作者:名字,email地址)
Status: Testing (状况:测试)
Repository: extra (贮仓库: 额外的)
Recompile: netfilter, iptables (重新编译: netfilter, iptables)
# cat geoip/help
This patch makes possible to match a packet by its source or destination country.
翻译:这个补丁令一个包能够根据源或目的国家(地区)匹配
GeoIP options: (选项:)
--src-cc, --source-country country
Match packet coming from (one of) the specified country(ies)
根据包的来源(或非来源)地区匹配
--dst-cc, --destination-country country
Match packet going to (one of) the specified country(ies)
根据包的去向(或非去向)地区匹配
NOTE: The country is inputed by its ISO3166 code.
注意:这个国家地区列表放在ISO3166编码里
The only extra files you need is a binary db (geoipdb.bin) & its index file (geoipdb.idx).Both files are generated from a countries & subnets database with the csv2bin tool,available at www.cookinglinux.org/geoip/. Both files MUST also be moved in /var/geoip/ as the shared library is statically looking for that pathname (ex.: /var/geoip/geoipdb.bin).
这个你需要额外的二进位文件geoipdb.bin 和它的索引文件geoipdb.idx.这两个文件是国家地区网络数据库,是用csv2bin 工具生成的,可以在www.cookinglinux.org/geoip/得到.这些文件必须放在/var/geoip/下,作为一个共享库查找路径名字如/var/geoip/geoipdb.bin

7. Nth(第n个包匹配)
# cat nth/info
Title: iptables nth match (标题: iptables第N个匹配)
Author: Fabrice MARIE (作者:名字,email地址)
Status: Works (状况:运作)
Repository: base (贮仓库: 基础的)
# cat nth/help
This option adds an iptables `Nth' match, which allows you to match every Nth packet encountered. By default there are 16 different counters that can be used.
翻译: 这个选项增加一个第N个匹配,允许你匹配每隔N个包,默认有16不同的计算方法可以使用
This match functions in one of two ways
1) Match ever Nth packet, and only the Nth packet.
example:(例子)
iptables -t mangle -A PREROUTING -m nth --every 10 -j DROP
This rule will drop every 10th packet.
这个规则将丢弃每隔10个包
2) Unique rule for every packet. This is an easy and quick method to produce load-balancing for both inbound and outbound.
为每一个包应用一个独特的规则,这样是一个容易和快速的负载均衡方法
example: (例如)
iptables -t nat -A POSTROUTING -o eth0 -m nth --counter 7 --every 3 --packet 0 -j SNAT --to-source 10.0.0.5
iptables -t nat -A POSTROUTING -o eth0 -m nth --counter 7 --every 3 --packet 1 -j SNAT --to-source 10.0.0.6
iptables -t nat -A POSTROUTING -o eth0 -m nth --counter 7 --every 3 --packet 2 -j SNAT --to-source 10.0.0.7
This example evenly splits connections between the three SNAT addresses.
上面例子由三个源ip地址平滑分割连接
By using the mangle table and iproute2, you can setup complex load-balanced routing. There's lot of other uses. Be creative!
配合iptables 的mangle表和高级路由iproute2,你能设置一个复合的负载平衡路由.还有其他的用途,具有创造性的设置
Suppported options are: (支持选项有:)
--every Nth Match every Nth packet (匹配每N 个包)
num Use counter 0-15 (default:0) (用计算器(默认是0))
num Initialize the counter at the number 'num' instead of 0. Must be between 0 and Nth-1
(初始化一个计算器,用这个num值而不是0. 必需是在0和N减1之间的数
num Match on 'num' packet. Must be between 0 and Nth-1. If --packet is used for a counter than
there must be Nth number of --packet rules, covering all values between 0 and Nth-1 inclusively.
匹配'num' 包,必需是在0和N减1之间的数,如果该包被用一个计算器,必需是第Nth数字包规则,并覆盖0至Nth-1的所有值(这个翻译得不好,请指正)

8. ipp2p(点对点匹配)
# cat ipp2p/info
Title: Detects some P2P packets (标题: 侦查P2P包)
Author: Eicke Friedrich (作者:名字,email地址)
Status: Stable (状况:稳定的)
Repository: extra (贮仓库: 额外的)
Recompile: netfilter, iptables (重新编译:netfilter|iptables)
# cat ipp2p/help
This option makes possible to match some P2P packets therefore helps controlling such traffic.
Dropping all matches prohibits P2P networks.
Combined with conntrack,CONNMARK and a packet scheduler it can be used for accounting or shaping of P2P traffic.
这个选项能够匹配某些P2P包,帮助控制流量.丢弃所有匹配的P2P.结合连接跟踪,和一个包的调度器,它能被用作计算和×××一个P2流量
Examples: (例如:)
iptables -A FORWARD -m ipp2p --edk --kazaa --bit -j DROP
iptables -A FORWARD -p tcp -m ipp2p --ares -j DROP
iptables -A FORWARD -p udp -m ipp2p --kazaa -j DROP
上例可以封杀很多bt等的P2P软件.
更多参数更详细的参考还有ipp2p/iptables/extensions/libipt_ipp2p.man或http://www.ipp2p.org
9. quota(配额匹配)
# cat quota/info Title: iptables quota match (标题: iptables配额匹配)
Author: Sam Johnston (作者:名字,email地址)
Status: worksforme (状况:运作的)
Repository: base (贮仓库: 基础的)
# cat quota/help
This option adds CONFIG_IP_NF_MATCH_QUOTA, which implements network quotas by decrementing a byte counter with each packet.
这个选项增加一个模块匹配包实现网络包通过的配额
Supported options are: (支持选项有:)
--quota
The quota in bytes. (用bytes为单位)
iptables -I FORWARD -s 192.168.3.159 -p tcp --dport 80 -m quota --quota 500 -j DROP
上例是这样的,在ip192.168.3.159的目标端口为80匹配的500个字节内,将被丢弃.直到匹配完这500字节后,才不会丢弃,就是说,才可以打开网页.
KNOWN BUGS: this does not work on SMP systems.
知道的bug:这个不能工作在SMP系统上,(SMP, symmetric multiprocessing 多处理技术)
10.其他的.
推荐用cat /模块目录名/info 和cat /模块目录名/help 查看相应的模块信息和帮助.
由于我对其他某些模块不太感兴趣,或和我现在系统2.4.20-8有冲突,没有再列出翻译.如果有谁翻译了,可以让我参考下.谢谢
如果有更新,请看blog: http://kindgeorge.at.3322.org
相关资料:
安装编译 KindGeorge的:
http://blog.chinaunix.net/article.php?articleId=19797&blogId=4543
http://bbs.chinaunix.net/forum/viewtopic.php?t=525493
platinum 的http://www.chinaunix.net/jh/4/505370.html 如何给iptables添加新的模块v2.2(含视频教程)
hongfengyue 的http://www.chinaunix.net/jh/4/508312.html iptables 添加模块 (for kernel 2.6)
文章出处:http://www.diybl.com/course/6_system/linux/linuxjq/2007211/16665_3.html
 

转载于:https://blog.51cto.com/jxwpx/197026

iptables模块功能中文介绍相关推荐

  1. netfilter/iptables模块功能中文介绍

    功能介绍 (每个info和help本是英文的,为方便阅读我把它翻译成中文,由于水平有限,如果有误请有经验者来信指正) 获取最新patch-o-matic-ng的地址:[url]ftp://ftp.ne ...

  2. 云服务总线API管理模块功能梳理

    随着技术的不断发展,系统间的交互越来越依赖API,用户可以根据服务接口信息深入了解所需要的产品,这样不仅可以使大众快速理解产品作用,也可以进行更广泛的推广. ESB中API管理模块下API服务接口功能 ...

  3. ADS129X芯片中文资料(三)——数字功能部分介绍

    写在前面:最近做项目用到TI公司的用于生理信号测量的低功耗.8通道.24位模拟前端的ADS1298芯片,于是研究了下芯片手册.一百多页的芯片手册,经常看过后又记不清了,每次都得重新去翻阅,所以整理成中 ...

  4. ISP各个模块功能介绍

    ISP各个模块功能介绍

  5. WiFi选型_主设备WiFi模块,从设备WiFi模块功能介绍

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言 一.主设备WiFi模块 主设备WiFi模块功能介绍 二.从设备WiFi模块 从设备WiFi模块功能介绍 前言 在物联网 ...

  6. 菜鸟学PCB贴片及无线模块功能介绍

    视频录制:视频见链接 1.手机及录播软件,电脑及屏幕录制软件 2.PCB板及各种元器件(大概80个贴片) 3.恒温电洛铁,焊锡,松香及各种工具 贴片前先吃锡 焊接后效果 带外壳的效果(3种) 视频:h ...

  7. :UG模块功能介绍::

    § UG/Gateway(UG入口) 这个模块是UG的基本模块,包括打开.创建.存储等文件操作:着色.消隐.缩放等视图操作:视图布局:图层管理:绘图及绘图机队列管理:空间漫游,可以定 义漫游路径,生成 ...

  8. iOS开源项目MobileProject功能点介绍

    一:MobileProject简介 MobileProject项目是一个以MVC模式搭建的开源功能集合,基于Objective-C上面进行编写,意在解决新项目对于常见功能模块的重复开发,MobileP ...

  9. 基层教学组织评估系统5_系统管理员数据维护模块功能完善,优化教学组织名称的输入提示补全,项目打包部署篇

    目录 一.完善 二.项目打包 三.部署 四.报错解决 五.数据初始 一.完善 系统管理员数据维护模块功能完善 优化教学组织名称的输入提示补全 数据对应格式bug修复 1.系统管理员数据维护模块功能完善 ...

  10. TTCN简介 中文介绍

    TTCN简介 中文介绍 TTCN, 简介, 中文 TTCN, 简介, 中文 中文介绍 TTCN简介   TTCN- 3 (Testing and Test Control Notation – ver ...

最新文章

  1. 让Windows7运行速度更快的BIOS优化设置教程
  2. 字符串声明太大出现错误_搜索框输入中文出现单引号报错问题
  3. spell_picture二次升级版
  4. HashMap的put和get操作
  5. 工作171:阅读账号里面的新增调用接口操作
  6. 计算机视觉模型、学习和推理
  7. opencv SIFT角检测
  8. 学C++不得不看的一篇文章
  9. 在Web上运行Linux
  10. WIN32汇编 菜单和加速键的使用
  11. 温度反转效应(文末附2018数字IC后端最新校招笔试题目)
  12. Qt文档阅读笔记-trimmed()与simplified()官方解析与实例
  13. PAT A1008 Elevator (20 分)
  14. centos7部署calamari
  15. CS224N Assignment3 #3: Dependency Parsing(2022 winter)
  16. 一些有用的Latex模板(持续更新)
  17. 会议panel是什么意思中文_医学术语中的panel到底是什么意思
  18. UN Comtrade(联合国商品贸易统计数据库)数据爬取Python代码
  19. 记一次计通项目(网元设计)(更新中)
  20. 计算机网络 王道论坛2

热门文章

  1. 闭包、循环setTimeout、立即执行函数
  2. 【原创】大叔案例分享(4)定位分析--见证scala的强大
  3. [剑指offer] 42. 和为S的两个数字
  4. Access、CorelDRAW总结
  5. 第10题 正则表达式匹配(动态规划)
  6. 不同数据库之间的独立性
  7. PCIE设备与HOST之间的地址转换
  8. type与instance区别
  9. Java项目导出为jar包+导出第三方jar包+使用命令行调用+传参
  10. echarts配合循环计时器等出现的内存泄漏