> For the complete documentation index, see [llms.txt](https://hezhiqiang.gitbook.io/linux/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hezhiqiang.gitbook.io/linux/ming-ling/dhcrelay.md).

# dhcrelay

使用dhcrelay命令可以提供中继DHCP和BOOTP请求

## 补充说明

**dhcrelay命令** 使用dhcrelay命令可以提供中继DHCP和BOOTP请求，从一个没有DHCP服务器的子网直接连接到其它子网内的一个或多个DHCP服务器。该命令在DHCP中继服务器上使用，同时支持DHCPv4/BOOTP和DHCPv6协议。

### 语法

```
dhcrelay [选项] [DHCP服务器]
```

### 选项

```
-c <跳数> 当转发数据包时，dhcrelay丢弃已经达到一个最大跳数的数据包。默认值是10，最大值是255
-4 运行dhcrelay命令作为DHCPv4/BOOTP中继代理。这是默认操作模式
-6 运行dhcrelay命令作为DHCPv6中继代理
-q 安静模式
-p <端口> 监听和发送端口。DHCPv4/BOOTP默认端口是67，DHCPv6默认端口是547
-A <长度> 指定发送到DHCP服务器的最大数据包大小
-d 强制dhcrelay命令作为前台进程运行
```

### 例子

指定DHCP服务器的位置。

```
[root@localhost ~]# dhcrelay 192.168.0.2
Internet Systems Consortium DHCP Relay Agent4.1.1-P1
Copyright 2004-2010 Internet SystemsConsortium.
All rights reserved.
For info, please visithttps://www.isc.org/software/dhcp/
Listening on LPF/eth1/00:0c:29:fc:2f:ef
Sending on  LPF/eth1/00:0c:29:fc:2f:ef
Listening on LPF/eth0/00:0c:27:fc:25:ec
Sending on  LPF/eth0/00:0c:27:fc:25:ec
Sending on  Socket/fallback
```


---

# 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://hezhiqiang.gitbook.io/linux/ming-ling/dhcrelay.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.
