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上常用的防火墙软件
1818 - [ 防火墙的策略] ( #防火墙的策略-1 )
1919 - [ 实例] ( #实例 )
2020 - [ 列出已设置的规则] ( #列出已设置的规则 )
21- - [ 清除已有iptables规则 ] ( #清除已有iptables规则 )
22- - [ 删除一条规则 ] ( #删除一条规则 )
21+ - [ 清除已有规则 ] ( #清除已有规则 )
22+ - [ 删除已添加的规则 ] ( #删除已添加的规则 )
2323 - [ 开放指定的端口] ( #开放指定的端口 )
2424 - [ 屏蔽IP] ( #屏蔽ip )
2525 - [ 指定数据包出去的网络接口] ( #指定数据包出去的网络接口 )
26- - [ 查看已添加的iptables规则] ( #查看已添加的iptables规则 )
27- - [ 删除已添加的iptables规则] ( #删除已添加的iptables规则 )
26+ - [ 查看已添加的规则] ( #查看已添加的规则 )
2827 - [ 启动网络转发规则] ( #启动网络转发规则 )
2928 - [ 端口映射] ( #端口映射 )
3029 - [ 字符串匹配] ( #字符串匹配 )
@@ -186,7 +185,7 @@ iptables -L INPUT
186185iptables -L -nv # 查看,这个列表看起来更详细
187186```
188187
189- #### 清除已有iptables规则
188+ #### 清除已有规则
190189
191190``` bash
192191iptables -F INPUT # 清空指定链 INPUT 上面的所有规则
@@ -195,14 +194,23 @@ iptables -X INPUT # 删除指定的链,这个链必须没有被其它任何
195194iptables -Z INPUT # 把指定链,或者表中的所有链上的所有计数器清零。
196195```
197196
198- #### 删除一条规则
197+ #### 删除已添加的规则
199198
200199``` bash
201200# 添加一条规则
202201iptables -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的规则,执行:
203211
204- # 删除上面添加的规则,删除用-D参数
205- iptables -D INPUT -s 192.168.1.5 -j DROP
212+ ``` bash
213+ iptables -D INPUT 8
206214```
207215
208216#### 开放指定的端口
@@ -237,7 +245,7 @@ iptables -I INPUT -s 123.45.6.0/24 -j DROP #封IP段即从123.45.6.1到123.45
237245iptables -A FORWARD -o eth0
238246```
239247
240- #### 查看已添加的iptables规则
248+ #### 查看已添加的规则
241249
242250```
243251iptables -L -n -v
@@ -257,20 +265,6 @@ Chain OUTPUT (policy ACCEPT 3382K packets, 1819M bytes)
257265 5075 589K ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0
258266```
259267
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-
274268#### 启动网络转发规则
275269
276270公网` 210.14.67.7 ` 让内网` 192.168.188.0/24 ` 上网
You can’t perform that action at this time.
0 commit comments