2014-01-11 136 views
10

我有这样的规则在我的iptables:如何删除iptables规则

sudo iptables -t nat -nvL --line-numbers 

Chain PREROUTING (policy ACCEPT 14 packets, 1950 bytes) 
num pkts bytes target  prot opt in  out  source    destination   

Chain INPUT (policy ACCEPT 14 packets, 1950 bytes) 
num pkts bytes target  prot opt in  out  source    destination   

Chain OUTPUT (policy ACCEPT 577 packets, 41182 bytes) 
num pkts bytes target  prot opt in  out  source    destination   
1  0  0 REDIRECT tcp -- *  lo  0.0.0.0/0   0.0.0.0/0   tcp dpt:80 redir ports 8090 

我试图用将其删除:

sudo iptables -D OUTPUT 1 

通过我得到这个错误:

因此,在网络上进行一些搜索后,我发现应该能够删除链条的所有规则,如下所示:

sudo iptables -F OUTPUT 

该命令的输出没有任何意义,但是当我重新运行sudo iptables -t nat -nvL --line-numbers命令以后列出现有规则时,没有任何操作被删除。我错过了什么?

回答

11

您的规则是在表nat中定义的,因此您必须明确添加-t nat

sudo iptables -D OUTPUT 1 -t nat 

如果您没有指定表名,则默认操作将隐式使用'-t filter'。

+0

就是这样!非常感谢! – pkout