删除已经创建的iptables(防火墙)规则

首先使用 iptables -L -n 命令来查看已经创建的防火墙规则,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@webxn ~]# iptables -L -n

Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 173.231.17.71 0.0.0.0/0
DROP all -- 173.231.17.71 0.0.0.0/0
ACCEPT all -- 173.252.192.205 0.0.0.0/0
DROP all -- 173.252.192.205 0.0.0.0/0
DROP all -- 173.252.192.205 0.0.0.0/0
ACCEPT all -- 173.252.192.205 0.0.0.0/0
DROP all -- 173.252.192.205 0.0.0.0/0

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

我们可以看到我创建了很多规则. 然后我们可以使用命令:

1
iptables -D INPUT *

来删除制定规则, 比如我们删除第一行的规则, 那我们就可以执行:

1
iptables -D INPUT 1

就可以了.