Upgrade isc-dhcp, e.g. dhclient.
[dragonfly.git] / contrib / isc-dhcp / client / dhclient-script.8
1 .\"     dhclient-script.8
2 .\"
3 .\" Copyright (c) 1996-2002 Internet Software Consortium.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\"
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\" 3. Neither the name of The Internet Software Consortium nor the names
14 .\"    of its contributors may be used to endorse or promote products derived
15 .\"    from this software without specific prior written permission.
16 .\"
17 .\" THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
18 .\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19 .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 .\" DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
22 .\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25 .\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 .\" SUCH DAMAGE.
30 .\"
31 .\" This software has been written for the Internet Software Consortium
32 .\" by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
33 .\" To learn more about the Internet Software Consortium, see
34 .\" ``http://www.isc.org/''.  To learn more about Vixie Enterprises,
35 .\" see ``http://www.vix.com''.   To learn more about Nominum, Inc., see
36 .\" ``http://www.nominum.com''.
37 .\"
38 .\" $Id: dhclient-script.8,v 1.8.2.4 2002/11/17 02:25:43 dhankins Exp $
39 .\" $FreeBSD: src/contrib/isc-dhcp/client/dhclient-script.8,v 1.10 2003/01/16 07:23:57 obrien Exp $
40 .\" $DragonFly: src/contrib/isc-dhcp/client/Attic/dhclient-script.8,v 1.3 2003/10/11 21:14:12 dillon Exp $
41 .\"
42 .TH dhclient-script 8
43 .SH NAME
44 dhclient-script - DHCP client network configuration script
45 .SH DESCRIPTION
46 The DHCP client network configuration script is invoked from time to
47 time by \fBdhclient(8)\fR.  This script is used by the dhcp client to
48 set each interface's initial configuration prior to requesting an
49 address, to test the address once it has been offered, and to set the
50 interface's final configuration once a lease has been acquired.  If no
51 lease is acquired, the script is used to test predefined leases, if
52 any, and also called once if no valid lease can be identified.
53 .PP
54 This script is not meant to be customized by the end user.  If local
55 customizations are needed, they should be possible using the enter and
56 exit hooks provided (see HOOKS for details).   These hooks will allow the
57 user to override the default behaviour of the client in creating a
58 .B /etc/resolv.conf
59 file.
60 .PP
61 No standard client script exists for some operating systems, even though
62 the actual client may work, so a pioneering user may well need to create
63 a new script or modify an existing one.  In general, customizations specific
64 to a particular computer should be done in the
65 .B ETCDIR/dhclient.conf
66 file.   If you find that you can't make such a customization without
67 customizing
68 .B ETCDIR/dhclient.conf
69 or using the enter and exit hooks, please submit a bug report.
70 .SH HOOKS
71 When it starts, the client script first defines a shell function,
72 .B make_resolv_conf ,
73 which is later used to create the
74 .B /etc/resolv.conf
75 file.   To override the default behaviour, redefine this function in
76 the enter hook script.
77 .PP
78 On after defining the make_resolv_conf function, the client script checks
79 for the presence of an executable
80 .B ETCDIR/dhclient-enter-hooks
81 script, and if present, it invokes the script inline, using the Bourne
82 shell '.' command.   The entire environment documented under OPERATION
83 is available to this script, which may modify the environment if needed
84 to change the behaviour of the script.   If an error occurs during the
85 execution of the script, it can set the exit_status variable to a nonzero
86 value, and
87 .B CLIENTBINDIR/dhclient-script
88 will exit with that error code immediately after the client script exits.
89 .PP
90 After all processing has completed,
91 .B CLIENTBINDIR/dhclient-script
92 checks for the presence of an executable
93 .B ETCDIR/dhclient-exit-hooks
94 script, which if present is invoked using the '.' command.  The exit
95 status of dhclient-script will be passed to dhclient-exit-hooks in the
96 exit_status shell variable, and will always be zero if the script
97 succeeded at the task for which it was invoked.   The rest of the
98 environment as described previously for dhclient-enter-hooks is also
99 present.   The
100 .B ETCDIR/dhclient-exit-hooks
101 script can modify the valid of exit_status to change the exit status
102 of dhclient-script.
103 .SH OPERATION
104 When dhclient needs to invoke the client configuration script, it
105 defines a set of variables in the environment, and then invokes
106 .B CLIENTBINDIR/dhclient-script.
107 In all cases, $reason is set to the name of the reason why the script
108 has been invoked.   The following reasons are currently defined:
109 MEDIUM, PREINIT, BOUND, RENEW, REBIND, REBOOT, EXPIRE, FAIL and TIMEOUT.
110 .PP
111 .SH MEDIUM
112 The DHCP client is requesting that an interface's media type
113 be set.  The interface name is passed in $interface, and the media
114 type is passed in $medium.
115 .SH PREINIT
116 The DHCP client is requesting that an interface be configured as
117 required in order to send packets prior to receiving an actual
118 address.   For clients which use the BSD socket library, this means
119 configuring the interface with an IP address of 0.0.0.0 and a
120 broadcast address of 255.255.255.255.   For other clients, it may be
121 possible to simply configure the interface up without actually giving
122 it an IP address at all.   The interface name is passed in $interface,
123 and the media type in $medium.
124 .PP
125 If an IP alias has been declared in dhclient.conf, its address will be
126 passed in $alias_ip_address, and that ip alias should be deleted from
127 the interface, along with any routes to it.
128 .SH BOUND
129 The DHCP client has done an initial binding to a new address.   The
130 new ip address is passed in $new_ip_address, and the interface name is
131 passed in $interface.   The media type is passed in $medium.   Any
132 options acquired from the server are passed using the option name
133 described in \fBdhcp-options\fR, except that dashes ('-') are replaced
134 by underscores ('_') in order to make valid shell variables, and the
135 variable names start with new_.   So for example, the new subnet mask
136 would be passed in $new_subnet_mask.
137 .PP
138 Before actually configuring the address, dhclient-script should
139 somehow ARP for it and exit with a nonzero status if it receives a
140 reply.   In this case, the client will send a DHCPDECLINE message to
141 the server and acquire a different address.   This may also be done in
142 the RENEW, REBIND, or REBOOT states, but is not required, and indeed
143 may not be desirable.
144 .PP
145 When a binding has been completed, a lot of network parameters are
146 likely to need to be set up.   A new /etc/resolv.conf needs to be
147 created, using the values of $new_domain_name and
148 $new_domain_name_servers (which may list more than one server,
149 separated by spaces).   A default route should be set using
150 $new_routers, and static routes may need to be set up using
151 $new_static_routes.
152 .PP
153 If an IP alias has been declared, it must be set up here.   The alias
154 IP address will be written as $alias_ip_address, and other DHCP
155 options that are set for the alias (e.g., subnet mask) will be passed
156 in variables named as described previously except starting with
157 $alias_ instead of $new_.   Care should be taken that the alias IP
158 address not be used if it is identical to the bound IP address
159 ($new_ip_address), since the other alias parameters may be incorrect
160 in this case.
161 .SH RENEW
162 When a binding has been renewed, the script is called as in BOUND,
163 except that in addition to all the variables starting with $new_,
164 there is another set of variables starting with $old_.  Persistent
165 settings that may have changed need to be deleted - for example, if a
166 local route to the bound address is being configured, the old local
167 route should be deleted.  If the default route has changed, the old default
168 route should be deleted.  If the static routes have changed, the old
169 ones should be deleted.  Otherwise, processing can be done as with
170 BOUND.
171 .SH REBIND
172 The DHCP client has rebound to a new DHCP server.  This can be handled
173 as with RENEW, except that if the IP address has changed, the ARP
174 table should be cleared.
175 .SH REBOOT
176 The DHCP client has successfully reacquired its old address after a
177 reboot.   This can be processed as with BOUND.
178 .SH EXPIRE
179 The DHCP client has failed to renew its lease or acquire a new one,
180 and the lease has expired.   The IP address must be relinquished, and
181 all related parameters should be deleted, as in RENEW and REBIND.
182 .SH FAIL
183 The DHCP client has been unable to contact any DHCP servers, and any
184 leases that have been tested have not proved to be valid.   The
185 parameters from the last lease tested should be deconfigured.   This
186 can be handled in the same way as EXPIRE.
187 .SH TIMEOUT
188 The DHCP client has been unable to contact any DHCP servers.
189 However, an old lease has been identified, and its parameters have
190 been passed in as with BOUND.   The client configuration script should
191 test these parameters and, if it has reason to believe they are valid,
192 should exit with a value of zero.   If not, it should exit with a
193 nonzero value.
194 .PP
195 The usual way to test a lease is to set up the network as with REBIND
196 (since this may be called to test more than one lease) and then ping
197 the first router defined in $routers.  If a response is received, the
198 lease must be valid for the network to which the interface is
199 currently connected.   It would be more complete to try to ping all of
200 the routers listed in $new_routers, as well as those listed in
201 $new_static_routes, but current scripts do not do this.
202 .SH FILES
203 Each operating system should generally have its own script file,
204 although the script files for similar operating systems may be similar
205 or even identical.   The script files included in the Internet
206 Software Consortium DHCP distribution appear in the distribution tree
207 under client/scripts, and bear the names of the operating systems on
208 which they are intended to work.
209 .SH BUGS
210 If more than one interface is being used, there's no obvious way to
211 avoid clashes between server-supplied configuration parameters - for
212 example, the stock dhclient-script rewrites /etc/resolv.conf.   If
213 more than one interface is being configured, /etc/resolv.conf will be
214 repeatedly initialized to the values provided by one server, and then
215 the other.   Assuming the information provided by both servers is
216 valid, this shouldn't cause any real problems, but it could be
217 confusing.
218 .SH SEE ALSO
219 dhclient.conf(5), dhclient.leases(5), dhclient(8).
220 .SH AUTHOR
221 .B dhclient-script(8)
222 has been written for the Internet Software Consortium
223 by Ted Lemon in cooperation with Vixie
224 Enterprises.  To learn more about the Internet Software Consortium,
225 see
226 .B http://www.isc.org.
227 To learn more about Vixie
228 Enterprises, see
229 .B http://www.vix.com.