这是用户在 2024-3-15 11:20 为 https://man.archlinux.org/man/dhcpcd.8 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?
DHCPCD(8) System Manager's Manual 系统管理员手册 DHCPCD(8)

dhcpcda DHCP client
dhcpcd — DHCP 客户端

dhcpcd [-146ABbDdEGgHJKLMNPpqTV] [-C, --nohook hook] [-c, --script script] [-e, --env value] [-F, --fqdn FQDN] [-f, --config file] [-h, --hostname hostname] [-I, --clientid clientid] [-i, --vendorclassid vendorclassid] [-j, --logfile logfile] [-l, --leasetime seconds] [-m, --metric metric] [-O, --nooption option] [-o, --option option] [-Q, --require option] [-r, --request address] [-S, --static value] [-s, --inform address[/cidr[/broadcast_address]]] [--inform6] [-t, --timeout seconds] [-u, --userclass class] [-v, --vendor code, value] [-W, --whitelist address[/cidr]] [-w] [--waitip=[4 | 6]] [-y, --reboot seconds] [-X, --blacklist address[/cidr]] [-Z, --denyinterfaces pattern] [-z, --allowinterfaces pattern] [--inactive] [--configure] [--noconfigure] [interface] [...]
[ -146ABbDdEGgHJKLMNPpqTV ] [ -C--nohook 挂钩] [ -c--script 脚本] [ -e 值] [ -F--fqdn FQDN] [ -f--config 文件] [ -h--hostname 主机名] [ -I--clientid 客户端 ID] [ -i--vendorclassid 供应商类ID] [ -j--logfile 日志文件][ -l--leasetime 秒][ -m--metric 公制] [ -O--nooption 选项] [ -o--option 选项] [ -Q--require 选项] [ -r--request 地址] [ -S--static 值] [ -s--inform 地址[/cidr[/broadcast_address]]] [ --inform6 ] [ -t--timeout 秒] [ -u--userclass 类] [ -v--vendor 代码、值] [ -W--whitelist 地址[/cidr]] [ -w ] [ --waitip =[4 | 6]] [ -y , --reboot 秒] [ -X , --blacklist 地址[/cidr]] [ -Z , --denyinterfaces 模式] [ -z , --allowinterfaces 模式] [ --inactive ] [ --configure ] [ --noconfigure ] [界面] [...]

dhcpcd -n, --rebind [interface]
-n--rebind [界面]

dhcpcd -k, --release [interface]
-k--release [界面]

dhcpcd -U, --dumplease [interface]
-U--dumplease [界面]

dhcpcd --version

dhcpcd -x, --exit [interface]
-x--exit [界面]

dhcpcd is an implementation of the DHCP client specified in RFC 2131. dhcpcd gets the host information (IP address, routes, etc) from a DHCP server and configures the network interface of the machine on which it is running. dhcpcd then runs the configuration script which writes DNS information to resolvconf(8), if available, otherwise directly to /etc/resolv.conf. If the hostname is currently blank, (null) or localhost, or force_hostname is YES or TRUE or 1 then dhcpcd sets the hostname to the one supplied by the DHCP server. dhcpcd then daemonises and waits for the lease renewal time to lapse. It will then attempt to renew its lease and reconfigure if the new lease changes when the lease begins to expire or the DHCP server sends a message to renew early.
dhcpcdRFC 2131 中指定的 DHCP 客户端的实现。 dhcpcd 从 DHCP 服务器获取主机信息(IP 地址、路由等)并配置其运行所在计算机的网络接口。 dhcpcd 然后运行配置脚本,将 DNS 信息写入 resolvconf(8)(如果可用),否则直接写入 /etc/resolv.conf。如果主机名当前为空、(null) 或 localhost,或者force_hostname 为 YES 或 TRUE 或 1,则 dhcpcd 将主机名设置为 DHCP 服务器提供的主机名。 dhcpcd 然后守护进程并等待租约续订时间过去。然后,如果在租约开始到期时新租约发生变化或者 DHCP 服务器发送提前续订消息,它将尝试续订其租约并重新配置。

If any interface reports a working carrier then dhcpcd will try to obtain a lease before forking to the background, otherwise it will fork right away. This behaviour can be modified with the -b, --background and -w, --waitip options.
如果任何接口报告工作载体,则 dhcpcd 将在分叉到后台之前尝试获得租约,否则它将立即分叉。可以使用 -b--background-w--waitip 选项修改此行为。

dhcpcd is also an implementation of the BOOTP client specified in RFC 951.
dhcpcd 也是 RFC 951 中指定的 BOOTP 客户端的实现。

dhcpcd is also an implementation of the IPv6 Router Solicitor as specified in RFC 4861 and RFC 6106.
dhcpcd 也是 RFC 4861RFC 6106 中指定的 IPv6 Router Solicitor 的实现。

dhcpcd is also an implementation of the IPv6 Privacy Extensions to AutoConf as specified in RFC 4941. This feature needs to be enabled in the kernel and dhcpcd will start using it.
dhcpcd 也是 RFC 4941 中指定的 AutoConf IPv6 隐私扩展的实现。需要在内核中启用此功能, dhcpcd 将开始使用它。

dhcpcd is also an implementation of the DHCPv6 client as specified in RFC 3315. By default, dhcpcd only starts DHCPv6 when instructed to do so by an IPV6 Router Advertisement. If no Identity Association is configured, then a Non-temporary Address is requested.
dhcpcd 也是 RFC 3315 中指定的 DHCPv6 客户端的实现。默认情况下, dhcpcd 仅在 IPV6 路由器通告指示时才启动 DHCPv6。如果未配置身份关联,则请求非临时地址。

