1 .\" $OpenBSD: dhclient-script.8,v 1.5 2007/05/31 19:19:43 jmc Exp $
2 .\" $DragonFly: src/sbin/dhclient/dhclient-script.8,v 1.3 2008/09/01 10:48:29 swildner Exp $
4 .\" Copyright (c) 1997 The Internet Software Consortium.
5 .\" All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of The Internet Software Consortium nor the names
17 .\" of its contributors may be used to endorse or promote products derived
18 .\" from this software without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
21 .\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 .\" DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
25 .\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 .\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" This software has been written for the Internet Software Consortium
35 .\" by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
36 .\" Enterprises. To learn more about the Internet Software Consortium,
37 .\" see ``http://www.isc.org/isc''. To learn more about Vixie
38 .\" Enterprises, see ``http://www.vix.com''.
45 .Nd DHCP client network configuration script
47 The DHCP client network configuration script is invoked from time to
50 This script is used by the DHCP client to set each interface's initial
51 configuration prior to requesting an address, to test the address once it
52 has been offered, and to set the interface's final configuration once a
53 lease has been acquired.
54 If no lease is acquired, the script is used to test predefined leases, if
55 any, and also called once if no valid lease can be identified.
57 .\" No standard client script exists for some operating systems, even though
58 .\" the actual client may work, so a pioneering user may well need to create
59 .\" a new script or modify an existing one.
60 In general, customizations specific to a particular computer should be done
62 .Pa /etc/dhclient.conf
67 needs to invoke the client configuration script, it sets up a number of
68 environment variables and runs
72 is set to the name of the reason why the script has been invoked.
73 The following reasons are currently defined:
74 MEDIUM, PREINIT, ARPCHECK, ARPSEND, BOUND, RENEW, REBIND, REBOOT,
75 EXPIRE, FAIL and TIMEOUT.
76 .Bl -tag -width "ARPCHECK"
78 The DHCP client is requesting that an interface's media type be set.
79 The interface name is passed in
81 and the media type is passed in
84 The DHCP client is requesting that an interface be configured as
85 required in order to send packets prior to receiving an actual address.
86 .\" For clients which use the BSD socket library,
87 This means configuring the interface with an IP address of 0.0.0.0
88 and a broadcast address of 255.255.255.255.
89 .\" For other clients, it may be possible to simply configure the interface up
90 .\" without actually giving it an IP address at all.
91 The interface name is passed in
96 If an IP alias has been declared in
98 its address will be passed in
99 .Va $alias_ip_address ,
100 and that IP alias should be deleted from the interface,
101 along with any routes to it.
103 The DHCP client is requesting that an address that has been offered to
104 it be checked to see if somebody else is using it, by sending an ARP
105 request for that address.
106 It's not clear how to implement this, so no examples exist yet.
107 The IP address to check is passed in
108 .Va $new_ip_address ,
109 and the interface name is passed in
112 The DHCP client wants to know if a response to the ARP request sent
113 using ARPSEND has been received.
114 If one has, the script should exit with a nonzero status, indicating that
115 the offered address has already been requested and should be declined.
119 are set as with ARPSEND.
121 The DHCP client has done an initial binding to a new address.
122 The new IP address is passed in
123 .Va $new_ip_address ,
124 and the interface name is passed in
126 The media type is passed in
128 Any options acquired from the server are passed using the option name
133 are replaced by underscores
135 in order to make valid shell variables, and the variable names start with new_.
136 So for example, the new subnet mask would be passed in
137 .Va $new_subnet_mask .
139 When a binding has been completed, a lot of network parameters are
140 likely to need to be set up.
143 needs to be created, using the values of
146 .Va $new_domain_name_servers
147 (which may list more than one server, separated by spaces).
148 A default route should be set using
150 and static routes may need to be set up using
151 .Va $new_static_routes .
155 effectively overwrites
156 .Pa /etc/resolv.conf ,
157 any information contained therein is lost.
158 If options must be passed to the resolver,
159 they may be contained in
160 .Pa /etc/resolv.conf.tail ,
161 which is appended to the generated
166 .Xr resolv.conf.tail 5
167 for further information.
169 If an IP alias has been declared, it must be set up here.
170 The alias IP address will be written as
171 .Va $alias_ip_address ,
172 and other DHCP options that are set for the alias (e.g., subnet mask)
173 will be passed in variables named as described previously except starting with
174 $alias_ instead of $new_.
175 Care should be taken that the alias IP address not be used if it is identical
176 to the bound IP address
177 .Pq Va $new_ip_address ,
178 since the other alias parameters may be incorrect in this case.
180 When a binding has been renewed, the script is called as in BOUND,
181 except that in addition to all the variables starting with $new_,
182 there is another set of variables starting with $old_.
183 Persistent settings that may have changed need to be deleted \- for example,
184 if a local route to the bound address is being configured, the old local
185 route should be deleted.
186 If the default route has changed, the old default route should be deleted.
187 If the static routes have changed, the old ones should be deleted.
188 Otherwise, processing can be done as with BOUND.
190 The DHCP client has rebound to a new DHCP server.
191 This can be handled as with RENEW, except that if the IP address has changed,
192 the ARP table should be cleared.
194 The DHCP client has successfully reacquired its old address after a reboot.
195 This can be processed as with BOUND.
197 The DHCP client has failed to renew its lease or acquire a new one,
198 and the lease has expired.
199 The IP address must be relinquished, and all related parameters should be
200 deleted, as in RENEW and REBIND.
202 The DHCP client has been unable to contact any DHCP servers, and any
203 leases that have been tested have not proved to be valid.
204 The parameters from the last lease tested should be deconfigured.
205 This can be handled in the same way as EXPIRE.
207 The DHCP client has been unable to contact any DHCP servers.
208 However, an old lease has been identified, and its parameters have
209 been passed in as with BOUND.
210 The client configuration script should test these parameters and,
211 if it has reason to believe they are valid, should exit with a value of zero.
212 If not, it should exit with a nonzero value.
215 The usual way to test a lease is to set up the network as with REBIND
216 (since this may be called to test more than one lease) and then ping
217 the first router defined in
219 If a response is received, the lease must be valid for the network to
220 which the interface is currently connected.
221 It would be more complete to try to ping all of the routers listed in
223 as well as those listed in
224 .Va $new_static_routes ,
225 but current scripts do not do this.
227 .\" Each operating system should generally have its own script file,
228 .\" although the script files for similar operating systems may be similar
229 .\" or even identical.
230 .\" The script files included in the Internet Software Consortium DHCP
231 .\" distribution appear in the distribution tree under client/scripts,
232 .\" and bear the names of the operating systems on which they are intended
235 .Xr dhclient.conf 5 ,
236 .Xr dhclient.leases 5 ,
237 .Xr resolv.conf.tail 5 ,
239 .Xr dhcpd 8 Pq Pa pkgsrc/net/isc-dhcpd4 ,
240 .Xr dhcrelay 8 Pq Pa pkgsrc/net/isc-dhcrelay4
243 The original version of
245 was written for the Internet Software Consortium by
246 .An Ted Lemon Aq mellon@fugue.com
247 in cooperation with Vixie Enterprises.
254 .An Kenneth R. Westerback Aq krw@openbsd.org .
256 If more than one interface is being used, there's no obvious way to
257 avoid clashes between server-supplied configuration parameters \- for
258 example, the stock dhclient-script rewrites
259 .Pa /etc/resolv.conf .
260 If more than one interface is being configured,
262 will be repeatedly initialized to the values provided by one server, and then
264 Assuming the information provided by both servers is valid, this shouldn't
265 cause any real problems, but it could be confusing.