我在CentOS 5.6机器上遇到了一个问题,以前工作正常,我不完全确定这是什么时候开始发生的,因为我只是注意到问题,当我来一个端口上允许一个新的IP。
基本上,当我试图停止,启动或重新启动我得到以下内容:
Flushing firewall rules: [ OK ] Setting chains to policy ACCEPT: security raw nat mangle filter [FAILED] Unloading iptables modules: [ OK ]
出于某种原因,无论我做什么,我都不能重新configuration规则。 我已经尝试去完全卸载IPtables(通过yum),但即使在系统重新启动后,它仍然只允许连接到在问题开始之前打开的端口,并过滤其他所有内容。
我真的在我的智慧结束, iptables status显示完全空的链,但仍然没有喜欢外部连接。
任何想法,将不胜感激。 如果您希望我提供更多信息,请告诉我。
提前致谢,
山姆。
编辑: /etc/sysconfig/iptables (由于删除并重新安装了iptables,基本上是空的)。
# Firewall configuration written by system-config-securitylevel # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] COMMIT
编辑2:
如果我运行/etc/init.d/iptables stop我得到:
Flushing firewall rules: [ OK ] Setting chains to policy ACCEPT: security raw nat mangle filter [FAILED] Unloading iptables modules: [ OK ]
而空的规则:
$ iptables -L -n -v Chain INPUT (policy ACCEPT 81 packets, 6575 bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 72 packets, 4133 bytes) pkts bytes target prot opt in out source destination
但它仍然阻塞和过滤端口。
同样,起始结果在:
/etc/init.d/iptables start Flushing firewall rules: [ OK ] Setting chains to policy ACCEPT: security raw nat mangle filter [FAILED] Unloading iptables modules: [ OK ] Applying iptables firewall rules: [ OK ] iptables -L -n -v Chain INPUT (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 207 54155 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 0 0 REJECT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:!0x17/0x02 reject-with tcp-reset 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID 0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 4 228 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:25 2 116 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:110 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:143 1 52 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:993 2 128 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:995 0 0 ACCEPT tcp -- * * -sanitized- 0.0.0.0/0 tcp dpt:22 0 0 ACCEPT tcp -- * * 192.168.0.0/16 0.0.0.0/0 tcp dpt:22 0 0 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 code 0 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 Chain FORWARD (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 0 0 REJECT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:!0x17/0x02 reject-with tcp-reset 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID 0 0 ACCEPT all -- lo lo 0.0.0.0/0 0.0.0.0/0 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 Chain OUTPUT (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 158 25662 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 0 0 REJECT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:!0x17/0x02 reject-with tcp-reset 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID 0 0 ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0 33 2351 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0
但我仍然无法连接在SSH端口22(否则使用串行控制台)。
这个线程有一个解决scheme,为我工作: http : //forum.linode.com/viewtopic.php?t=6981&postdays=0&postorder=asc&start=0
解决方法是将以下行添加到/etc/init.d/iptables
echo -n $"${IPTABLES}: Setting chains to policy $policy: " ret=0 for i in $tables; do echo -n "$i " case "$i" in + security) + $IPTABLES -t filter -P INPUT $policy \ + && $IPTABLES -t filter -P OUTPUT $policy \ + && $IPTABLES -t filter -P FORWARD $policy \ + || let ret+=1 + ;; raw) $IPTABLES -t raw -P PREROUTING $policy \ && $IPTABLES -t raw -P OUTPUT $policy \ || let ret+=1 ;;
你在Linode(或其他VPS)上运行? 我问这是因为,在Googlesearch“设置链接策略ACCEPT:安全原始nat manglefilter”,我find了以下参考:
Linode.com论坛::查看主题 – IPTables
http://www.linode.com/forums/archive/o_t/t_3930/iptables.html
在这个讨论中,相关的消息是用户“ troublshootr ”中的这个消息,也提到了CentOS(我把它看作是答案的答案部分):
我问了同样的问题,并没有真正回答。 这是我从支持收到的:
“问题是”最新的2.6版本“内核有一个”安全“链,iptables不知道如何处理, 通常切换到”最新的2.6稳定版“内核可以解决这个问题,而不需要进一步调整 iptables init脚本(通常只是忽略这个链条,并且正常启动),我们的构build团队确实意识到这个问题,但是如果解决这个问题,我还没有ETA,继续使用我们的“最新的2.6稳定的“内核 – 这个内核实际上是CentOS部署的默认select,直到最近,没有任何应用程序(除了iptables)在使用稳定的内核时运行不同。
这有帮助吗?
你有没有可能在这台服务器上运行Webmin或其他控制面板?
我在CentOS 5.6服务器上遇到了同样的问题,那就是我通过命令行对iptables所做的一切都是在重启后刷新的; 只有通过Webmin中的界面input的规则才会坚持。
在错误消息中,列出的每个项目都是一个单独的iptables表。 内核模块支持各个表:
- 在加载的时候,
iptable_raw模块将会注册一个在任何其他Netfilter钩子之前被调用的钩子。 它提供了一个名为raw的表格,可用于在数据包达到更多内存要求较高的操作(例如连接跟踪)之前对数据包进行过滤。iptable_mangle模块在连接跟踪之后(但仍然在任何其他表之前)注册一个钩子表和一个mangle表,以便可以修改可能影响诸如NAT或过滤之类的其他规则的分组。iptable_nat模块注册两个钩子:基于DNAT的转换应用在筛选器挂钩之前,之后应用基于SNAT的转换。 可用于iptables的nat表仅仅是用于NAT映射的“configuration数据库”,而不是用于任何types的过滤。iptable_filter模块注册过滤表,用于通用过滤(防火墙)。
security表是相对较新的,可能你正在使用的内核没有编译进来。你可以通过运行iptables -t <table> -L来确认。 即:
adam@adamc: $ sudo iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination adam@adamc: $ sudo iptables -t mangle -L Chain PREROUTING (policy ACCEPT) target prot opt source destination Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain POSTROUTING (policy ACCEPT) target prot opt source destination
真正的窍门是,我不知道如何告诉CentOS不要去加载security表。 在初始化脚本中徘徊可能会显示一个configuration文件,其中列出了这些行; 否则,您可以直接编辑初始化脚本以删除您尚未安装的任何表。