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