If dhcpcd failed to obtain a lease, it probes for a valid IPv4LL address (aka ZeroConf, aka APIPA). Once obtained it restarts the process of looking for a DHCP server to get a proper address.
如果 dhcpcd 未能获得租约,它将探测有效的 IPv4LL 地址(又名 ZeroConf、又名 APIPA)。一旦获得,它就会重新启动寻找 DHCP 服务器以获得正确地址的过程。

When using IPv4LL, dhcpcd nearly always succeeds and returns an exit code of 0. In the rare case it fails, it normally means that there is a reverse ARP proxy installed which always defeats IPv4LL probing. To disable this behaviour, you can use the -L, --noipv4ll option.
使用 IPv4LL 时, dhcpcd 几乎总是成功并返回退出代码 0。在极少数情况下会失败,这通常意味着安装了反向 ARP 代理,该代理始终会失败 IPv4LL 探测。要禁用此行为,您可以使用 -L--noipv4ll 选项。

If a list of interfaces are given on the command line, then dhcpcd only works with those interfaces, otherwise dhcpcd discovers available Ethernet interfaces that can be configured. When dhcpcd is not limited to one interface on the command line, it is running in Manager mode. The dhcpcd-ui project expects dhcpcd to be running this way.
如果在命令行上给出了接口列表,则 dhcpcd 仅适用于这些接口,否则 dhcpcd 会发现可配置的可用以太网接口。当 dhcpcd 不限于命令行上的一个界面时,它运行在Manager模式下。 dhcpcd-ui 项目期望 dhcpcd 以这种方式运行。

If a single interface is given then dhcpcd only works for that interface and runs as a separate instance to other dhcpcd processes. The -w, --waitip option is enabled in this instance to maintain compatibility with older versions. Using a single interface, optionally further limited to an address protocol, also affects the -k, -N, -n and -x options, where the same interface and any address protocol will need to be specified, as a lack of an interface will imply Manager mode which this is not. To force starting in Manager mode with only one interface, the -M, --manager option can be used.
如果给定单个接口,则 dhcpcd 仅适用于该接口,并作为其他 dhcpcd 进程的单独实例运行。在此实例中启用 -w--waitip 选项以保持与旧版本的兼容性。使用单个接口(可选地进一步限制为地址协议)还会影响 -k-N-n-x 选项,其中需要指定相同的接口和任何地址协议,因为缺少接口将意味着管理器模式,而这不是管理器模式。要强制以仅一个界面的管理器模式启动,可以使用 -M--manager 选项。

Interfaces are preferred by carrier, DHCP lease/IPv4LL and then lowest metric. For systems that support route metrics, each route will be tagged with the metric, otherwise dhcpcd changes the routes to use the interface with the same route and the lowest metric. See options below for controlling which interfaces we allow and deny through the use of patterns.
接口由运营商、DHCP 租用/IPv4LL 和最低度量优先。对于支持路由度量的系统,每个路由都将使用度量进行标记,否则 dhcpcd 会将路由更改为使用具有相同路由和最低度量的接口。请参阅下面的选项来控制我们通过使用模式允许和拒绝哪些接口。

Non-ethernet interfaces and some virtual ethernet interfaces such as TAP and bridge are ignored by default, as is the FireWire interface. To work with these devices they either need to be specified on the command line, be listed in --allowinterfaces or have an interface directive in /etc/dhcpcd.conf.
默认情况下,非以太网接口和一些虚拟以太网接口(例如 TAP 和网桥)将被忽略,FireWire 接口也是如此。要使用这些设备,需要在命令行上指定它们,将它们列在 --allowinterfaces 中,或者在 /etc/dhcpcd.conf 中包含一个接口指令。

dhcpcd runs /usr/lib/dhcpcd/dhcpcd-run-hooks, or the script specified by the -c, --script option. This script runs each script found in /usr/lib/dhcpcd/dhcpcd-hooks in a lexical order. The default installation supplies the scripts 01-test, 20-resolv.conf and 30-hostname. You can disable each script by using the -C, --nohook option. See dhcpcd-run-hooks(8) for details on how these scripts work. dhcpcd currently ignores the exit code of the script.
dhcpcd 运行 /usr/lib/dh​​cpcd/dhcpcd-run-hooks 或由 -c--script 选项指定的脚本。该脚本按词法顺序运行 /usr/lib/dh​​cpcd/dhcpcd-hooks 中找到的每个脚本。默认安装提供脚本 01-test、20-resolv.conf 和 30-hostname。您可以使用 -C--nohook 选项禁用每个脚本。有关这些脚本如何工作的详细信息,请参阅 dhcpcd-run-hooks(8)。 dhcpcd 当前忽略脚本的退出代码。

More scripts are supplied in /usr/share/dhcpcd/hooks and need to be copied to /usr/lib/dhcpcd/dhcpcd-hooks if you intend to use them. For example, you could install 29-lookup-hostname so that dhcpcd can lookup the hostname of the IP address in DNS if no hostname is given by the lease and one is not already set.
/usr/share/dhcpcd/hooks 中提供了更多脚本,如果您打算使用它们,则需要将其复制到 /usr/lib/dh​​cpcd/dhcpcd-hooks 中。例如,您可以安装 29-lookup-hostname,以便在租约未给出主机名且尚未设置主机名的情况下, dhcpcd 可以在 DNS 中查找 IP 地址的主机名。

