> 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/man/man4/ng_hub.4.md).

# ng\_hub.4

`ng_hub` — 数据包分发 netgraph 节点类型

## 名称

`ng_hub`

## 概要

`#include <netgraph/ng_hub.h>`

## 描述

`hub` 节点类型提供了一种在多条链路上分发数据包的简单机制。在任一钩子上收到的数据包会被转发到其他钩子输出。数据包不会以任何方式被修改。

## 钩子

`hub` 节点接受任何连接请求，无论钩子名称如何，只要名称唯一即可。

## 控制消息

本节点类型支持通用控制消息，以及以下消息：

**`NGM_HUB_SET_PERSISTENT`** (`setpersistent`) 此命令设置节点的持久标志，不接受任何参数。

## 关闭

本节点在收到 `NGM_SHUTDOWN` 控制消息时关闭，或在所有钩子都已断开时关闭。通过 `NGM_HUB_SET_PERSISTENT` 控制消息设置持久标志后，最后一个钩子断开时不会自动关闭节点。

## 参见

[netgraph(4)](/man/man4/netgraph.4.md), [ng\_bridge(4)](/man/man4/ng_bridge.4.md), [ng\_ether(4)](/man/man4/ng_ether.4.md), [ng\_one2many(4)](/man/man4/ng_one2many.4.md), ngctl(8), nghook(8)

## 历史

`hub` 节点类型出现于 FreeBSD 5.3。

## 作者

Ruslan Ermilov <ru@FreeBSD.org>


---

# 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/man/man4/ng_hub.4.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.
