1、
iptalbes 的有多个MARK 模块..用法各不相同..一直没有完全明白..希望高手解释一下各功能的使用及区别....
-m mark
-m connmark
-j MARK
-j CONNMARK
-j CONNSECMARK
-j SECMARK
解释:
小写的是数据包匹配模块,大写的是数据包修改模块。
带 CONN 的是连接的标记,不带的是标记数据包的。
带 SEC 的是用于处理 IPSEC 数据的,不带的是处理一般数据的。
2、
CONNMARK target options:
--set-xmark value[/ctmask] Zero mask bits and XOR ctmark with value
--save-mark [--ctmask mask] [--nfmask mask]
Copy ctmark to nfmark using masks
--restore-mark [--ctmask mask] [--nfmask mask]
Copy nfmark to ctmark using masks
--set-mark value[/mask] Set conntrack mark value
--save-mark [--mask mask] Save the packet nfmark in the connection
--restore-mark [--mask mask] Restore saved nfmark value
--and-mark value Binary AND the ctmark with bits
--or-mark value Binary OR the ctmark with bits
--xor-mark value Binary XOR the ctmark with bits
在这个模块中..--save-mark,--set-mark,--restore-mark
这些常用的..如何用..有什么区别呢
--set-mark value[/mask] Set conntrack mark value
--save-mark [--mask mask] Save the packet nfmark in the connection
--restore-mark [--mask mask] Restore saved nfmark value
就像描述中说的一样
--set-mark 是直接设置连接中的 mark(注意,不是设置数据包的)
--save-mark 是把数据包中的 mark 设置到连接中
--restore-mark 是把连接中的 mark 设置到数据包中
具体这些功能有什么意义呢?看如下规则
这个功能在 ipp2p 结合 tc 进行限速时特别有用
http://www.ipp2p.org/docu_en.html#example
对于限速来说...包肯定是在某一个连接中...
就象之前我用IPTABLES L7标记文件大小限制速度..那就应该用CONNMARK了..这是对整个连接的包进行限速成了...也正是我们需要的..
但白金大哥说过..L7本身就有连接跟踪的作用..而IP2PP没有...所以得通过上面的方式..转换成第个包...
作了个小节....呵
3、
mark 打标记 用 mangle 表
iptables -t mangle -A PREROUTING -mttl --ttl-eq 64 -j MARK --set-mark 10
iptables -t mangle -A PREROUTING -mttl --ttl-eq 123 -j MARK --set-mark 20
iptables -t filter -A FORWARD -m mark--mark 10 -j ACCEPT
iptables -t filter -A FORWARD -m mark--mark 20 -j DROP
打标记的位置很重要
表优先级 mangle --------> nat ------>filter
http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=1926255&highlight=