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