Update iptables.md

This commit is contained in:
小弟调调™ 2017-07-19 02:55:12 +08:00 committed by GitHub
parent 5da538174b
commit 318c3e54f6
1 changed files with 50 additions and 17 deletions

View File

@ -42,28 +42,61 @@ iptables -t 表名 <-A/I/D/R> 规则链名 [规则号] <-i/o 网卡名> -p 协
表名包括:
* **raw** :高级功能,如:网址过滤。
* **mangle** 数据包修改QOS用于实现服务质量。
* **net** :地址转换,用于网关路由器。
* **filter** :包过滤,用于防火墙规则。
- **raw** :高级功能,如:网址过滤。
- **mangle** 数据包修改QOS用于实现服务质量。
- **net** :地址转换,用于网关路由器。
- **filter** :包过滤,用于防火墙规则。
规则链名包括:
* **INPUT链** :处理输入数据包。
* **OUTPUT链** :处理输出数据包。
* **PORWARD链** :处理转发数据包。
* **PREROUTING链** 用于目标地址转换DNAT
* **POSTOUTING链** 用于源地址转换SNAT
- **INPUT链** :处理输入数据包。
- **OUTPUT链** :处理输出数据包。
- **PORWARD链** :处理转发数据包。
- **PREROUTING链** 用于目标地址转换DNAT
- **POSTOUTING链** 用于源地址转换SNAT
动作包括:
* **ACCEPT** :接收数据包。
* **DROP** :丢弃数据包。
* **REDIRECT** :重定向、映射、透明代理。
* **SNAT** :源地址转换。
* **DNAT** :目标地址转换。
* **MASQUERADE** IP伪装NAT用于ADSL。
* **LOG** :日志记录。
- **ACCEPT** :接收数据包。
- **DROP** :丢弃数据包。
- **REDIRECT** :重定向、映射、透明代理。
- **SNAT** :源地址转换。
- **DNAT** :目标地址转换。
- **MASQUERADE** IP伪装NAT用于ADSL。
- **LOG** :日志记录。
```bash
┎╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓
┌───────────────┐ ┃ Network ┃
│ table: filter │ ┖━━━━━━━│━━━━━━━┛
│ chain: INPUT ◀────┐ │
└───────┬───────┘ │ │
│ │ ┌─────────▼─────────┐
┌ ▼ ┐ │ │ table: nat │
│local process│ │ │ chain: PREROUTING │
└ ┘ │ └─────────┬─────────┘
│ │ │
▼ │ ▼ ┌─────────────────┐
┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅ │ ┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅ │table: nat │
Routing decision └────── outing decision ─────▶│chain: PREROUTING│
┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅ ┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅ └────────┬────────┘
│ │
│ │
┌───────▼───────┐ │
│ table: nat │ ┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅ │
│ chain: OUTPUT │ ┌─────▶ outing decision ◀──────────────┘
└───────┬───────┘ │ ┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅
│ │ │
┌───────▼───────┐ │ ┌──────────▼─────────┐
│ table: filter │ │ │ table: nat │
│ chain: OUTPUT ├────┘ │ chain: POSTROUTING │
└───────────────┘ └──────────┬─────────┘
┎╍╍╍╍╍╍╍▼╍╍╍╍╍╍╍┓
┃ Network ┃
┖━━━━━━━━━━━━━━━┛
```
### 实例
@ -133,4 +166,4 @@ iptables -D INPUT 8
```
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->