← 返回命令列表

Linux command

dhcpcd 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Obtain a lease

sudo dhcpcd [eth0]

Release

sudo dhcpcd -k

Request

sudo dhcpcd -n

Configure IPv4 only

sudo dhcpcd -4 [eth0]

Configure IPv6 only

sudo dhcpcd -6 [eth0]

Test mode

sudo dhcpcd -T [eth0]

说明

dhcpcd is a DHCP and DHCPv6 client daemon that automatically configures network interfaces. It obtains IP addresses, default routes, and DNS servers from DHCP servers on the network, and can also process IPv6 Router Advertisements for stateless autoconfiguration. The daemon runs in the background managing network configuration as interfaces come up and down. It handles lease renewal, rebinding, and release operations automatically. Configuration hooks allow running custom scripts when network state changes. dhcpcd is commonly used as the default network configuration tool on many Linux distributions, particularly those without NetworkManager. It's lightweight, follows RFC standards closely, and integrates well with embedded and server environments.

参数

-k, --release
Release current leases and exit
-n, --rebind
Request new leases (rebind)
-x, --exit
Exit daemon
-d, --debug
Debug mode (don't fork)
-B, --nobackground
Don't run in background
-4, --ipv4only
Only configure IPv4
-6, --ipv6only
Only configure IPv6
-b, --background
Background immediately
-S, --static _value_
Configure a static DHCP value (e.g., ip_address, routers, domain_name_servers)
-s, --inform _address_
Send DHCP INFORM instead of DISCOVER/REQUEST
-T, --test
Test mode, don't configure interfaces

FAQ

What is the dhcpcd command used for?

dhcpcd is a DHCP and DHCPv6 client daemon that automatically configures network interfaces. It obtains IP addresses, default routes, and DNS servers from DHCP servers on the network, and can also process IPv6 Router Advertisements for stateless autoconfiguration. The daemon runs in the background managing network configuration as interfaces come up and down. It handles lease renewal, rebinding, and release operations automatically. Configuration hooks allow running custom scripts when network state changes. dhcpcd is commonly used as the default network configuration tool on many Linux distributions, particularly those without NetworkManager. It's lightweight, follows RFC standards closely, and integrates well with embedded and server environments.

How do I run a basic dhcpcd example?

Run `sudo dhcpcd [eth0]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -k, --release do in dhcpcd?

Release current leases and exit