我在 CentOS 5.6 机器上遇到了 IPtables 问题,该机器以前工作正常,我不完全确定这是什么时候开始发生的,因为我只是在我开始允许端口上的新 IP 时才注意到这个问题。
基本上,当我尝试停止、启动或重新启动时,我得到以下信息:
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: security raw nat mangle filter [FAILED]
Unloading iptables modules: [ OK ]
Run Code Online (Sandbox Code Playgroud)
出于某种原因,无论我做什么,我都无法重新配置规则。我已经尝试过完全卸载 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
Run Code Online (Sandbox Code Playgroud)
编辑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 ]
Run Code Online (Sandbox Code Playgroud)
和空规则:
$ 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
Run Code Online (Sandbox Code Playgroud)
但它仍然会阻止和过滤端口。
同样,开始的结果是:
/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
Run Code Online (Sandbox Code Playgroud)
但是我仍然无法在 SSH 端口 22 上连接(否则我正在使用串行控制台)。
小智 5
这个线程有一个对我有用的解决方案: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
;;
Run Code Online (Sandbox Code Playgroud)