You can fine-tune the behaviour of dhcpcd with the following options:
您可以使用以下选项微调 dhcpcd 的行为:

, --background
Background immediately. This is useful for startup scripts which don't disable link messages for carrier status.
立即背景。这对于不禁用运营商状态链接消息的启动脚本很有用。
, --script script
-c--script 脚本
Use this script instead of the default /usr/lib/dhcpcd/dhcpcd-run-hooks.
使用此脚本代替默认的 /usr/lib/dh​​cpcd/dhcpcd-run-hooks。
, --duid [ll | lt | uuid | value]
-D--duid [ll | LT | uuid|价值]
Use a DHCP Unique Identifier. If a system UUID is available, that will be used to create a DUID-UUID, otherwise if persistent storage is available then a DUID-LLT (link local address + time) is generated, otherwise DUID-LL is generated (link local address). The DUID type can be hinted as an optional parameter if the file /var/lib/dhcpcd/duid does not exist. If not ll, lt or uuid then value will be converted from 00:11:22:33 format. This, plus the IAID will be used as the -I, --clientid. The DUID generated will be held in /var/lib/dhcpcd/duid and should not be copied to other hosts. This file also takes precedence over the above rules except for setting a value.
使用 DHCP 唯一标识符。如果系统 UUID 可用,则将用于创建 DUID-UUID,否则如果持久存储可用,则生成 DUID-LLT(链接本地地址 + 时间),否则生成 DUID-LL(链接本地地址) 。如果文件 /var/lib/dh​​cpcd/duid 不存在,则可以将 DUID 类型提示为可选参数。如果不是 ll、lt 或 uuid,则值将从 00:11:22:33 格式转换。这加上 IAID 将用作 -I--clientid 。生成的 DUID 将保存在 /var/lib/dh​​cpcd/duid 中,不应复制到其他主机。除了设置值之外,该文件也优先于上述规则。
, --debug
Echo debug messages to the stderr and syslog.
将调试消息回显到 stderr 和 syslog。
, --lastlease
If dhcpcd cannot obtain a lease, then try to use the last lease acquired for the interface.
如果 dhcpcd 无法获得租约,则尝试使用为接口获得的最后一个租约。
Same as the above, but the lease will be retained even if it expires. dhcpcd will give it up if any other host tries to claim it for their own via ARP. This violates RFC 2131, section 3.7, which states the lease should be dropped once it has expired.
与上述相同,但租约即使到期也将保留。如果任何其他主机试图通过 ARP 声明其所有权, dhcpcd 将放弃它。这违反了 RFC 2131 第 3.7 节,该节规定租约一旦过期就应被删除。
, --env value
-e--env
Push value to the environment for use in dhcpcd-run-hooks(8). For example, you can force the hostname hook to always set the hostname with -e force_hostname=YES.
将值推送到环境以在 dhcpcd-run-hooks(8) 中使用。例如,您可以强制主机名挂钩始终使用 -e force_hostname=YES 设置主机名。
, --reconfigure
dhcpcd will re-apply IP address, routing and run dhcpcd-run-hooks(8) for each interface. This is useful so that a 3rd party such as PPP or VPN can change the routing table and / or DNS, etc and then instruct dhcpcd to put things back afterwards. dhcpcd does not read a new configuration when this happens - you should rebind if you need that functionality.
dhcpcd 将为每个接口重新应用 IP 地址、路由并运行 dhcpcd-run-hooks(8)。这很有用,这样第三方(例如 PPP 或 VPN)可以更改路由表和/或 DNS 等,然后指示 dhcpcd 将内容放回原处。发生这种情况时, dhcpcd 不会读取新配置 - 如果您需要该功能,您应该重新绑定。
, --fqdn fqdn
-F , --fqdn 完整域名
Requests that the DHCP server update DNS using FQDN instead of just a hostname. Valid values for fqdn are disable, none, ptr and both. dhcpcd itself never does any DNS updates. dhcpcd encodes the FQDN hostname as specified in RFC 1035.
请求 DHCP 服务器使用 FQDN 而不仅仅是主机名来更新 DNS。 FQDN 的有效值为disable、none、ptr 和both。 dhcpcd 本身从不进行任何 DNS 更新。 dhcpcd 按照 RFC 1035 中指定的方式对 FQDN 主机名进行编码。
, --config file
-f--config 文件
Specify a config to load instead of /etc/dhcpcd.conf. dhcpcd always processes the config file before any command line options.
指定要加载的配置而不是/etc/dhcpcd.conf。 dhcpcd 始终在任何命令行选项之前处理配置文件。
, --hostname hostname
-h , --hostname 主机名
Sends hostname to the DHCP server so it can be registered in DNS. If hostname is an empty string then the current system hostname is sent. If hostname is a FQDN (i.e., contains a .) then it will be encoded as such.
将主机名发送到 DHCP 服务器,以便可以在 DNS 中注册。如果主机名是空字符串,则发送当前系统主机名。如果主机名是 FQDN(即包含 .),那么它将被如此编码。
, --clientid clientid
-I , --clientid 客户端 ID
Send the clientid. If the string is of the format 01:02:03 then it is encoded as hex. For interfaces whose hardware address is longer than 8 bytes, or if the clientid is an empty string then dhcpcd sends a default clientid of the hardware family and the hardware address.
发送客户端 ID。如果字符串的格式为 01:02:03,则它会被编码为十六进制。对于硬件地址长于 8 个字节的接口,或者如果 clientid 为空字符串,则 dhcpcd 发送硬件系列的默认 clientid 和硬件地址。
, --vendorclassid vendorclassid
-i , --vendorclassid 供应商类别
Override the DHCPv4 vendorclassid field sent. The default is dhcpcd-<version>:<os>:<machine>:<platform>. For example
覆盖发送的 DHCPv4 VendorClassID 字段。默认值为 dhcpcd-<版本>:<操作系统>:<机器>:<平台>。例如
dhcpcd-5.5.6:NetBSD-6.99.5:i386:i386
If not set then none is sent. Some badly configured DHCP servers reject unknown vendorclassids. To work around it, try and impersonate Windows by using the MSFT vendorclassid.
如果未设置,则不会发送任何内容。一些配置不当的 DHCP 服务器会拒绝未知的供应商类别。要解决此问题,请尝试使用 MSFT 供应商类 ID 来模拟 Windows。
, --logfile logfile
-j--logfile 日志文件
Writes to the specified logfile. dhcpcd still writes to syslog(3). The logfile is reopened when dhcpcd receives the SIGUSR2 signal.
写入指定的日志文件。 dhcpcd 仍然写入 syslog(3)。当 dhcpcd 收到 SIGUSR2 信号时,日志文件将重新打开。
, --release [interface]
-k--release [界面]
This causes an existing dhcpcd process running on the interface to release its lease and de-configure the interface regardless of the -p, --persistent option. If no interface is specified then this applies to all interfaces in Manager mode. If no interfaces are left running, dhcpcd will exit.
这会导致接口上运行的现有 dhcpcd 进程释放其租约并取消配置接口,而不管 -p--persistent 选项如何。如果未指定接口,则这适用于管理器模式下的所有接口。如果没有接口仍在运行, dhcpcd 将退出。
, --leasetime seconds
-l , --leasetime
Request a lease time of seconds. -1 represents an infinite lease time. By default dhcpcd does not request any lease time and leaves it in the hands of the DHCP server.
请求以秒为单位的租用时间。 -1代表无限租用时间。默认情况下, dhcpcd 不请求任何租用时间,并将其交给 DHCP 服务器。
, --manager
Start dhcpcd in Manager mode even if only one interface specified on the command line. See the Multiple Interfaces section above.
即使在命令行上只指定了一个接口,也要在管理器模式下启动 dhcpcd 。请参阅上面的“多个接口”部分。
, --metric metric
-m--metric 指标
Metrics are used to prefer an interface over another one, lowest wins. dhcpcd will supply a default metric of 1000 + if_nametoindex(3). This will be offset by 2000 for wireless interfaces, with additional offsets of 1000000 for IPv4LL and 2000000 for roaming interfaces.
指标用于优先选择一种界面而不是另一种界面,即最低获胜。 dhcpcd 将提供默认指标 1000 + if_nametoindex(3)。对于无线接口,这将偏移 2000,对于 IPv4LL,额外偏移 1000000,对于漫游​​接口,额外偏移 2000000。
, --rebind [interface]
-n--rebind [界面]
Notifies dhcpcd to reload its configuration and rebind the specified interface. If no interface is specified then this applies to all interfaces in Manager mode. If dhcpcd is not running, then it starts up as normal.
通知 dhcpcd 重新加载其配置并重新绑定指定的接口。如果未指定接口,则这适用于管理器模式下的所有接口。如果 dhcpcd 未运行,则它会正常启动。
, --renew [interface]
-N--renew [界面]
Notifies dhcpcd to renew existing addresses on the specified interface. If no interface is specified then this applies to all interfaces in Manager mode. If dhcpcd is not running, then it starts up as normal. Unlike the -n, --rebind option above, the configuration for dhcpcd is not reloaded.
通知 dhcpcd 更新指定接口上的现有地址。如果未指定接口,则这适用于管理器模式下的所有接口。如果 dhcpcd 未运行,则它会正常启动。与上面的 -n--rebind 选项不同, dhcpcd 的配置不会重新加载。
, --option option
-o--option 选项
Request the DHCP option variable for use in /usr/lib/dhcpcd/dhcpcd-run-hooks.
请求在 /usr/lib/dh​​cpcd/dhcpcd-run-hooks 中使用 DHCP 选项变量。
, --persistent
dhcpcd de-configures the interface when it exits unless this option is enabled. Sometimes, this isn't desirable if, for example, you have root mounted over NFS or SSH clients connect to this host and they need to be notified of the host shutting down. You can use this option to stop this from happening.
dhcpcd 除非启用此选项,否则在退出时取消配置接口。有时,这是不可取的,例如,如果您通过 NFS 或 SSH 客户端安装了 root 连接到该主机,并且需要通知它们主机关闭。您可以使用此选项来阻止这种情况发生。
, --request address
-r , --request 地址
Request the address in the DHCP DISCOVER message. There is no guarantee this is the address the DHCP server will actually give. If no address is given then the first address currently assigned to the interface is used.
请求 DHCP DISCOVER 消息中的地址。无法保证这是 DHCP 服务器实际提供的地址。如果没有给出地址,则使用当前分配给接口的第一个地址。
, --inform address[/cidr[/broadcast_address]]
-s--inform 地址[/cidr[/broadcast_address]]
Behaves like -r, --request as above, but sends a DHCP INFORM instead of DISCOVER/REQUEST. This does not get a lease as such, just notifies the DHCP server of the address in use. You should also include the optional cidr network number in case the address is not already configured on the interface. dhcpcd remains running and pretends it has an infinite lease. dhcpcd will not de-configure the interface when it exits. If dhcpcd fails to contact a DHCP server then it returns a failure instead of falling back on IPv4LL.
行为类似于上面的 -r--request ,但发送 DHCP INFORM 而不是 DISCOVER/REQUEST。这不会获得租约,只是通知 DHCP 服务器正在使用的地址。您还应该包括可选的 cidr 网络号,以防接口上尚未配置该地址。 dhcpcd 继续运行并假装它具有无限租约。 dhcpcd 退出时不会取消配置接口。如果 dhcpcd 无法联系 DHCP 服务器,那么它会返回失败,而不是退回到 IPv4LL。
Performs a DHCPv6 Information Request. No address is requested or specified, but all other DHCPv6 options are allowed. This is normally performed automatically when the IPv6 Router Advertises that the client should perform this operation. This option is only needed when dhcpcd is not processing IPv6RA messages and the need for DHCPv6 Information Request exists.
执行 DHCPv6 信息请求。不请求或指定地址,但允许所有其他 DHCPv6 选项。当 IPv6 路由器通告客户端应执行此操作时,这通常会自动执行。仅当 dhcpcd 不处理 IPv6RA 消息并且需要 DHCPv6 信息请求时才需要此选项。
, --static value
-S--static
Configures a static DHCP value. If you set ip_address then dhcpcd will not attempt to obtain a lease and just use the value for the address with an infinite lease time.
配置静态 DHCP 值。如果设置 ip_address ,则 dhcpcd 将不会尝试获取租约,而只是使用具有无限租约时间的地址值。

