1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-22 17:22:10 +02:00
tldr/pages.zh/linux/iptables.md
K.B.Dharun Krishna 5c26174aa9
pages/*: update links and more info link script (#11390)
* pages/*: update links and more info link script

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>

* cleanup: reformat code

* ax-webapp: fix link

* curl: fix false positive

Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com>

---------

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com>
2023-11-06 23:14:12 +05:30

32 lines
907 B
Markdown

# iptables
> 可用于配置 Linux 内核防火墙提供的过滤表、规则链和规则的程序。
> 更多信息:<https://manned.org/iptables>.
- 查看过滤表的规则链、规则以及数据包/字节计数器:
`sudo iptables -vnL`
- 设定规则链策略规则:
`sudo iptables -P {{规则链}} {{规则}}`
- 追加规则到 IP 的规则链策略:
`sudo iptables -A {{规则链}} -s {{ip}} -j {{规则}}`
- 追加规则到 IP 的规则链策略(考虑协议与端口):
`sudo iptables -A {{规则链}} -s {{ip}} -p {{协议}} --dport {{端口}} -j {{规则}}`
- 删除规则链中的规则:
`sudo iptables -D {{规则链}} {{规则所在行号}}`
- 将指定过滤表的 iptables 配置保存到文件中:
`sudo iptables-save -t {{过滤表名}} > {{iptables_文件路径}}`
- 从文件中还原 iptables 配置:
`sudo iptables-restore < {{iptables_文件路径}}`