我有一个iptables规则。 在search时使用
sudo /sbin/iptables -L -n --line-numbers
我正在得到它
Chain tcp_inbound (1 references) num target prot opt source destination xxxx 2 ACCEPT tcp -- 10.10.0.20 0.0.0.0/0 tcp dpt:25 xxxx ...
我的目标是删除这条规则。
我试过了
sudo iptables -D INPUT 2
但规则仍然存在。 我在debian上。 任何想法?
find要删除的规则的最简单方法是检查iptables-save的输出,并将-A更改为-D是要删除的规则。
在你的情况下:
$ iptables-save | grep 10.10.0.20 .... -A tcp_inbound -s 10.10.0.20/32 -p tcp -m tcp --dport 25 -j ACCEPT ....
所以你只需要发出:
iptables -D tcp_inbound -s 10.10.0.20/32 -p tcp -m tcp --dport 25 -j ACCEPT
您试图删除链条INPUT规则2,其中您的规则存储在链条tcp_inbound 。