Here is an example which configures a static address, routes and DNS.
以下是配置静态地址、路由和 DNS 的示例。

dhcpcd -S ip_address=192.168.0.10/24 \
-S routers=192.168.0.1 \
-S 路由器=192.168.0.1 \
-S domain_name_servers=192.168.0.1 \
-S 域名服务器=192.168.0.1 \
eth0 以太网0

You cannot presently set static DHCPv6 values. Use the -e, --env option instead.
您目前无法设置静态 DHCPv6 值。请改用 -e--env 选项。

, --timeout seconds
-t , --timeout
Timeout after seconds, instead of the default 30. A setting of 0 seconds causes dhcpcd to wait forever to get a lease. If dhcpcd is working on a single interface then dhcpcd will exit when a timeout occurs, otherwise dhcpcd will fork into the background.
秒后超时,而不是默认的 30 秒。设置为 0 秒会导致 dhcpcd 永远等待以获得租约。如果 dhcpcd 在单个接口上工作,则 dhcpcd 将在发生超时时退出,否则 dhcpcd 将分叉到后台。
, --userclass class
-u--userclass
Tags the DHCPv4 message with the userclass class. DHCP servers use this to give members of the class DHCP options other than the default, without having to know things like hardware address or hostname.
使用用户类标记 DHCPv4 消息。 DHCP 服务器使用它来为该类的成员提供默认值以外的 DHCP 选项,而无需知道硬件地址或主机名等信息。
, --vendor code,value
-v--vendor 代码、值
Add an encapsulated vendor option. code should be between 1 and 254 inclusive. To add a raw vendor string, omit code but keep the comma. Examples.
添加封装的供应商选项。代码应介于 1 和 254 之间(含 1 和 254)。要添加原始供应商字符串,请省略代码但保留逗号。例子。

