1dhclient(8) System Manager's Manual dhclient(8)
2
3
4
6 dhclient - Dynamic Host Configuration Protocol Client
7
9 dhclient [ -4 | -6 ] [ -S ] [ -N [ -N... ] ] [ -T [ -T... ] ] [ -P [
10 -P... ] ] -R ] [ -i ] [ -I ] [ -4o6 port ] [ -D LL|LLT ] [ -p port-
11 number ] [ -d ] [ -df duid-lease-file ] [ -e VAR=value ] [ -q ] [ -1 ]
12 [ -r | -x ] [ -lf lease-file ] [ -pf pid-file ] [ --no-pid ] [ -cf con‐
13 fig-file ] [ -sf script-file ] [ -s server-addr ] [ -g relay ] [ -n ] [
14 -nw ] [ -w ] [ -nc ] [ -B ] [ -C dhcp-client-identifier ] [ -H host-
15 name ] [ -F fqdn.fqdn ] [ -V vendor-class-identifier ] [ --request-
16 options request-option-list ] [ --timeout timeout ] [ --dad-wait-time
17 seconds ] [ -v ] [ --version ] [ if0 [ ...ifN ] ]
18
20 The Internet Systems Consortium DHCP Client, dhclient, provides a means
21 for configuring one or more network interfaces using the Dynamic Host
22 Configuration Protocol, BOOTP protocol, or if these protocols fail, by
23 statically assigning an address.
24
26 The DHCP protocol allows a host to contact a central server which main‐
27 tains a list of IP addresses which may be assigned on one or more sub‐
28 nets. A DHCP client may request an address from this pool, and then
29 use it on a temporary basis for communication on network. The DHCP
30 protocol also provides a mechanism whereby a client can learn important
31 details about the network to which it is attached, such as the location
32 of a default router, the location of a name server, and so on.
33
34 There are two versions of the DHCP protocol DHCPv4 and DHCPv6. At
35 startup the client may be started for one or the other via the -4 or -6
36 options.
37
38 On startup, dhclient reads the dhclient.conf for configuration instruc‐
39 tions. It then gets a list of all the network interfaces that are con‐
40 figured in the current system. For each interface, it attempts to con‐
41 figure the interface using the DHCP protocol.
42
43 In order to keep track of leases across system reboots and server
44 restarts, dhclient keeps a list of leases it has been assigned in the
45 dhclient.leases file. On startup, after reading the dhclient.conf
46 file, dhclient reads the dhclient.leases file to refresh its memory
47 about what leases it has been assigned.
48
49 When a new lease is acquired, it is appended to the end of the
50 dhclient.leases file. In order to prevent the file from becoming arbi‐
51 trarily large, from time to time dhclient creates a new dhclient.leases
52 file from its in-core lease database. The old version of the
53 dhclient.leases file is retained under the name dhclient.leases~ until
54 the next time dhclient rewrites the database.
55
56 Old leases are kept around in case the DHCP server is unavailable when
57 dhclient is first invoked (generally during the initial system boot
58 process). In that event, old leases from the dhclient.leases file
59 which have not yet expired are tested, and if they are determined to be
60 valid, they are used until either they expire or the DHCP server
61 becomes available.
62
63 A mobile host which may sometimes need to access a network on which no
64 DHCP server exists may be preloaded with a lease for a fixed address on
65 that network. When all attempts to contact a DHCP server have failed,
66 dhclient will try to validate the static lease, and if it succeeds,
67 will use that lease until it is restarted.
68
69 A mobile host may also travel to some networks on which DHCP is not
70 available but BOOTP is. In that case, it may be advantageous to
71 arrange with the network administrator for an entry on the BOOTP data‐
72 base, so that the host can boot quickly on that network rather than
73 cycling through the list of old leases.
74
76 The names of the network interfaces that dhclient should attempt to
77 configure may be specified on the command line. If no interface names
78 are specified on the command line dhclient will normally identify all
79 network interfaces, eliminating non-broadcast interfaces if possible,
80 and attempt to configure each interface.
81
82 It is also possible to specify interfaces by name in the dhclient.conf
83 file. If interfaces are specified in this way, then the client will
84 only configure interfaces that are either specified in the configura‐
85 tion file or on the command line, and will ignore all other interfaces.
86
87 The client normally prints no output during its startup sequence. It
88 can be made to emit verbose messages displaying the startup sequence
89 events until it has acquired an address by supplying the -v command
90 line argument. In either case, the client logs messages using the sys‐
91 log(3) facility.
92
94 -4 Use the DHCPv4 protocol to obtain an IPv4 address and configura‐
95 tion parameters. This is the default and cannot be combined
96 with -6.
97
98 -6 Use the DHCPv6 protocol to obtain whatever IPv6 addresses are
99 available along with configuration parameters. It cannot be
100 combined with -4. The -S -T -P -N and -D arguments provide more
101 control over aspects of the DHCPv6 processing. Note: it is not
102 recommended to mix queries of different types together or even
103 to share the lease file between them.
104
105 -4o6 port
106 Participate in the DHCPv4 over DHCPv6 protocol specified by RFC
107 7341. This associates a DHCPv4 and a DHCPv6 client to allow the
108 v4 client to send v4 requests encapsulated in a v6 packet. Com‐
109 munication between the two clients is done on a pair of UDP
110 sockets bound to ::1 port and port + 1. Both clients must be
111 launched using the same port argument.
112
113 -1 Try to get a lease once. On failure exit with code 2. In
114 DHCPv6 this sets the maximum duration of the initial exchange to
115 timeout (from dhclient.conf with a default of sixty seconds).
116
117 -d Force dhclient to run as a foreground process. Normally the
118 DHCP client will run in the foreground until is has configured
119 an interface at which time it will revert to running in the
120 background. This option is useful when running the client under
121 a debugger, or when running it out of inittab on System V sys‐
122 tems. This implies -v.
123
124 -nw Become a daemon immediately (nowait) rather than waiting until
125 an IP address has been acquired.
126
127 -q Be quiet at startup, this is the default.
128
129 -v Enable verbose log messages.
130
131 -w Continue running even if no broadcast interfaces were found.
132 Normally DHCP client will exit if it isn't able to identify any
133 network interfaces to configure. On laptop computers and other
134 computers with hot-swappable I/O buses, it is possible that a
135 broadcast interface may be added after system startup. This
136 flag can be used to cause the client not to exit when it doesn't
137 find any such interfaces. The omshell(1) program can then be
138 used to notify the client when a network interface has been
139 added or removed, so that the client can attempt to configure an
140 IP address on that interface.
141
142 -nc Do not drop capabilities.
143
144 Normally, if dhclient was compiled with libcap-ng support,
145 dhclient drops most capabilities immediately upon startup.
146 While more secure, this greatly restricts the additional actions
147 that hooks in dhclient-script (8) can take. (For example, any
148 daemons that dhclient-script (8) starts or restarts will inherit
149 the restricted capabilities as well, which may interfere with
150 their correct operation.) Thus, the -nc option can be used to
151 prevent dhclient from dropping capabilities.
152
153 The -nc option is ignored if dhclient was not compiled with lib‐
154 cap-ng support.
155
156
157 -n Do not configure any interfaces. This is most likely to be use‐
158 ful in combination with the -w flag.
159
160 -e VAR=value
161 Define additional environment variables for the environment
162 where dhclient-script executes. You may specify multiple -e
163 options on the command line.
164
165 -r Release the current lease and stop the running DHCP client as
166 previously recorded in the PID file. When shutdown via this
167 method dhclient-script will be executed with the specific reason
168 for calling the script set. The client normally doesn't release
169 the current lease as this is not required by the DHCP protocol
170 but some cable ISPs require their clients to notify the server
171 if they wish to release an assigned IP address.
172
173 -x Stop the running DHCP client without releasing the current
174 lease. Kills existing dhclient process as previously recorded
175 in the PID file. When shutdown via this method dhclient-script
176 will be executed with the specific reason for calling the script
177 set.
178
179 -p port-number
180 The UDP port number on which the DHCP client should listen and
181 transmit. If unspecified, dhclient uses the default port of 68.
182 This is mostly useful for debugging purposes. If a different
183 port is specified on which the client should listen and trans‐
184 mit, the client will also use a different destination port - one
185 less than the specified port.
186
187 -s server-addr
188 Specify the server IP address or fully qualified domain name to
189 use as a destination for DHCP protocol messages before dhclient
190 has acquired an IP address. Normally, dhclient transmits these
191 messages to 255.255.255.255 (the IP limited broadcast address).
192 Overriding this is mostly useful for debugging purposes. This
193 feature is not supported in DHCPv6 (-6) mode.
194
195 -g relay
196 Set the giaddr field of all packets to the relay IP address sim‐
197 ulating a relay agent. This is for testing purposes only and
198 should not be expected to work in any consistent or useful way.
199
200 -i Use a DUID with DHCPv4 clients. If no DUID is available in the
201 lease file one will be constructed and saved. The DUID will be
202 used to construct a RFC4361 style client id that will be
203 included in the client's messages. This client id can be over‐
204 ridden by setting a client id in the configuration file. Over‐
205 ridding the client id in this fashion is discouraged. This
206 option is turned on by default, if you want to redefine or turn
207 off sending of client id, use send dhcp-client-identifier =
208 "better identifier" or send dhcp-client-identifier = "" in
209 /etc/dhcp/dhclient.conf.
210
211 -I Use the standard DDNS scheme from RFCs 4701 & 4702.
212
213 --version
214 Print version number and exit.
215
216 Options available for DHCPv6 mode:
217
218 -S Use Information-request to get only stateless configuration
219 parameters (i.e., without address). This implies -6. It also
220 doesn't rewrite the lease database.
221
222 -T Ask for IPv6 temporary addresses, one set per -T flag. This
223 implies -6 and also disables the normal address query. See -N
224 to restore it.
225
226 -P Enable IPv6 prefix delegation. This implies -6 and also dis‐
227 ables the normal address query. See -N to restore it. Multiple
228 prefixes can be requested with multiple -P flags. Note only one
229 requested interface is allowed.
230
231 -R Require that responses include all of the items requested by any
232 -N, -T, or -P options. Normally even if the command line
233 includes a number of these the client will be willing to accept
234 the best lease it can even if the lease doesn't include all of
235 the requested items. This option causes the client to only
236 accept leases that include all of the requested items.
237
238 Note well: enabling this may prevent the client from using any
239 leases it receives if the servers aren't configured to supply
240 all of the items.
241
242 -D LL or LLT
243 Override the default when selecting the type of DUID to use. By
244 default, DHCPv6 dhclient creates an identifier based on the
245 link-layer address (DUID-LL) if it is running in stateless mode
246 (with -S, not requesting an address), or it creates an identi‐
247 fier based on the link-layer address plus a timestamp (DUID-LLT)
248 if it is running in stateful mode (without -S, requesting an
249 address). When DHCPv4 is configured to use a DUID using -i
250 option the default is to use a DUID-LLT. -D overrides these
251 default, with a value of either LL or LLT.
252
253 -N Restore normal address query for IPv6. This implies -6. It is
254 used to restore normal operation after using -T or -P. Multiple
255 addresses can be requested with multiple -N flags.
256
257 --dad-wait-time seconds
258 Specify maximum time (in seconds) that the client should wait
259 for the duplicate address detection (DAD) to complete on an
260 interface. This value is propagated to the dhclient script in a
261 dad_wait_time environment variable. If any of the IPv6 addresses
262 on the interface are tentative (DAD is in progress), the script
263 will wait for the specified number of seconds for DAD to com‐
264 plete. If the script ignores this variable the parameter has no
265 effect.
266
267 Modifying default file locations: The following options can be used to
268 modify the locations a client uses for its files. They can be particu‐
269 larly useful if, for example, /var/lib/dhclient or /var/run have not
270 been mounted when the DHCP client is started.
271
272 -cf config-file
273 Path to the client configuration file. If unspecified, the
274 default /etc/dhcp/dhclient.conf is used. See dhclient.conf(5)
275 for a description of this file.
276
277 -df duid-lease-file
278 Path to a secondary lease file. If the primary lease file
279 doesn't contain a DUID this file will be searched. The DUID
280 read from the secondary will be written to the primary. This
281 option can be used to allow an IPv4 instance of the client to
282 share a DUID with an IPv6 instance. After starting one of the
283 instances the second can be started with this option pointing to
284 the lease file of the first instance. There is no default. If
285 no file is specified no search is made for a DUID should one not
286 be found in the main lease file.
287
288 -lf lease-file
289 Path to the lease database file. If unspecified, the default
290 /var/lib/dhclient/dhclient.leases is used. See
291 dhclient.leases(5) for a description of this file.
292
293 -pf pid-file
294 Path to the process ID file. If unspecified, the default
295 /var/run/dhclient.pid is used.
296
297 --no-pid
298 Option to disable writing pid files. By default the program
299 will write a pid file. If the program is invoked with this
300 option it will not attempt to kill any existing client processes
301 even if invoked with -r or -x.
302
303 -sf script-file
304 Path to the network configuration script invoked by dhclient
305 when it gets a lease. If unspecified, the default
306 /usr/sbin/dhclient-script is used. See dhclient-script(8) for a
307 description of this file.
308
310 During operations the client may use multiple UDP ports to provide dif‐
311 ferent functions. Which ports are opened depends on both the way you
312 compiled your code and the configuration you supply. The following
313 should provide you an idea of what ports may be in use.
314
315 Normally a DHCPv4 client will open a raw UDP socket to receive and send
316 most DHCPv4 packets. It also opens a fallback UDP socket for use in
317 sending unicast packets. Normally these will both use the well known
318 port number for BOOTPC.
319
320 For DHCPv6 the client opens a UDP socket on the well known client port
321 and a fallback UDP socket on a random port for use in sending unicast
322 messages. Unlike DHCPv4 the well known socket doesn't need to be
323 opened in raw mode.
324
325 If you have included an omapi port statement in your configuration file
326 then the client will open a TCP socket on that port to listen for OMPAI
327 connections. When something connects another port will be used for the
328 established connection.
329
330 When DDNS is enabled at compile time (see includes/site.h) the client
331 will open both a v4 and a v6 UDP socket on random ports. These ports
332 are not opened unless/until the client first attempts to do an update.
333 If the client is not configured to do updates, the ports will never be
334 opened.
335
337 The syntax of the dhclient.conf(5) file is discussed separately.
338
340 The DHCP client provides some ability to control it while it is run‐
341 ning, without stopping it. This capability is provided using OMAPI, an
342 API for manipulating remote objects. OMAPI clients connect to the
343 client using TCP/IP, authenticate, and can then examine the client's
344 current status and make changes to it.
345
346 Rather than implementing the underlying OMAPI protocol directly, user
347 programs should use the dhcpctl API or OMAPI itself. Dhcpctl is a
348 wrapper that handles some of the housekeeping chores that OMAPI does
349 not do automatically. Dhcpctl and OMAPI are documented in dhcpctl(3)
350 and omapi(3). Most things you'd want to do with the client can be done
351 directly using the omshell(1) command, rather than having to write a
352 special program.
353
355 The control object allows you to shut the client down, releasing all
356 leases that it holds and deleting any DNS records it may have added.
357 It also allows you to pause the client - this unconfigures any inter‐
358 faces the client is using. You can then restart it, which causes it to
359 reconfigure those interfaces. You would normally pause the client
360 prior to going into hibernation or sleep on a laptop computer. You
361 would then resume it after the power comes back. This allows PC cards
362 to be shut down while the computer is hibernating or sleeping, and then
363 reinitialized to their previous state once the computer comes out of
364 hibernation or sleep.
365
366 The control object has one attribute - the state attribute. To shut
367 the client down, set its state attribute to 2. It will automatically
368 do a DHCPRELEASE. To pause it, set its state attribute to 3. To
369 resume it, set its state attribute to 4.
370
372 The following environment variables may be defined to override the
373 builtin defaults for file locations. Note that use of the related com‐
374 mand-line options will ignore the corresponding environment variable
375 settings.
376
377 PATH_DHCLIENT_CONF
378 The dhclient.conf configuration file.
379
380 PATH_DHCLIENT_DB
381 The dhclient.leases database.
382
383 PATH_DHCLIENT_PID
384 The dhclient PID file.
385
386 PATH_DHCLIENT_SCRIPT
387 The dhclient-script file.
388
390 /usr/sbin/dhclient-script, /etc/dhcp/dhclient.conf,
391 /var/lib/dhclient/dhclient.leases, /var/run/dhclient.pid,
392 /var/lib/dhclient/dhclient.leases~.
393
395 dhcpd(8), dhcrelay(8), dhclient-script(8), dhclient.conf(5),
396 dhclient.leases(5), dhcp-eval(5).
397
399 dhclient(8) To learn more about Internet Systems Consortium, see
400 https://www.isc.org
401
402 This client was substantially modified and enhanced by Elliot Poger for
403 use on Linux while he was working on the MosquitoNet project at Stan‐
404 ford.
405
406 The current version owes much to Elliot's Linux enhancements, but was
407 substantially reorganized and partially rewritten by Ted Lemon so as to
408 use the same networking framework that the Internet Systems Consortium
409 DHCP server uses. Much system-specific configuration code was moved
410 into a shell script so that as support for more operating systems is
411 added, it will not be necessary to port and maintain system-specific
412 configuration code to these operating systems - instead, the shell
413 script can invoke the native tools to accomplish the same purpose.
414
415 dhclient(8)