【问题标题】:How to remove iptables rule如何删除 iptables 规则
【发布时间】:2014-01-30 20:48:36
【问题描述】:

我的 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

我得到了这个错误:

iptables: Index of deletion too big.

所以在网上搜索了一番后,我发现应该可以像这样删除链的所有规则:

sudo iptables -F OUTPUT

这个命令的输出什么都没有,但是当我之后重新运行sudo iptables -t nat -nvL --line-numbers 命令列出现有规则时,什么都没有被删除。我错过了什么?

【问题讨论】:

    标签: iptables


    【解决方案1】:

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

    sudo iptables -D OUTPUT 1 -t nat 
    

    如果您没有指定表名,默认操作将隐式使用“-t 过滤器”。

    【讨论】:

    • 就是这样!非常感谢!
    猜你喜欢
    • 2016-01-09
    • 1970-01-01
    • 2012-01-04
    • 1970-01-01
    • 1970-01-01
    • 2012-04-29
    • 2015-05-17
    • 2018-10-09
    • 1970-01-01
    相关资源
    最近更新 更多