Mil*_*los 0 linux debian iptables
我有一个 iptables 规则。搜索它时
sudo /sbin/iptables -L -n --line-numbers
Run Code Online (Sandbox Code Playgroud)
我明白了
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
...
Run Code Online (Sandbox Code Playgroud)
我的目标是删除此规则。
我试过
sudo iptables -D INPUT 2
Run Code Online (Sandbox Code Playgroud)
但规则仍然存在。我在 debian 上。任何的想法?
查找要删除的规则的最简单方法是检查 的输出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
....
Run Code Online (Sandbox Code Playgroud)
所以你只需要发出:
iptables -D tcp_inbound -s 10.10.0.20/32 -p tcp -m tcp --dport 25 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)