Set the vendor option 01 with an IP address.
使用 IP 地址设置供应商选项 01。

dhcpcd -v 01,192.168.0.2 eth0
Set the vendor option 02 with a hex code.
使用十六进制代码设置供应商选项 02。
dhcpcd -v 02,01:02:03:04:05 eth0
Set the vendor option 03 with an IP address as a string.
使用 IP 地址作为字符串设置供应商选项 03。
dhcpcd -v 03,\"192.168.0.2\" eth0
Set un-encapsulated vendor option to hello world.
将未封装的供应商选项设置为 hello world。
dhcpcd -v ,"hello world" eth0
dhcpcd -v ,“你好世界”eth0
Display both program version and copyright information. dhcpcd then exits before doing any configuration.
显示程序版本和版权信息。 dhcpcd 然后在进行任何配置之前退出。
Wait for an address to be assigned before forking to the background. Does not take an argument, unlike the below option.
在分叉到后台之前等待分配地址。与下面的选项不同,不接受参数。
=[4 | 6]
Wait for an address to be assigned before forking to the background. 4 means wait for an IPv4 address to be assigned. 6 means wait for an IPv6 address to be assigned. If no argument is given, dhcpcd will wait for any address protocol to be assigned. It is possible to wait for more than one address protocol and dhcpcd will only fork to the background when all waiting conditions are satisfied.
在分叉到后台之前等待分配地址。 4 表示等待分配 IPv4 地址。 6 表示等待分配 IPv6 地址。如果没有给出参数, dhcpcd 将等待分配任何地址协议。可以等待多个地址协议,并且 dhcpcd 仅当满足所有等待条件时才会分叉到后台。
, --exit [interface]
-x--exit [界面]
This will signal an existing dhcpcd process running on the interface to exit. If no interface is specified, then the above is applied to all interfaces in Manager mode. See the -p, --persistent option to control configuration persistence on exit, which is enabled by default in dhcpcd.conf(5). dhcpcd then waits until this process has exited.
这将向接口上运行的现有 dhcpcd 进程发出退出信号。如果未指定接口,则以上内容适用于 Manager 模式下的所有接口。请参阅 -p--persistent 选项来控制退出时的配置持久性,该选项在 dhcpcd.conf(5) 中默认启用。 dhcpcd 然后等待,直到该进程退出。
, --reboot seconds
-y , --reboot
Allow reboot seconds before moving to the discover phase if we have an old lease to use. Allow reboot seconds before starting fallback states from the discover phase. IPv4LL is started when the first reboot timeout is reached. The default is 5 seconds. A setting of 0 seconds causes dhcpcd to skip the reboot phase and go straight into discover. This has no effect on DHCPv6 other than skipping the reboot phase.
如果我们有旧租约可供使用,请在进入发现阶段之前允许重新启动几秒钟。在从发现阶段开始回退状态之前,允许重新启动几秒钟。当达到第一次重新启动超时时,IPv4LL 将启动。默认值为 5 秒。设置为 0 秒会导致 dhcpcd 跳过重新启动阶段并直接进入发现阶段。除了跳过重新启动阶段之外,这对 DHCPv6 没有任何影响。

