- 论坛徽章:
- 0
|
本帖最后由 kivis 于 2011-01-18 11:36 编辑
iptables中的状态(NEW,ESTABLISHED...)改变和设置在理解上的一些问题。
在学习linux下的iptables的时候,iptables指南1.1.9,1.2.2 ,里面在对状态机制讲解上,说到:
||All connection tracking is handled in the PREROUTING chain, except locally generated packets which are handled in
the OUTPUT chain. What this means is that iptables will do all recalculation of states and so on within the
PREROUTING chain. If we send the initial packet in a stream, the state gets set to NEW within the OUTPUT chain, and
when we receive a return packet, the state gets changed in the PREROUTING chain to ESTABLISHED, and so on. If the
first packet is not originated by ourself, the NEW state is set within the PREROUTING chain of course. So, all state
changes and calculations are done within the PREROUTING and OUTPUT chains of the nat table.摘自iptables指南-状态机制
-概述 部分||
特别是最后一句提到:So, all state changes and calculations are done within the PREROUTING and OUTPUT chains of the
nat table。"the nat tables"!!! 我的理解就是NEW状态,ESTABLISHED,等状态的形成都是在NAT的chains中进行改变和重新计算的
。然后我对状态机制在这句话的讲解进行了测试, 策略配置如下(CentOS5.5):
iptables -X
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -t raw -F
iptables -t raw -A PREROUTING -p icmp -m state --state NEW -j LOG --prefix="raw PREROUTING new:"
iptables -t mangle -A PREROUTING -p icmp -m state --state NEW -j LOG --prefix="mangle PREROUTING new:"
iptables -t nat -A PREROUTING -p icmp -m state --state NEW -j LOG --prefix="nat PREROUTING new:"
iptables -A INPUT -p icmp -m state --state NEW -j LOG --prefix="filter INPUT new:" #这条是额外添加的,只为记录包是否进入防火墙了。
(只针对进入防火墙的ICMP数据包进行记录)
数据包匹配顺序:raw表的PREROUTING链->mangle表的PREROUTING链->nat表的PREROUTING链->mangle表的INPUT链->filter表的INPUT
链。
然后在另外一台和此防火墙同在一个网络的客户机上进行测试:ping x.x.x.x -c 1
然后通过日志发现:日志中除了第一个raw表的PREROUTING链没有记录,mangle表的PREROUTING链,nat表的PREROUTING链,filter的
INPUT链对进入防火墙的ping包都进行了记录。
这个实验说明:进入防火墙的第一个ping包在进入mangle表的PREROUTING链就已经是NEW状态了,并且记录在了日志里面,
对比iptables指南中的概述介绍"So, all changes and calculations are done within the PREROUTING and OUTPUT chains of the nat table" "the nat table"。。NEW状态在nat表的PREROUTING链、OUTPUT链中才会被设置,对此很奇怪,难道iptables的指南有问题吗?还是我理解上面有些问题?希望chinaunix论坛的各位前辈给晚辈指点一下,提前在这里谢谢你们!!
ps:经 广告杀手 dreamice 的提示,对原文进行了改错。在这里谢谢前辈指点。 |
|