linux
dhcpcd
[-146ABbDdEGgHJKLMNPpqTV]
[-C| --nohook hook]
[-c| --script script]
[-e| --env value]
[-F| --fqdn FQDN]
[-f| --config file]
[-h| --hostname hostname]
[-I| --clientid clientid]
[-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]]
[--inform6]
[-t| --timeout seconds]
[-u| --userclass class]
[-v| --vendor code, value]
[-i| --vendorclassid vendorclassid]
[-W| --whitelist address
[-X| --blacklist address
[/cidr]]
[-w]
[--waitip
[4 | 6]]
[-y| --reboot seconds]
[/cidr]]
[-Z| --denyinterfaces pattern]
[-z| --allowinterfaces pattern]
[--inactive]
interface [interface] […]
dhcpcd -n --rebind interface
dhcpcd -k --release interface
dhcpcd -U --dumplease interface
dhcpcd -x --exit
dhcpcd --version
dhcpcd 8.1.2 Raspberry pi buster 2/3/20
Compiled in features: INET IPv4LL INET6 DHCPv6 AUTH
was:on raspberry pi 4/18/19
dhcpcd 6.11.5
Copyright (c) 2006-2016 Roy Marples
May be invoked by /etc/systemd/system/dhcpcd.service.d/wait.conf : /usr/lib/dhcpcd5/dhcpcd -q -w
Gets the host information (IP address, routes, etc) from a DHCP server and configures the network interfaces.
Runs configuration script which writes DNS information to resolvconf (8), or /etc/resolv.conf .
If the hostname is currently blank, (null) or localhost or force_hostnam is TRUE ,
sets the hostname to the one supplied by the DHCP server.
Then waits for the lease renewal time, renews its lease and reconfigures, ….
Some options send a signal a DHCPcd process already running.
If an interface reports carrier obtains a lease then forks.
Local Link configuration
If fails to obtain a lease, probes for a valid IPv4LL address (aka ZeroConf, aka APIPA). then
looks for a DHCP server to get a proper address.
When using IPv4LL, failure means there is a reverse ARP proxy installed which defeats IPv4LL probing.
To disable this behaviour, use -L , --noipv4ll
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.
Hooking into events
Runs /lib/dhcpcd/dhcpcd-run-hooks
which invokes scripts
/etc/dhcpcd.enter-hook distributed empty
/lib/dhcpcd/dhcpcd-hooks/* and
/etc/dhcpcd.exit-hook distributed empty
in lexical order, or the script specified by --script .
The default installation supplies the scripts 01-test, 02-dump, 20-resolv.conf and 30-hostname.
Disable a script by using --nohook . See dhcpcd-run-hooks(8)
dhcpcd ignores the exit code of the script.
Additional scripts in /usr/share/dhcpcd/hooks: 10-wpa_supplicant, 15-timezone and 29-lookup-hostname
need to be copied to /lib/dhcpcd/dhcpcd-hooks
For example, 10-wpa_supplicant ensures that wpa_supplicant is always running on a hot-plugged wireless interface.
Actions
|
---|
-T --test
On receipt of DHCP messages call /lib/dhcpcd/dhcpcd-run-hooks with the reason of TEST
which outputs specific DHCP variables in the message. The interface and configuration files are not changed.
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.
| -d --debug messages to the stderr and syslog.
| -j --logfile logfile Writes logfile not syslog, truncated when opened and is reopened on SIGUSR2
| -q --quiet only warnings and errors will be displayed. The messages are logged .
| -f --config file
Default:/etc/dhcpcd.conf processes the config file before command line options.
| -c --script script script instead of
/lib/dhcpcd/dhcpcd-run-hooks which runs everything in
/etc/dhcpcd.enter-hook /lib/dhcpcd/dhcpcd-hooks and /etc/dhcpcd.exit-hook
-C --nohook script
Don't run this hook script. Matches full name, or prefixed with 2 numbers optionally ending with .sh
To changing DNS settings : dhcpcd -C resolv.conf eth0
|
-g --reconfigure
re-apply IP address, routing and run dhcpcd-run-hooks(8) for each interface. useful so 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.
does not read a new configuration
| -n --rebind [interface] reload configuration and rebind the specified interface.
If no interface is specified applies to all interfaces in Master mode.
If dhcpcd is not running, it starts up as normal.
May also cause wpa_supplicant(8) to reload its configuration for each interface as well if the relevant hook script has been installed.
| -N --renew [interface renew existing addresses
If no interface is specified applies to all in Master mode.
If dhcpcd is not running, it starts up as normal.
Unlike --rebind the configuration is not reloaded.
| -k --release [interface release lease and de-configure the interface regardless of --persistent .
If no interface is specified then applies to all in Master mode.
If no interfaces are left running, dhcpcd exits.
| -y --reboot seconds before moving to the discover phase if there is an old lease to use.
before starting fallback states from the discover phase.
IPv4LL is started when the first reboot timeout is reached.
Default 5 seconds.
skips the reboot phase and go into discover. This on DHCPv6 only than skips the reboot phase.
|
-b --background Background immediately, for startup scripts which don't disable link messages for carrier status.
| -B --nobackground
| -w Wait for an address to be assigned before forking to the background.
| --waitip [4 | 6]
Wait for an address to be assigned before forking to the background. 4 IPv4, 6 IPv6 address 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.
| -e --env value
Add value to the environment for use in dhcpcd-run-hooks(8).
Example: force the hostname hook to always set the hostname -e force_hostname=YES.
| -M --master
Start Master mode even if only one interface specified on the command line. See Multiple Interfaces .
| -D --duid Generate an RFC 4361 compliant clientid,
and stores it in /etc/dhcpcd.duid
| -p --persistent Don't de-configuring the interface and configuration on exit
| -t --timeout seconds Default 30. (Don't use 0 i.e. wait forever)
If is working on a single interface then exits, otherwise forks to the background.
| -U --dumplease interface
Dumps the last lease for the interface to stdout. If omitted, standard input is used to read a DHCP wire formatted message. Use the -4 or -6 flags to specify an address family.
| -P --printpidfile output the pidfile
| --version and exits
| -x --exit [interface signal dhcpcd running on interface to exit.
If no interface is specified, then the above is applied to all interfaces in Master mode.
See --persistent to control configuration persistence on exit, enabled by default in dhcpcd.conf(5).
Waits until this process has exited.
| -V --variables
Display a list of option codes, the associated variable and encoding for use in dhcpcd-run-hooks(8).
Variables are pre-fixed with new_ and old_ unless the option number is -.
Variables without an option are part of the DHCP message and cannot be directly requested.
|
> sudo dhcpcd --test --debug -V
Interface options:
- interface
- reason
- pid
- ifcarrier
- ifmetric
- ifwireless
- ifflags
- ssid
- profile
- interface_order
DHCPv4 options:
ip_address
subnet_cidr
network_number
filename
server_name
1 subnet_mask IP addr request
121 classless_static_routes string rfc3442
249 ms_classless_static_routes string rfc3442
33 static_routes IP addrs request
3 routers IP addrs request
2 time_offset uint32
4 time_servers IP addrs
5 ien116_name_servers IP addrs
6 domain_name_servers IP addrs
7 log_servers IP addrs
8 cookie_servers IP addrs
9 lpr_servers IP addrs
10 impress_servers IP addrs
11 resource_location_servers IP addrs
12 host_name dname
13 boot_size uint16
14 merit_dump string
15 domain_name array dname
16 swap_server ipaddress
17 root_path string
18 extensions_path string
19 ip_forwarding uint8
20 non_local_source_routing uint8
21 policy_filter IP addrs
22 max_dgram_reassembly uint16
23 default_ip_ttl uint8
24 path_mtu_aging_timeout uint32
25 path_mtu_plateau_table array uint16
26 interface_mtu uint16
27 all_subnets_local uint8
28 broadcast_address IPaddr request
29 perform_mask_discovery uint8
30 mask_supplier uint8
31 router_discovery uint8
32 router_solicitation_address IP addr
34 trailer_encapsulation uint8
35 arp_cache_timeout uint32
36 ieee802_3_encapsulation uint16
37 default_tcp_ttl uint8
38 tcp_keepalive_interval uint32
39 tcp_keepalive_garbage uint8
40 nis_domain string
41 nis_servers IP addrs
42 ntp_servers IP addrs
43 vendor_encapsulated_options binhex
44 netbios_name_servers IP addrs
45 netbios_dd_server ipaddress
46 netbios_node_type uint8
47 netbios_scope string
48 font_servers IP addrs
49 x_display_manager IP addrs
50 dhcp_requested_address ipaddress
51 dhcp_lease_time uint32 request
52 dhcp_option_overload uint8
53 dhcp_message_type uint8
54 dhcp_server_identifier ipaddress
55 dhcp_parameter_request_list array uint8
56 dhcp_message string
57 dhcp_max_message_size uint16
58 dhcp_renewal_time uint32 request
59 dhcp_rebinding_time uint32 request
60 vendor_class_identifier string
61 dhcp_client_identifier binhex
64 nisplus_domain string
65 nisplus_servers IP addrs
66 tftp_server_name dname
67 bootfile_name string
68 mobile_ip_home_agent IP addrs
69 smtp_server IP addrs
70 pop_server IP addrs
71 nntp_server IP addrs
72 www_server IP addrs
73 finger_server IP addrs
74 irc_server IP addrs
75 streettalk_server IP addrs
76 streettalk_directory_assistance_serverarray
ipaddress
77 user_class binhex
78 slp_agent embed
79 slp_service embed
80 rapid_commit flag norequest
81 fqdn embed
83 isns embed
85 nds_servers IP addrs
86 nds_tree_name raw
87 nds_context raw
88 bcms_controller_names array domain
89 bcms_controller_address IP addrs
90 auth embed
91 client_last_transaction_time uint32
92 associated_ip IP addrs
98 uap_servers string
99 geoconf_civic encap
100 posix_timezone string
101 tzdb_timezone string
116 auto_configure uint8
117 name_service_search array uint16
118 subnet_selection ipaddress
119 domain_search array domain
120 sip_server string rfc3361
122 tsp encap
123 geoconf binhex
124 vivco binhex
125 vivso embed
136 pana_agent IP addrs
137 lost_server domain
138 capwap_ac IP addrs
139 mos_ip encap
140 mos_domain encap
141 sip_ua_cs_list array domain
142 andsf IP addrs
143 andsf6 array IP6addr
144 geoloc binhex
145 forcerenew_nonce_capable array uint8
146 rdnss_selection embed
150 tftp_servers IP addrs
208 pxelinux_magic binhex
209 config_file string
210 path_prefix string
211 reboot_time uint32
212 sixrd embed
213 access_domain domain
221 vss encap
252 wpad_url string
ND options:
1 source_address binhex
2 target_address binhex
3 prefix_information embed index
5 mtu embed
25 rdnss embed index
31 dnssl embed index
| | | | | | | | |
DHCPv6 options:
1 client_id binhex
2 server_id binhex
3 ia_na embed index norequest
4 ia_ta embed index norequest
5 ia_addr embed index norequest
6 option_request array uint16
7 preference uint8
8 elased_time uint16
9 dhcp_relay_msg binhex
11 auth embed
12 unicast ip6address
13 status_code embed norequest
14 rapid_commit flag norequest
15 user_class binhex
16 vivco binhex
17 vivso embed
18 interface_id binhex
19 reconfigure_msg uint8
20 reconfigure_accept flag
21 sip_servers_names array domain
22 sip_servers_addresses array ip6address
23 name_servers array ip6address
24 domain_search array domain
25 ia_pd embed index norequest
26 prefix embed index
27 nis_servers array ip6address
28 nisp_servers array ip6address
29 nis_domain_name string
30 nisp_domain_name string
31 sntp_servers array ip6address
32 info_refresh_time uint32
33 bcms_server_d array domain
34 bcms_server_a array ip6address
36 geoconf_civic encap
37 remote_id embed
38 subscriber_id binhex
39 fqdn embed
40 pana_agent array ip6address
41 posix_timezone string
42 tzdb_timezone string
43 ero array uint16
49 mip6_hnidf domain
50 mip6_vdinf encap
51 lost_server domain
52 capwap_ac array ip6address
53 relay_id binhex
54 mos_ip encap
55 mos_domain encap
56 ntp_server encap
57 access_domain domain
58 sip_ua_cs_list array domain
59 bootfile_url string
60 bootfile_param binhex
61 architecture_types array uint16
62 nii embed
63 geoloc binhex
64 aftr_name domain
67 pd_exclude embed
69 mip6_idinf encap
70 mip6_udinf encap
71 mip6_hnp embed
72 mip6_haa ip6address
73 mip6_haf domain
74 rdnss_selection embed
75 krb_principal_name string
76 krb_realm_name string
78 krb_kdc embed
80 link_address ip6address
82 sol_max_rt uint32 request
83 inf_max_rt uint32 request
| | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | |
Restricting behaviour
|
---|
-1 --oneshot Exit after its configuring an interface.
itsiUse the --waitip
to specify which protocol(s) to configure before exiting.
| -4 --ipv4only
| -6 --ipv6only
| -A --noarp Don't request or claim the address by ARP. disables IPv4LL.
-K --nolink Don't receive link messages for carrier status.
| -L --noipv4ll Don't use IPv4LL (aka APIPA, aka Bonjour, aka ZeroConf).
|
-l --leasetime seconds Request a specific lease time in seconds. By default leaves leasing to the DHCP server.
| -E --lastlease If dhcpcd cannot obtain a lease, then try to use the last lease acquired for the interface.
| --lastleaseextend
lease will be retained after it expires. dhcpcd will give it up if any other host tries to
claim it for their own via ARP. violates RFC2131 7 which states the lease should be dropped once expired.
| -r --request [address]
Request the address in the DHCP DISCOVER message. There is no guarantee the DHCP server will give it.
If no address is given then the first address currently assigned to the interface is used.
| -s --inform [address[/cidr]]
like --request but sends a DHCP INFORM instead of DISCOVER/REQUEST.
This does not get a lease, just notifies the DHCP server of the address in use.
include the optional cidr network number in case the address is not already configured on the interface.
dhcpcd remains running and as if it has an infinite lease.
Will not de-configure the interface when it exits.
If dhcpcd fails to contact a DHCP server then returns a failure instead of falling back on IPv4LL.
| --inform6
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.
Only needed when not processing IPv6RA messages
| -F --fqdn disable|none| ptr|both
DHCP server updates DNS using FQDN instead of just a hostname.
dhcpcd does no DNS updates. dhcpcd encodes the FQDN hostname as specified in RFC1035.
| -h --hostname [hostname]
Send hostname to the DHCP server to be registered in DNS. Default system hostname .
| -I --clientid [clientid]
Send the clientid. Use xx:xx:xx for hexadecimal.
If hardware address is longer than 8 bytes or clientid is an not specified
sends hardware family and the hardware address.
| -i --vendorclassid vendorclassid
Override the DHCPv4 vendorclassid field sent. Default: dhcpcd-version:os:machine:platform . For example
dhcpcd-5.5.6:NetBSD-6.99.5:i386:i386
| -S --static value Does not obtain a lease and with an infinite lease time.
Example :
dhcpcd -S ip_address=192.168.0.10/24 \
-S routers=192.168.0.1 \
-S domain_name_servers=192.168.0.1 \
eth0
Cannot set static DHCPv6 values. Use --env
| -u --userclass class Tags the DHCPv4 message.
DHCP servers use this to give members of the class DHCP options other
than the default, without having to know hardware address or hostname.
| -v --vendor code[,value
Add an encapsulated vendor option. code is 1..254 .
To add a raw vendor string, omit code but keep the comma.
Examples.
IP address: dhcpcd -v 01,192.168.0.2 eth0
hex code: dhcpcd -v 02,01:02:03:04:05 eth0
IP address as a string: dhcpcd -v 03,\"192.168.0.2\" eth0
un-encapsulated vendor option : dhcpcd -v ,"hello world" eth0
| -o --option option Request option variable for use in /lib/dhcpcd/dhcpcd-run-hooks.
-m --metric metric Metrics used to prefer an interface over another one, lowest wins.
Default 200 + if_nametoindex(3). 100 will be added for wireless interfaces.
| -G --nogateway Don't any default routes.
| -H --xidhwaddr Use the last four bytes of the hardware address as xid instead of a random number.
| -J --broadcast Instructs the DHCP server to broadcast replies back to the client.
| -O --nooption option Removes option from the DHCP message before processing.
|
-Q --require option
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, --require dhcp_message_type.
-W --whitelist address[/cidr]
Only accept packets from address[/cidr]
--blacklist is ignored if --whitelist is set.
| -X --blacklist address[/cidr] Ignore all packets from address[/cidr].
-Z --denyinterfaces pattern […]
When discovering interfaces, the interface name must not match pattern which is a space or comma separated list of patterns
| -z --allowinterfaces pattern
When discovering interfaces, the interface name must match pattern
--denyinterfaces takes precedence!
| --inactive
Don't start any interfaces other than those specified on the command line. This allows dhcpcd to be started in Master mode
and then wait for subsequent dhcpcd commands to start each interface as required.
| --nodev
Don't load any /dev management modules.
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
3RDPARTY LINK MANAGEMENT
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 configura-
tion. If the point to point interface is configured for INFORM, then dhcpcd unicasts INFORM to the destination, otherwise it
defaults to STATIC.
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.
Log as result of sudo ifconfig wlan0 down; sudo ifconfig wlan0 up
12:55:16 daemon.info systemd[1]: Starting dhcpcd on all interfaces...
12:55:17 daemon.err dhcpcd[279]: no valid interfaces found
12:55:17 daemon.info dhcpcd[279]: forked to background, child pid 289
12:55:17 daemon.info systemd[1]: Started dhcpcd on all interfaces.
12:55:20 daemon.info dhcpcd-run-hooks[378]: wlan0: starting wpa_supplicant
12:55:24 daemon.info dhcpcd[289]: wlan0: waiting for carrier
12:55:25 daemon.info dhcpcd[289]: eth0: waiting for carrier
12:55:25 daemon.info dhcpcd[289]: wlan0: carrier acquired
12:55:25 daemon.info dhcpcd[289]: DUID 00:01:00:01:21:b0:de:59:b8:27:eb:0f:cf:06
12:55:25 daemon.info dhcpcd[289]: wlan0: IAID eb:1c:5b:93
12:55:25 daemon.info dhcpcd[289]: wlan0: adding address fe80::2360:c560:acef:fd7e
12:55:25 daemon.info dhcpcd[289]: wlan0: carrier lost
12:55:25 daemon.info dhcpcd[289]: wlan0: deleting address fe80::2360:c560:acef:fd7e
12:55:25 daemon.info dhcpcd[289]: eth0: carrier acquired
12:55:25 daemon.info dhcpcd[289]: eth0: IAID 4c:53:44:58
12:55:25 daemon.info dhcpcd[289]: eth0: adding address fe80::dbd3:57ef:a88c:c782
12:55:25 daemon.info dhcpcd[289]: wlan0: carrier acquired
12:55:25 daemon.info dhcpcd[289]: wlan0: IAID eb:1c:5b:93
12:55:25 daemon.info dhcpcd[289]: wlan0: adding address fe80::314c:5853:cd9c:11c3
12:55:25 daemon.info dhcpcd[289]: wlan0: soliciting a DHCP lease
12:55:26 daemon.info dhcpcd[289]: eth0: soliciting an IPv6 router
12:55:26 daemon.info dhcpcd[289]: eth0: rebinding lease of 192.168.1.10
12:55:26 daemon.info dhcpcd[289]: eth0: probing address 192.168.1.10/24
12:55:26 daemon.info dhcpcd[289]: wlan0: soliciting an IPv6 router
12:55:26 daemon.info dhcpcd[289]: wlan0: offered 192.168.1.3 from 192.168.1.1
12:55:26 daemon.info dhcpcd[289]: wlan0: probing address 192.168.1.3/24
12:55:31 daemon.info dhcpcd[289]: wlan0: leased 192.168.1.3 for 600 seconds
12:55:31 daemon.info dhcpcd[289]: wlan0: adding route to 192.168.1.0/24
12:55:31 daemon.info dhcpcd[289]: wlan0: adding default route via 192.168.1.1
12:55:32 daemon.info dhcpcd[289]: eth0: leased 192.168.1.10 for 600 seconds
12:55:32 daemon.info dhcpcd[289]: eth0: adding route to 192.168.1.0/24
12:55:32 daemon.info dhcpcd[289]: eth0: adding default route via 192.168.1.1
12:55:38 daemon.warning dhcpcd[289]: eth0: no IPv6 Routers available
12:55:38 daemon.warning dhcpcd[289]: wlan0: no IPv6 Routers available
|
FILES /etc/dhcpcd.conf
/etc/dhcpcd.duid DUID used to identify the host.
/etc/dhcpcd.secret secret key known only to the host.
/lib/dhcpcd/dhcpcd-run-hooks Bourne shell script that is run to configure or de-configure an interface.
/lib/arm-linux-gnueabihf/dhcpcd/dev management modules.
/lib/dhcpcd/dhcpcd-hooks
/var/lib/dhcpcd5/dhcpcd-interface-ssid.lease actual DHCP message sent by the server.
used when reading the last lease and use the files mtime as when it was issued.
/var/lib/dhcpcd5/dhcpcd-interface-ssid.lease6
/var/lib/dhcpcd5/dhcpcd-rdm.monotonic counter used in the replay field in Authentication Options.
/var/run/dhcpcd.pid PID of dhcpcd running on all interfaces.
/var/run/dhcpcd-interface.pid PID of dhcpcd running on the interface.
/var/run/dhcpcd.sock Control socket to the master daemon.
/var/run/dhcpcd.unpriv.sock Unpriviledged socket to the master daemon, only for state retrieval.
/var/run/dhcpcd-interface.sock Control socket to per interface daemon.
dhcpcd is also an implementation of
BOOTP client specified in RFC 951.
IPv6 Router Solicitor as specified in RFC 4861 and RFC 6106.
IPv6 Privacy Extensions to AutoConf as specified in RFC 4941. needs to be enabled in the kernel
DHCPv6 client as specified in RFC 3315.
By default, dhcpcd only starts DHCPv6 when instructed by an IPV6 Router Advertisement.
If no Identity Association is configured, then a Non-temporary Address is requested.
See
fnmatch(3), if_nametoindex(3), dhcpcd.conf(5), resolv.conf(5), dhcpcd-run-hooks(8), resolvconf(8)
/etc/syslog.conf : local0.* /var/log/dhcpcd.log
and refresh syslogd daemon: kill -1 `cat /var/run/syslogd.pid`
|