> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/openbsd/networking-and-daemons/pf.md).

# PF

OpenBSD 手册的 PF 部分详细介绍如何配置和管理 Packet Filter 防火墙。PF 通过过滤规则、NAT、重定向及多种高级特性控制网络流量。

本部分包含：

* [pfctl 速查表](/openbsd/networking-and-daemons/pf/cheat_sheet.md) 常用 `pfctl` 命令与选项的速查表。
* [锚点](/openbsd/networking-and-daemons/pf/anchors.md) 使用锚点模块化 PF 规则集，并动态加载规则。
* [过滤](/openbsd/networking-and-daemons/pf/filter.md) 编写过滤规则，控制进出流量。
* [转发](/openbsd/networking-and-daemons/pf/forwarding.md) 在 PF 中启用并配置数据包转发。
* [列表与宏](/openbsd/networking-and-daemons/pf/lists-and-macros.md) 对地址分组并定义宏，简化规则管理。
* [负载均衡](/openbsd/networking-and-daemons/pf/load-balancing.md) 将流量分散到多台服务器或多条网络路径。
* [日志](/openbsd/networking-and-daemons/pf/logging.md) 捕获并分析 PF 日志数据。
* [NAT](/openbsd/networking-and-daemons/pf/nat.md) 配置网络地址转换，让专有网络接入互联网。
* [选项](/openbsd/networking-and-daemons/pf/options.md) 配置影响规则处理与性能的全局 PF 选项。
* [策略](/openbsd/networking-and-daemons/pf/policies.md) 为数据包处理设置默认规则策略。
* [简写](/openbsd/networking-and-daemons/pf/shortcuts.md) 高效编写 PF 规则的技巧与简写。
* [表](/openbsd/networking-and-daemons/pf/tables.md) 使用表高效管理大批地址。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/openbsd/networking-and-daemons/pf.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
