ssahani / rpms / dhcp

Forked from rpms/dhcp 5 years ago
Clone
dc724d5
.\"	dhclient-script.8
dc724d5
.\"
dc724d5
.\" Copyright (c) 2004-2005 by Internet Systems Consortium, Inc. ("ISC")
dc724d5
.\" Copyright (c) 1996-2003 by Internet Software Consortium
dc724d5
.\"
dc724d5
.\" Permission to use, copy, modify, and distribute this software for any
dc724d5
.\" purpose with or without fee is hereby granted, provided that the above
dc724d5
.\" copyright notice and this permission notice appear in all copies.
dc724d5
.\"
dc724d5
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
dc724d5
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
dc724d5
.\" MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
dc724d5
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
dc724d5
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
dc724d5
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
dc724d5
.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
dc724d5
.\"
dc724d5
.\"   Internet Systems Consortium, Inc.
dc724d5
.\"   950 Charter Street
dc724d5
.\"   Redwood City, CA 94063
dc724d5
.\"   <info@isc.org>
dc724d5
.\"   http://www.isc.org/
dc724d5
.\"
dc724d5
.\" This software has been written for Internet Systems Consortium
dc724d5
.\" by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
dc724d5
.\" To learn more about Internet Systems Consortium, see
dc724d5
.\" ``http://www.isc.org/''.  To learn more about Vixie Enterprises,
dc724d5
.\" see ``http://www.vix.com''.   To learn more about Nominum, Inc., see
dc724d5
.\" ``http://www.nominum.com''.
dc724d5
.\"
dc724d5
.\" $Id: dhclient-script.8,v 1.1 2007/11/12 23:16:08 dcantrel Exp $
dc724d5
.\"
dc724d5
.TH dhclient-script 8
dc724d5
.SH NAME
dc724d5
dhclient-script - DHCP client network configuration script
dc724d5
.SH DESCRIPTION
dc724d5
The DHCP client network configuration script is invoked from time to
dc724d5
time by \fBdhclient(8)\fR.  This script is used by the dhcp client to
dc724d5
set each interface's initial configuration prior to requesting an
dc724d5
address, to test the address once it has been offered, and to set the
dc724d5
interface's final configuration once a lease has been acquired.  If no
dc724d5
lease is acquired, the script is used to test predefined leases, if
dc724d5
any, and also called once if no valid lease can be identified.
dc724d5
.PP
dc724d5
This script is not meant to be customized by the end user.  If local
dc724d5
customizations are needed, they should be possible using the enter and
dc724d5
exit hooks provided (see HOOKS for details).   These hooks will allow the
dc724d5
user to override the default behaviour of the client in creating a
dc724d5
.B /etc/resolv.conf
dc724d5
file, and to handle DHCP options not handled by default.
dc724d5
.PP
dc724d5
No standard client script exists for some operating systems, even though
dc724d5
the actual client may work, so a pioneering user may well need to create
dc724d5
a new script or modify an existing one.  In general, customizations specific
dc724d5
to a particular computer should be done in the
dc724d5
.B ETCDIR/dhclient.conf
dc724d5
file.   If you find that you can't make such a customization without
dc724d5
customizing
dc724d5
.B ETCDIR/dhclient.conf
dc724d5
or using the enter and exit hooks, please submit a bug report.
dc724d5
.SH HOOKS
dc724d5
When it starts, the client script first defines a shell function,
dc724d5
.B make_resolv_conf ,
dc724d5
which is later used to create the
dc724d5
.B /etc/resolv.conf
dc724d5
file.   To override the default behaviour, redefine this function in
dc724d5
the enter hook script.
dc724d5
.PP
dc724d5
On after defining the make_resolv_conf function, the client script checks
dc724d5
for the presence of an executable
dc724d5
.B ETCDIR/dhclient-enter-hooks
dc724d5
script, and if present, it invokes the script inline, using the Bourne
dc724d5
shell '.' command.   The entire environment documented under OPERATION
dc724d5
is available to this script, which may modify the environment if needed
dc724d5
to change the behaviour of the script.   If an error occurs during the
dc724d5
execution of the script, it can set the exit_status variable to a nonzero
dc724d5
value, and
dc724d5
.B CLIENTBINDIR/dhclient-script
dc724d5
will exit with that error code immediately after the client script exits.
dc724d5
.PP
dc724d5
After all processing has completed,
dc724d5
.B CLIENTBINDIR/dhclient-script
dc724d5
checks for the presence of an executable
dc724d5
.B ETCDIR/dhclient-exit-hooks
dc724d5
script, which if present is invoked using the '.' command.  The exit
dc724d5
status of dhclient-script will be passed to dhclient-exit-hooks in the
dc724d5
exit_status shell variable, and will always be zero if the script
dc724d5
succeeded at the task for which it was invoked.   The rest of the
dc724d5
environment as described previously for dhclient-enter-hooks is also
dc724d5
present.   The
dc724d5
.B ETCDIR/dhclient-exit-hooks
dc724d5
script can modify the valid of exit_status to change the exit status
dc724d5
of dhclient-script.
dc724d5
.PP
dc724d5
Immediately after dhclient brings an interface UP with a new IP address,
dc724d5
subnet mask, and routes, in the REBOOT/BOUND states, it will check for the
dc724d5
existence of an executable
dc724d5
.B ETCDIR/dhclient-up-hooks
dc724d5
script, and source it if found. This script can handle DHCP options in
dc724d5
the environment that are not handled by default. A per-interface.
dc724d5
.B ETCDIR/dhclient-${IF}-up-hooks
dc724d5
script will override the generic script and be sourced when interface
dc724d5
$IF has been brought up.
dc724d5
.PP
dc724d5
Immediately before dhclient brings an interface DOWN, removing its IP
dc724d5
address, subnet mask, and routes, in the STOP/RELEASE  states, it will
dc724d5
check for the existence of an executable
dc724d5
.B ETCDIR/dhclient-down-hooks
dc724d5
script, and source it if found. This script can handle DHCP options in
dc724d5
the environment that are not handled by default. A per-interface
dc724d5
.B ETCDIR/dhclient-${IF}-down-hooks
dc724d5
script will override the generic script and be sourced when interface
dc724d5
$IF is about to be brought down.
dc724d5
dc724d5
.SH OPERATION
dc724d5
When dhclient needs to invoke the client configuration script, it
dc724d5
defines a set of variables in the environment, and then invokes
dc724d5
.B CLIENTBINDIR/dhclient-script.
dc724d5
In all cases, $reason is set to the name of the reason why the script
dc724d5
has been invoked.   The following reasons are currently defined:
dc724d5
MEDIUM, PREINIT, BOUND, RENEW, REBIND, REBOOT, EXPIRE, FAIL, STOP, RELEASE,
dc724d5
NBI and TIMEOUT.
dc724d5
.PP
dc724d5
.SH MEDIUM
dc724d5
The DHCP client is requesting that an interface's media type
dc724d5
be set.  The interface name is passed in $interface, and the media
dc724d5
type is passed in $medium.
dc724d5
.SH PREINIT
dc724d5
The DHCP client is requesting that an interface be configured as
dc724d5
required in order to send packets prior to receiving an actual
dc724d5
address.   For clients which use the BSD socket library, this means
dc724d5
configuring the interface with an IP address of 0.0.0.0 and a
dc724d5
broadcast address of 255.255.255.255.   For other clients, it may be
dc724d5
possible to simply configure the interface up without actually giving
dc724d5
it an IP address at all.   The interface name is passed in $interface,
dc724d5
and the media type in $medium.
dc724d5
.PP
dc724d5
If an IP alias has been declared in dhclient.conf, its address will be
dc724d5
passed in $alias_ip_address, and that ip alias should be deleted from
dc724d5
the interface, along with any routes to it.
dc724d5
.SH BOUND
dc724d5
The DHCP client has done an initial binding to a new address.   The
dc724d5
new ip address is passed in $new_ip_address, and the interface name is
dc724d5
passed in $interface.   The media type is passed in $medium.   Any
dc724d5
options acquired from the server are passed using the option name
dc724d5
described in \fBdhcp-options\fR, except that dashes ('-') are replaced
dc724d5
by underscores ('_') in order to make valid shell variables, and the
dc724d5
variable names start with new_.   So for example, the new subnet mask
dc724d5
would be passed in $new_subnet_mask.
dc724d5
.PP
dc724d5
Before actually configuring the address, dhclient-script should
dc724d5
somehow ARP for it and exit with a nonzero status if it receives a
dc724d5
reply.   In this case, the client will send a DHCPDECLINE message to
dc724d5
the server and acquire a different address.   This may also be done in
dc724d5
the RENEW, REBIND, or REBOOT states, but is not required, and indeed
dc724d5
may not be desirable.
dc724d5
.PP
dc724d5
When a binding has been completed, a lot of network parameters are
dc724d5
likely to need to be set up.   A new /etc/resolv.conf needs to be
dc724d5
created, using the values of $new_domain_name and
dc724d5
$new_domain_name_servers (which may list more than one server,
dc724d5
separated by spaces).   A default route should be set using
dc724d5
$new_routers, and static routes may need to be set up using
dc724d5
$new_static_routes.
dc724d5
.PP
dc724d5
If an IP alias has been declared, it must be set up here.   The alias
dc724d5
IP address will be written as $alias_ip_address, and other DHCP
dc724d5
options that are set for the alias (e.g., subnet mask) will be passed
dc724d5
in variables named as described previously except starting with
dc724d5
$alias_ instead of $new_.   Care should be taken that the alias IP
dc724d5
address not be used if it is identical to the bound IP address
dc724d5
($new_ip_address), since the other alias parameters may be incorrect
dc724d5
in this case.
dc724d5
.SH RENEW
dc724d5
When a binding has been renewed, the script is called as in BOUND,
dc724d5
except that in addition to all the variables starting with $new_,
dc724d5
there is another set of variables starting with $old_.  Persistent
dc724d5
settings that may have changed need to be deleted - for example, if a
dc724d5
local route to the bound address is being configured, the old local
dc724d5
route should be deleted.  If the default route has changed, the old default
dc724d5
route should be deleted.  If the static routes have changed, the old
dc724d5
ones should be deleted.  Otherwise, processing can be done as with
dc724d5
BOUND.
dc724d5
.SH REBIND
dc724d5
The DHCP client has rebound to a new DHCP server.  This can be handled
dc724d5
as with RENEW, except that if the IP address has changed, the ARP
dc724d5
table should be cleared.
dc724d5
.SH REBOOT
dc724d5
The DHCP client has successfully reacquired its old address after a
dc724d5
reboot.   This can be processed as with BOUND.
dc724d5
.SH EXPIRE
dc724d5
The DHCP client has failed to renew its lease or acquire a new one,
dc724d5
and the lease has expired.   The IP address must be relinquished, and
dc724d5
all related parameters should be deleted, as in RENEW and REBIND.
dc724d5
.SH FAIL
dc724d5
The DHCP client has been unable to contact any DHCP servers, and any
dc724d5
leases that have been tested have not proved to be valid.   The
dc724d5
parameters from the last lease tested should be deconfigured.   This
dc724d5
can be handled in the same way as EXPIRE.
dc724d5
.SH STOP
dc724d5
The dhclient has been informed to shut down gracefully, the
dc724d5
dhclient-script should unconfigure or shutdown the interface as
dc724d5
appropriate.
dc724d5
.SH RELEASE
dc724d5
The dhclient has been executed using the -r flag, indicating that the
dc724d5
administrator wishes it to release its lease(s).  dhclient-script should
dc724d5
unconfigure or shutdown the interface.
dc724d5
.SH NBI
dc724d5
No-Broadcast-Interfaces...dhclient was unable to find any interfaces
dc724d5
upon which it believed it should commence DHCP.  What dhclient-script
dc724d5
should do in this situation is entirely up to the implementor.
dc724d5
.SH TIMEOUT
dc724d5
The DHCP client has been unable to contact any DHCP servers.
dc724d5
However, an old lease has been identified, and its parameters have
dc724d5
been passed in as with BOUND.   The client configuration script should
dc724d5
test these parameters and, if it has reason to believe they are valid,
dc724d5
should exit with a value of zero.   If not, it should exit with a
dc724d5
nonzero value.
dc724d5
.PP
dc724d5
The usual way to test a lease is to set up the network as with REBIND
dc724d5
(since this may be called to test more than one lease) and then ping
dc724d5
the first router defined in $routers.  If a response is received, the
dc724d5
lease must be valid for the network to which the interface is
dc724d5
currently connected.   It would be more complete to try to ping all of
dc724d5
the routers listed in $new_routers, as well as those listed in
dc724d5
$new_static_routes, but current scripts do not do this.
dc724d5
.SH FILES
dc724d5
Each operating system should generally have its own script file,
dc724d5
although the script files for similar operating systems may be similar
dc724d5
or even identical.   The script files included in Internet
dc724d5
Systems Consortium DHCP distribution appear in the distribution tree
dc724d5
under client/scripts, and bear the names of the operating systems on
dc724d5
which they are intended to work.
dc724d5
.SH BUGS
dc724d5
If more than one interface is being used, there's no obvious way to
dc724d5
avoid clashes between server-supplied configuration parameters - for
dc724d5
example, the stock dhclient-script rewrites /etc/resolv.conf.   If
dc724d5
more than one interface is being configured, /etc/resolv.conf will be
dc724d5
repeatedly initialized to the values provided by one server, and then
dc724d5
the other.   Assuming the information provided by both servers is
dc724d5
valid, this shouldn't cause any real problems, but it could be
dc724d5
confusing.
dc724d5
.SH SEE ALSO
dc724d5
dhclient(8), dhcpd(8), dhcrelay(8), dhclient.conf(5) and
dc724d5
dhclient.leases(5).
dc724d5
.SH AUTHOR
dc724d5
.B dhclient-script(8)
dc724d5
has been written for Internet Systems Consortium
dc724d5
by Ted Lemon in cooperation with Vixie
dc724d5
Enterprises.  To learn more about Internet Systems Consortium,
dc724d5
see
dc724d5
.B http://www.isc.org.
dc724d5
To learn more about Vixie
dc724d5
Enterprises, see
dc724d5
.B http://www.vix.com.