Initial import from FreeBSD RELENG_4:
[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.5.2.5 2003/03/02 16:42:37 murray Exp $
40 .\"
41 .TH dhclient-script 8
42 .SH NAME
43 dhclient-script - DHCP client network configuration script
44 .SH DESCRIPTION
45 The DHCP client network configuration script is invoked from time to
46 time by \fBdhclient(8)\fR.  This script is used by the dhcp client to
47 set each interface's initial configuration prior to requesting an
48 address, to test the address once it has been offered, and to set the
49 interface's final configuration once a lease has been acquired.  If no
50 lease is acquired, the script is used to test predefined leases, if
51 any, and also called once if no valid lease can be identified.
52 .PP
53 This script is not meant to be customized by the end user.  If local
54 customizations are needed, they should be possible using the enter and
55 exit hooks provided (see HOOKS for details).   These hooks will allow the
56 user to override the default behaviour of the client in creating a
57 .B /etc/resolv.conf
58 file.
59 .PP
60 No standard client script exists for some operating systems, even though
61 the actual client may work, so a pioneering user may well need to create
62 a new script or modify an existing one.  In general, customizations specific
63 to a particular computer should be done in the
64 .B ETCDIR/dhclient.conf
65 file.   If you find that you can't make such a customization without
66 customizing
67 .B ETCDIR/dhclient.conf
68 or using the enter and exit hooks, please submit a bug report.
69 .SH HOOKS
70 When it starts, the client script first defines a shell function,
71 .B make_resolv_conf ,
72 which is later used to create the
73 .B /etc/resolv.conf
74 file.   To override the default behaviour, redefine this function in
75 the enter hook script.
76 .PP
77 On after defining the make_resolv_conf function, the client script checks
78 for the presence of an executable
79 .B ETCDIR/dhclient-enter-hooks
80 script, and if present, it invokes the script inline, using the Bourne
81 shell '.' command.   The entire environment documented under OPERATION
82 is available to this script, which may modify the environment if needed
83 to change the behaviour of the script.   If an error occurs during the
84 execution of the script, it can set the exit_status variable to a nonzero
85 value, and
86 .B CLIENTBINDIR/dhclient-script
87 will exit with that error code immediately after the client script exits.
88 .PP
89 After all processing has completed,
90 .B CLIENTBINDIR/dhclient-script
91 checks for the presence of an executable
92 .B ETCDIR/dhclient-exit-hooks
93 script, which if present is invoked using the '.' command.  The exit
94 status of dhclient-script will be passed to dhclient-exit-hooks in the
95 exit_status shell variable, and will always be zero if the script
96 succeeded at the task for which it was invoked.   The rest of the
97 environment as described previously for dhclient-enter-hooks is also
98 present.   The
99 .B ETCDIR/dhclient-exit-hooks
100 script can modify the valid of exit_status to change the exit status
101 of dhclient-script.
102 .SH OPERATION
103 When dhclient needs to invoke the client configuration script, it
104 defines a set of variables in the environment, and then invokes
105 .B CLIENTBINDIR/dhclient-script.
106 In all cases, $reason is set to the name of the reason why the script
107 has been invoked.   The following reasons are currently defined:
108 MEDIUM, PREINIT, BOUND, RENEW, REBIND, REBOOT, EXPIRE, FAIL and TIMEOUT.
109 .PP
110 .SH MEDIUM
111 The DHCP client is requesting that an interface's media type
112 be set.  The interface name is passed in $interface, and the media
113 type is passed in $medium.
114 .SH PREINIT
115 The DHCP client is requesting that an interface be configured as
116 required in order to send packets prior to receiving an actual
117 address.   For clients which use the BSD socket library, this means
118 configuring the interface with an IP address of 0.0.0.0 and a
119 broadcast address of 255.255.255.255.   For other clients, it may be
120 possible to simply configure the interface up without actually giving
121 it an IP address at all.   The interface name is passed in $interface,
122 and the media type in $medium.
123 .PP
124 If an IP alias has been declared in dhclient.conf, its address will be
125 passed in $alias_ip_address, and that ip alias should be deleted from
126 the interface, along with any routes to it.
127 .SH BOUND
128 The DHCP client has done an initial binding to a new address.   The
129 new ip address is passed in $new_ip_address, and the interface name is
130 passed in $interface.   The media type is passed in $medium.   Any
131 options acquired from the server are passed using the option name
132 described in \fBdhcp-options\fR, except that dashes ('-') are replaced
133 by underscores ('_') in order to make valid shell variables, and the
134 variable names start with new_.   So for example, the new subnet mask
135 would be passed in $new_subnet_mask.
136 .PP
137 Before actually configuring the address, dhclient-script should
138 somehow ARP for it and exit with a nonzero status if it receives a
139 reply.   In this case, the client will send a DHCPDECLINE message to
140 the server and acquire a different address.   This may also be done in
141 the RENEW, REBIND, or REBOOT states, but is not required, and indeed
142 may not be desirable.
143 .PP
144 When a binding has been completed, a lot of network parameters are
145 likely to need to be set up.   A new /etc/resolv.conf needs to be
146 created, using the values of $new_domain_name and
147 $new_domain_name_servers (which may list more than one server,
148 separated by spaces).   A default route should be set using
149 $new_routers, and static routes may need to be set up using
150 $new_static_routes.
151 .PP
152 If an IP alias has been declared, it must be set up here.   The alias
153 IP address will be written as $alias_ip_address, and other DHCP
154 options that are set for the alias (e.g., subnet mask) will be passed
155 in variables named as described previously except starting with
156 $alias_ instead of $new_.   Care should be taken that the alias IP
157 address not be used if it is identical to the bound IP address
158 ($new_ip_address), since the other alias parameters may be incorrect
159 in this case.
160 .SH RENEW
161 When a binding has been renewed, the script is called as in BOUND,
162 except that in addition to all the variables starting with $new_,
163 there is another set of variables starting with $old_.  Persistent
164 settings that may have changed need to be deleted - for example, if a
165 local route to the bound address is being configured, the old local
166 route should be deleted.  If the default route has changed, the old default
167 route should be deleted.  If the static routes have changed, the old
168 ones should be deleted.  Otherwise, processing can be done as with
169 BOUND.
170 .SH REBIND
171 The DHCP client has rebound to a new DHCP server.  This can be handled
172 as with RENEW, except that if the IP address has changed, the ARP
173 table should be cleared.
174 .SH REBOOT
175 The DHCP client has successfully reacquired its old address after a
176 reboot.   This can be processed as with BOUND.
177 .SH EXPIRE
178 The DHCP client has failed to renew its lease or acquire a new one,
179 and the lease has expired.   The IP address must be relinquished, and
180 all related parameters should be deleted, as in RENEW and REBIND.
181 .SH FAIL
182 The DHCP client has been unable to contact any DHCP servers, and any
183 leases that have been tested have not proved to be valid.   The
184 parameters from the last lease tested should be deconfigured.   This
185 can be handled in the same way as EXPIRE.
186 .SH TIMEOUT
187 The DHCP client has been unable to contact any DHCP servers.
188 However, an old lease has been identified, and its parameters have
189 been passed in as with BOUND.   The client configuration script should
190 test these parameters and, if it has reason to believe they are valid,
191 should exit with a value of zero.   If not, it should exit with a
192 nonzero value.
193 .PP
194 The usual way to test a lease is to set up the network as with REBIND
195 (since this may be called to test more than one lease) and then ping
196 the first router defined in $routers.  If a response is received, the
197 lease must be valid for the network to which the interface is
198 currently connected.   It would be more complete to try to ping all of
199 the routers listed in $new_routers, as well as those listed in
200 $new_static_routes, but current scripts do not do this.
201 .SH FILES
202 Each operating system should generally have its own script file,
203 although the script files for similar operating systems may be similar
204 or even identical.   The script files included in the Internet
205 Software Consortium DHCP distribution appear in the distribution tree
206 under client/scripts, and bear the names of the operating systems on
207 which they are intended to work.
208 .SH BUGS
209 If more than one interface is being used, there's no obvious way to
210 avoid clashes between server-supplied configuration parameters - for
211 example, the stock dhclient-script rewrites /etc/resolv.conf.   If
212 more than one interface is being configured, /etc/resolv.conf will be
213 repeatedly initialized to the values provided by one server, and then
214 the other.   Assuming the information provided by both servers is
215 valid, this shouldn't cause any real problems, but it could be
216 confusing.
217 .SH SEE ALSO
218 dhclient.conf(5), dhclient.leases(5), dhclient(8).
219 .SH AUTHOR
220 .B dhclient-script(8)
221 has been written for the Internet Software Consortium
222 by Ted Lemon in cooperation with Vixie
223 Enterprises.  To learn more about the Internet Software Consortium,
224 see
225 .B http://www.isc.org.
226 To learn more about Vixie
227 Enterprises, see
228 .B http://www.vix.com.