linux
dhcpcd many options: actions, Restricting behaviour …
interface [interface] […]
dhcpcd --rebind interface
dhcpcd --release interface
dhcpcd --dumplease interface
dhcpcd --exit
dhcpcd --version
Gets its host information (IP address, netmask,DNS server etc) from a DHCP server and configures its network.
Updates domain and DNServers in resolvconf (8), or /etc/resolv.conf .
If the hostname is blank, (null) or localhost or force_hostname is TRUE ,
sets the hostname.
Then waits for the lease renewal time, renews its lease and reconfigures, ….
If an interface reports carrier obtains a lease then forks.
Some options send a signal a running DHCPcd process.
-
As a daemon without a list of interfaces(Master mode), discovers interfaces.
- If an interface is given, runs as a separate instance on that interface with
--waitip enabled .
Hooking into events
May be invoked by
/etc/systemd/system/dhcpcd.service.d/wait.conf : /usr/lib/dhcpcd5/dhcpcd --quiet --waitip [--background]
Runs /lib/dhcpcd/dhcpcd-run-hooks
which invokes scripts :
See dhcpcd-run-hooks(8)
Scripts from /usr/share/dhcpcd/hooks: 10-wpa_supplicant, 15-timezone and 29-lookup-hostname
can be copied to /lib/dhcpcd/dhcpcd-hooks
10-wpa_supplicant ensures that wpa_supplicant is always running on a hot-plugged wireless interface.
Actions
|
---|
-T --test
Outputs specific DHCP variables. The interface and configuration files are not changed.
Calls /lib/dhcpcd/dhcpcd-run-hooks with TEST
|
> sudo dhcpcd --test
dhcp6_listen: Address already in use
DUID 00:01:00:01:2a:be:6b:ca:b8:27:eb:c3:29:26
eth0: IAID eb:c3:29:26
eth0: soliciting an IPv6 router
eth0: Router Advertisement from fe80::7a67:eff:fe0d:f57e
eth0: rebinding lease of 192.168.1.14 distributing static address
eth0: leased 192.168.1.14 for 18000 seconds
interface='wlan0'
pid='14455'
protocol='ra'
reason='TEST'
ifcarrier='up'
ifflags='4163'
ifmtu='1500'
ifssid='disabled'
ifwireless='1'
nd1_acquired='74453'
nd1_from='fe80::7a67:eff:fe0d:f57e'
nd1_mtu='1500'
nd1_now='74453'
nd1_prefix_information1_flags='LA'
nd1_prefix_information1_length='64'
nd1_prefix_information1_pltime='7200'
nd1_prefix_information1_prefix=
'2600:4041:4312:fb00::'
nd1_prefix_information1_vltime='7200'
nd1_rdnss1_lifetime='600'
nd1_rdnss1_servers=
'2600:4041:4312:fb00::1'
nd1_source_address='78670e0df57e'
wlan0: requesting DHCPv6 information
wlan0: rebinding lease of 192.168.1.63
dhcp6_listen: Address already in use
wlan0: leased 192.168.1.63
for 86400 seconds
Same information reported a second time…
dhcpcd exited
| | | |
rapid_commit is not sent 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 Uses logfile , truncated when opened, reopened on SIGUSR2 . Useful when run interactively on one interface.
| -q --quiet only warnings and errors will be displayed.
| -f --config file
Default:/etc/dhcpcd.conf , processed before command line options.
| -c --script script only run script .
| -C --nohook script
Don't run script . Matches full name, or prefix with 2 digits, optionally ending with .sh
To changing DNS settings : dhcpcd --nohook resolv.conf eth0
|
-g --reconfigure
Re-apply IP address, routing and run dhcpcd-run-hooks for each interface.
Useful when PPP or VPN changes the routing table, DNS, etc
| -n --rebind [interface] Reload configuration and rebind.
If dhcpcd is not running, it starts up as normal.
wpa_supplicant reloads its configuration 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
regardless of --persistent .
If no interfaces are left running, dhcpcd exits.
| -y --reboot seconds With an existing lease, Waits before discovery.
Waits again before starting fallback states after discovery .
Default 5 seconds. If seconds is zero, skips the reboot and goes to discover.
IPv4LL is started after the first reboot timeout .
On DHCPv6 only than skips the reboot phase.
|
-b --background Background immediately,
| -B --nobackground
| -w
--waitip [4 | 6]
Wait for an address to be assigned before forking to the background. 4 IPv4, 6 IPv6 address to be assigned.
With more than one address protocol dhcpcd forks to the background after all waiting conditions are satisfied.
| -e --env value
Add value to the environment for dhcpcd-run-hooks.
Example: always set the hostname -e force_hostname=YES.
| -M --master
Start Master mode even if only one interface is specified.
| -p --persistent Don't de-configure the interface on exit
| -t --timeout seconds
If working on one interface, exit after timeout, otherwise fork to the background.
Default 30. (Don't use 0 i.e. wait forever)
| -U --dumplease interface see github
??Dumps the last lease to stdout.
Read a DHCP wire message Defaiult standard input . Use -4 or -6
| -P --printpidfile output the pidfile
| -D --duid Generate an RFC 4361 compliant clientid,
and stores it in /etc/dhcpcd.duid
| --version and exits
| -x --exit [interface] From one dhcpcd, signal other dhcpcds in Master mode or interface to exit. Wait until they have exited.
Use --persistent to leave interface(s) unchanged.
| -V --variables
Display option codes for use in dhcpcd-run-hooks.
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 --variables
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 configuring interface.
| -K --nolink ignore link messages for carrier status.
Use --waitip to specify which protocol(s) to configure
| -4 --ipv4only
| -6 --ipv6only
| -A --noarp Don't request or claim address by ARP. disables IPv4LL.
-L --noipv4ll Don't use IPv4LL (aka APIPA, aka Bonjour, aka ZeroConf).
|
-l --leasetime seconds Request a specific lease time. default server controls lease time.
| -E --lastlease If cannot obtain a lease, use the last lease acquired for the interface anyway.
--lastleaseextend
Lease will be retained after it expires. It will be given it up if another host tries to
claim it via ARP. violates RFC2131 7
| -r --request [address]
Request the address in the DHCP DISCOVER message.
Default: first address assigned
| -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
| -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 --option option Request option variable for use in /lib/dhcpcd/dhcpcd-run-hooks.
-O --nooption option Removes option from the DHCP message before processing.
| -Q --require option
Requires option be present in DHCP messages or the message is ignored.
To force dhcpcd to respond to DHCP servers (i.e. 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 packets from address[/cidr].
-z --allowinterfaces pattern
When discovering interfaces, name must match pattern
--denyinterfaces takes precedence!
| --inactivestart interfaces on the command line.
This allows starting in Master mode and waiting for commands to start interfaces
| --nodev No /dev management modules are loaded..
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
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
3RD Party Link Management
When an interface configuration in dhcpcd is marked as
STATIC or INFORM without an address
(for example PPP or VPN) hcpcd monitors 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.
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.
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.
2/13/24 Linux dapi2 5.10.103+ #1529 Tue Mar 8 12:19:18 GMT 2022 armv6l GNU/Linux
> cat /etc/os-release
Raspbian GNU/Linux 10 (buster)
dapi2:/etc/dhcp > dhcpcd --version
dhcpcd 8.1.2
Copyright (c) 2006-2019 Roy Marples
Compiled in features: INET ARP ARPing IPv4LL INET6 DHCPv6 AUTH
answer:/home/dgerman > cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
answer:/home/dgerman > dhcpcd --version
dhcpcd 8.1.2
Copyright (c) 2006-2019 Roy Marples
Compiled in features: INET ARP ARPing IPv4LL INET6 DHCPv6 AUTH
answer:/home/dgerman > dhcpd --version aptitude ?
-bash: dhcpd: command not found
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`
|