dhcpcd will try to do as much as it can by default. However, there are sometimes situations where you don't want the things to be configured exactly how the DHCP server wants. Here are some options that deal with turning these bits off.
dhcpcd 默认情况下会尝试尽可能多地执行操作。但是,有时您不希望完全按照 DHCP 服务器的要求进行配置。以下是一些关闭这些位的选项。

Note that when dhcpcd is restricted to a single interface then the interface also needs to be specified when asking dhcpcd to exit using the commandline. If the protocol is restricted as well then the protocol needs to be included with the exit instruction.
请注意,当 dhcpcd 仅限于单个接口时,在使用命令行要求 dhcpcd 退出时也需要指定该接口。如果协议也受到限制,则协议需要包含在退出指令中。

, --oneshot
Exit after configuring an interface. Use the -w, --waitip option to specify which protocol(s) to configure before exiting.
配置完接口后退出。使用 -w--waitip 选项指定退出前要配置的协议。
, --ipv4only
Configure IPv4 only. 仅配置 IPv4。
, --ipv6only
Configure IPv6 only. 仅配置 IPv6。
, --noarp
Don't request or claim the address by ARP. This also disables IPv4LL.
不要通过 ARP 请求或声明地址。这也会禁用 IPv4LL。
, --nobackground
Don't run in the background when we acquire a lease. This is mainly useful for running under the control of another process, such as a debugger or a network manager.
当我们获得租约时,不要在后台运行。这主要适用于在另一个进程(例如调试器或网络管理器)的控制下运行。
, --nohook script
-C--nohook 脚本
Don't run this hook script. Matches full name, or prefixed with 2 numbers optionally ending with .sh.
不要运行这个钩子脚本。匹配全名,或以 2 个数字为前缀(可选以 .sh 结尾)。

So to stop dhcpcd from touching your DNS settings you would do:-
因此,要阻止 dhcpcd 触及您的 DNS 设置,您可以执行以下操作:-

