File tree Expand file tree Collapse file tree 1 file changed +17
-23
lines changed Expand file tree Collapse file tree 1 file changed +17
-23
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,12 @@ Linux上常用的防火墙软件
18
18
- [ 防火墙的策略] ( #防火墙的策略-1 )
19
19
- [ 实例] ( #实例 )
20
20
- [ 列出已设置的规则] ( #列出已设置的规则 )
21
- - [ 清除已有iptables规则 ] ( #清除已有iptables规则 )
22
- - [ 删除一条规则 ] ( #删除一条规则 )
21
+ - [ 清除已有规则 ] ( #清除已有规则 )
22
+ - [ 删除已添加的规则 ] ( #删除已添加的规则 )
23
23
- [ 开放指定的端口] ( #开放指定的端口 )
24
24
- [ 屏蔽IP] ( #屏蔽ip )
25
25
- [ 指定数据包出去的网络接口] ( #指定数据包出去的网络接口 )
26
- - [ 查看已添加的iptables规则] ( #查看已添加的iptables规则 )
27
- - [ 删除已添加的iptables规则] ( #删除已添加的iptables规则 )
26
+ - [ 查看已添加的规则] ( #查看已添加的规则 )
28
27
- [ 启动网络转发规则] ( #启动网络转发规则 )
29
28
- [ 端口映射] ( #端口映射 )
30
29
- [ 字符串匹配] ( #字符串匹配 )
@@ -186,7 +185,7 @@ iptables -L INPUT
186
185
iptables -L -nv # 查看,这个列表看起来更详细
187
186
```
188
187
189
- #### 清除已有iptables规则
188
+ #### 清除已有规则
190
189
191
190
``` bash
192
191
iptables -F INPUT # 清空指定链 INPUT 上面的所有规则
@@ -195,14 +194,23 @@ iptables -X INPUT # 删除指定的链,这个链必须没有被其它任何
195
194
iptables -Z INPUT # 把指定链,或者表中的所有链上的所有计数器清零。
196
195
```
197
196
198
- #### 删除一条规则
197
+ #### 删除已添加的规则
199
198
200
199
``` bash
201
200
# 添加一条规则
202
201
iptables -A INPUT -s 192.168.1.5 -j DROP
202
+ ```
203
+
204
+ 将所有iptables以序号标记显示,执行:
205
+
206
+ ```
207
+ iptables -L -n --line-numbers
208
+ ```
209
+
210
+ 比如要删除INPUT里序号为8的规则,执行:
203
211
204
- # 删除上面添加的规则,删除用-D参数
205
- iptables -D INPUT -s 192.168.1.5 -j DROP
212
+ ``` bash
213
+ iptables -D INPUT 8
206
214
```
207
215
208
216
#### 开放指定的端口
@@ -237,7 +245,7 @@ iptables -I INPUT -s 123.45.6.0/24 -j DROP #封IP段即从123.45.6.1到123.45
237
245
iptables -A FORWARD -o eth0
238
246
```
239
247
240
- #### 查看已添加的iptables规则
248
+ #### 查看已添加的规则
241
249
242
250
```
243
251
iptables -L -n -v
@@ -257,20 +265,6 @@ Chain OUTPUT (policy ACCEPT 3382K packets, 1819M bytes)
257
265
5075 589K ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0
258
266
```
259
267
260
- #### 删除已添加的iptables规则
261
-
262
- 将所有iptables以序号标记显示,执行:
263
-
264
- ```
265
- iptables -L -n --line-numbers
266
- ```
267
-
268
- 比如要删除INPUT里序号为8的规则,执行:
269
-
270
- ``` bash
271
- iptables -D INPUT 8
272
- ```
273
-
274
268
#### 启动网络转发规则
275
269
276
270
公网` 210.14.67.7 ` 让内网` 192.168.188.0/24 ` 上网
You can’t perform that action at this time.
0 commit comments