File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -106,19 +106,38 @@ iptables -t 表名 <-A/I/D/R> 规则链名 [规则号] <-i/o 网卡名> -p 协
106
106
107
107
#### 列出已设置的规则
108
108
109
+ > iptables -L [ -t 表名] [ 链名]
110
+
111
+ - 四个表名 ` raw ` ,` nat ` ,` filter ` ,` mangle `
112
+ - 五个规则链名 ` INPUT ` 、` OUTPUT ` 、` FORWARD ` 、` PREROUTING ` 、` POSTROUTING `
113
+ - filter表包含` INPUT ` 、` OUTPUT ` 、` FORWARD ` 三个规则链
114
+
109
115
``` bash
110
116
iptables -L -t nat # 列出 nat 上面的所有规则
111
117
# ^ -t 参数指定,必须是 raw, nat,filter,mangle 中的一个
112
118
iptables -L -t nat --line-numbers # 规则带编号
113
119
iptables -L INPUT
120
+
121
+ iptables -L -nv # 查看,这个列表看起来更详细
114
122
```
115
123
116
124
#### 清除已有iptables规则
117
125
126
+ ``` bash
127
+ iptables -F INPUT # 清空指定链 INPUT 上面的所有规则
128
+ iptables -X INPUT # 删除指定的链,这个链必须没有被其它任何规则引用,而且这条上必须没有任何规则。
129
+ # 如果没有指定链名,则会删除该表中所有非内置的链。
130
+ iptables -Z INPUT # 把指定链,或者表中的所有链上的所有计数器清零。
118
131
```
119
- iptables -F
120
- iptables -X
121
- iptables -Z
132
+
133
+ #### 删除一条规则
134
+
135
+ ``` bash
136
+ # 添加一条规则
137
+ iptables -A INPUT -s 192.168.1.5 -j DROP
138
+
139
+ # 删除上面添加的规则,删除用-D参数
140
+ iptables -D INPUT -s 192.168.1.5 -j DROP
122
141
```
123
142
124
143
#### 开放指定的端口
You can’t perform that action at this time.
0 commit comments