dhcpcd -C resolv.conf eth0
, --nogateway
Don't set any default routes.
不要设置任何默认路由。
, --xidhwaddr
Use the last four bytes of the hardware address as the DHCP xid instead of a randomly generated number.
使用硬件地址的最后四个字节作为 DHCP xid,而不是随机生成的数字。
, --broadcast
Instructs the DHCP server to broadcast replies back to the client. Normally this is only set for non-Ethernet interfaces, such as FireWire and InfiniBand. In most instances, dhcpcd will set this automatically.
指示 DHCP 服务器将回复广播回客户端。通常,这仅针对非以太网接口设置,例如 FireWire 和 InfiniBand。在大多数情况下, dhcpcd 会自动设置此项。
, --nolink
Don't receive link messages for carrier status. You should only have to use this with buggy device drivers or running dhcpcd through a network manager.
不会收到运营商状态的链接消息。您应该只需将其与有缺陷的设备驱动程序一起使用或通过网络管理器运行 dhcpcd
, --noipv4ll
Don't use IPv4LL (aka APIPA, aka Bonjour, aka ZeroConf).
不要使用 IPv4LL(又名 APIPA、Bonjour、ZeroConf)。
, --nooption option
-O--nooption 选项
Removes the option from the DHCP message before processing.
在处理之前从 DHCP 消息中删除该选项。
, --printpidfile
Print the pidfile dhcpcd will use based on command-line arguments to stdout.
打印 pidfile dhcpcd 将根据 stdout 的命令行参数使用。
, --require option
-Q--require 选项
Requires the option to be present in all DHCP messages, otherwise the message is ignored. To enforce that dhcpcd only responds to DHCP servers and not BOOTP servers, you can -Q dhcp_message_type.
要求所有 DHCP 消息中都存在该选项,否则该消息将被忽略。要强制 dhcpcd 仅响应 DHCP 服务器而不响应 BOOTP 服务器,您可以 -Q dhcp_message_type。
, --quiet
Quiet dhcpcd on the command line, only warnings and errors will be displayed. If this option is used another time then all console output is disabled. These messages are still logged via syslog(3).
命令行上安静 dhcpcd ,仅显示警告和错误。如果再次使用此选项,则所有控制台输出将被禁用。这些消息仍然通过 syslog(3) 记录。
, --test
On receipt of DHCP messages just call /usr/lib/dhcpcd/dhcpcd-run-hooks with the reason of TEST which echos the DHCP variables found in the message to the console. The interface configuration isn't touched and neither are any configuration files. The rapid_commit option is not sent in TEST mode so that the server does not lease an address. To test INFORM the interface needs to be configured with the desired address before starting dhcpcd.
收到 DHCP 消息后,只需调用 /usr/lib/dh​​cpcd/dhcpcd-run-hooks 并带有 TEST 原因,它将消息中找到的 DHCP 变量回显到控制台。接口配置没有被修改,任何配置文件也没有被修改。在TEST模式下不发送rapid_commit选项,以便服务器不租用地址。要测试 INFORM,需要在启动 dhcpcd 之前配置所需的地址。
, --dumplease [interface]
-U--dumplease [界面]
Dumps the current lease for the interface to stdout. If no interface is given then all interfaces are dumped. Use the -4 or -6 flags to specify an address family. If a lease is piped in via standard input then that is dumped. In this case, specifying an address family is mandatory.
将接口的当前租约转储到标准输出。如果没有给出接口,则转储所有接口。使用 -4-6 标志指定地址族。如果租约通过标准输入传入,则该租约将被转储。在这种情况下,必须指定地址族。
, --variables
Display a list of option codes, the associated variable and encoding for use in dhcpcd-run-hooks(8). Variables are prefixed with new_ and old_ unless the option number is -. Variables without an option are part of the DHCP message and cannot be directly requested.
显示 dhcpcd-run-hooks(8) 中使用的选项代码、关联变量和编码的列表。变量以 new_ 和 old_ 为前缀,除非选项号为 -。不带选项的变量是 DHCP 消息的一部分,不能直接请求。
, --whitelist address[/cidr]
-W--whitelist 地址[/cidr]
Only accept packets from address[/cidr]. -X, --blacklist is ignored if -W, --whitelist is set.
只接受来自地址[/cidr]的数据包。如果设置了 -W--whitelist ,则忽略 -X--blacklist
, --blacklist address[/cidr]
-X--blacklist 地址[/cidr]
Ignore all packets from address[/cidr].
忽略来自地址[/cidr]的所有数据包。
, --denyinterfaces pattern
-Z--denyinterfaces 模式
When discovering interfaces, the interface name must not match pattern which is a space or comma separated list of patterns passed to fnmatch(3).
发现接口时,接口名称不得与模式匹配,模式是传递给 fnmatch(3) 的空格或逗号分隔的模式列表。
, --allowinterfaces pattern
-z--allowinterfaces 模式
When discovering interfaces, the interface name must match pattern which is a space or comma separated list of patterns passed to fnmatch(3). If the same interface is matched in -Z, --denyinterfaces then it is still denied.
发现接口时,接口名称必须与模式匹配,模式是传递给 fnmatch(3) 的空格或逗号分隔的模式列表。如果 -Z--denyinterfaces 中匹配相同的接口,则仍然被拒绝。
Don't start any interfaces other than those specified on the command line. This allows dhcpcd to be started in Manager mode and then wait for subsequent dhcpcd commands to start each interface as required.
不要启动命令行上指定的接口以外的任何接口。这允许 dhcpcd 在管理器模式下启动,然后等待后续的 dhcpcd 命令根据需要启动每个接口。
Allows dhcpcd to configure the system. This is the default behaviour and sets if_configured=true.
允许 dhcpcd 配置系统。这是默认行为并设置 if_configured=true
dhcpcd will not configure the system at all. This is only of use if the --script that dhcpcd calls at each network event configures the system instead. This is different from -T, --test mode in that it's not one shot and the only change to the environment is the addition of if_configured=false.
dhcpcd 根本不会配置系统。仅当 dhcpcd 在每个网络事件中调用的 --script 来配置系统时,这才有用。这与 -T--test 模式不同,因为它不是一次性的,对环境的唯一更改是添加 if_configured=false
Don't load any /dev management modules.
不要加载任何 /dev 管理模块。

Some interfaces require configuration by 3rd parties, such as PPP or VPN. When an interface configuration in dhcpcd is marked as STATIC or INFORM without an address then dhcpcd will monitor the interface until an address is added or removed from it and act accordingly. For point to point interfaces (like PPP), a default route to its destination is automatically added to the configuration. If the point to point interface is configured for INFORM, then dhcpcd unicasts INFORM to the destination, otherwise it defaults to STATIC.
某些接口需要第三方配置,例如 PPP 或 VPN。当 dhcpcd 中的接口配置标记为 STATIC 或 INFORM 而没有地址时, dhcpcd 将监视该接口,直到添加或删除地址并采取相应操作。对于点对点接口(如 PPP),到其目的地的默认路由会自动添加到配置中。如果点对点接口配置为 INFORM,则 dhcpcd 将 INFORM 单播到目标,否则默认为 STATIC。

dhcpcd requires a Berkeley Packet Filter, or BPF device on BSD based systems and a Linux Socket Filter, or LPF device on Linux based systems for all IPv4 configuration.
dhcpcd 需要 Berkeley 数据包过滤器(或基于 BSD 的系统上的 BPF 设备)和 Linux 套接字过滤器(或基于 Linux 的系统上的 LPF 设备)来进行所有 IPv4 配置。

If restricting dhcpcd to a single interface and optionally address family via the command-line then all further calls to dhcpcd to rebind, reconfigure or exit need to include the same restrictive flags so that dhcpcd knows which process to signal.
如果通过命令行将 dhcpcd 限制为单个接口和可选地址系列,则对 dhcpcd 进行重新绑定、重新配置或退出的所有进一步调用都需要包含相同的限制性标志,以便 < b2> 知道向哪个进程发出信号。

Some DHCP servers implement ClientID filtering. If dhcpcd is replacing an in-use DHCP client then you might need to adjust the clientid option dhcpcd sends to match. If using a DUID in place of the ClientID, edit /var/lib/dhcpcd/duid accordingly.
某些 DHCP 服务器实施 ClientID 过滤。如果 dhcpcd 正在替换正在使用的 DHCP 客户端,那么您可能需要调整 dhcpcd 发送的 clientid 选项以匹配。如果使用 DUID 代替 ClientID,请相应地编辑 /var/lib/dh​​cpcd/duid。

/etc/dhcpcd.conf
Configuration file for dhcpcd. If you always use the same options, put them here.
dhcpcd 的配置文件。如果您总是使用相同的选项,请将它们放在这里。
/usr/lib/dhcpcd/dhcpcd-run-hooks
/usr/lib/dh​​cpcd/dhcpcd-run-hooks
Bourne shell script that is run to configure or de-configure an interface.
运行以配置或取消配置接口的 Bourne shell 脚本。
/usr/lib/dhcpcd/dev /usr/lib/dh​​cpcd/dev
Linux /dev management modules.
Linux /dev 管理模块。
/usr/lib/dhcpcd/dhcpcd-hooks
/usr/lib/dh​​cpcd/dhcpcd-hooks
A directory containing Bourne shell scripts that are run by the above script. Each script can be disabled by using the -C, --nohook option described above.
包含由上述脚本运行的 Bourne shell 脚本的目录。每个脚本都可以通过使用上面描述的 -C--nohook 选项来禁用。
/var/lib/dhcpcd/duid /var/lib/dh​​cpcd/duid
Text file that holds the DUID used to identify the host.
保存用于识别主机的 DUID 的文本文件。
/var/lib/dhcpcd/secret /var/lib/dh​​cpcd/秘密
Text file that holds a secret key known only to the host.
包含只有主机知道的密钥的文本文件。
/var/lib/dhcpcd/interface-ssid.lease
/var/lib/dh​​cpcd/interface-ssid.lease
The actual DHCP message sent by the server. We use this when reading the last lease and use the file's mtime as when it was issued.
服务器发送的实际 DHCP 消息。我们在读取最后一个租约时使用它,并使用文件发出时的 mtime。
/var/lib/dhcpcd/interface-ssid.lease6
/var/lib/dh​​cpcd/interface-ssid.lease6
The actual DHCPv6 message sent by the server. We use this when reading the last lease and use the file's mtime as when it was issued.
服务器发送的实际 DHCPv6 消息。我们在读取最后一个租约时使用它,并使用文件发出时的 mtime。
/var/lib/dhcpcd/rdm_monotonic
/var/lib/dh​​cpcd/rdm_monotonic
Stores the monotonic counter used in the replay field in Authentication Options.
存储“身份验证选项”中重播字段中使用的单调计数器。
/run/dhcpcd/pid /运行/dhcpcd/pid
Stores the PID of dhcpcd running on all interfaces.
存储所有接口上运行的 dhcpcd 的PID。
/run/dhcpcd/interface.pid
Stores the PID of dhcpcd running on the interface.
存储接口上运行的 dhcpcd 的PID。
/run/dhcpcd/sock /运行/dhcpcd/sock
Control socket to the manager daemon.
管理器守护进程的控制套接字。
/run/dhcpcd/unpriv.sock
Unprivileged socket to the manager daemon, only allows state retrieval.
管理器守护程序的非特权套接字,仅允许状态检索。
/run/dhcpcd/interface.sock
Control socket to per interface daemon.
控制每个接口守护进程的套接字。
/run/dhcpcd/interface.unpriv.sock
Unprivileged socket to per interface daemon, only allows state retrieval.
每个接口守护程序的非特权套接字仅允许状态检索。

fnmatch(3), if_nametoindex(3), dhcpcd.conf(5), resolv.conf(5), dhcpcd-run-hooks(8), resolvconf(8)
fnmatch(3)、if_nametoindex(3)、dhcpcd.conf(5)、resolv.conf(5)、dhcpcd-run-hooks(8)、resolvconf(8)

RFC 951, RFC 1534, RFC 2104, RFC 2131, RFC 2132, RFC 2563, RFC 2855, RFC 3004, RFC 3118, RFC 3203, RFC 3315, RFC 3361, RFC 3633, RFC 3396, RFC 3397, RFC 3442, RFC 3495, RFC 3925, RFC 3927, RFC 4039, RFC 4075, RFC 4242, RFC 4361, RFC 4390, RFC 4702, RFC 4074, RFC 4861, RFC 4833, RFC 4941, RFC 5227, RFC 5942, RFC 5969, RFC 6106, RFC 6334, RFC 6355, RFC 6603, RFC 6704, RFC 7217, RFC 7550, RFC 7844.
RFC 951、RFC 1534、RFC 2104、RFC 2131、RFC 2132、RFC 2563、RFC 2855、RFC 3004、RFC 3118、RFC 3203、RFC 3315、RFC 3361、RFC 3633、RFC 3396、RFC 3397、RFC 34 42、RFC 3495 、RFC 3925、RFC 3927、RFC 4039、RFC 4075、RFC 4242、RFC 4361、RFC 4390、RFC 4702、RFC 4074、RFC 4861、RFC 4833、RFC 4941、RFC 5227、RFC 5942、RFC 5969、RFC 6106、RFC 6334、RFC 6355、RFC 6603、RFC 6704、RFC 7217、RFC 7550、RFC 7844。

Roy Marples <roy@marples.name>
罗伊·马普尔斯 < roy@marples.name>

Please report them to https://roy.marples.name/projects/dhcpcd
请向 https://roy.marples.name/projects/dhcpcd 举报

December 10, 2023 2023 年 12 月 10 日 Linux 6.7.4-arch1-1