318 lines
13 KiB
HTML
318 lines
13 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of dhclient-script</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>dhclient-script</H1>
|
|
Section: Maintenance Commands (8)<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
dhclient-script - DHCP client network configuration script
|
|
<A NAME="lbAC"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The DHCP client network configuration script is invoked from time to
|
|
time by <B><A HREF="/cgi-bin/man/man2html?8+dhclient">dhclient</A>(8)</B>. This script is used by the dhcp client to
|
|
set each interface's initial configuration prior to requesting an
|
|
address, to test the address once it has been offered, and to set the
|
|
interface's final configuration once a lease has been acquired. If no
|
|
lease is acquired, the script is used to test predefined leases, if
|
|
any, and also called once if no valid lease can be identified.
|
|
<P>
|
|
|
|
This script is not meant to be customized by the end user. If local
|
|
customizations are needed, they should be possible using the enter and
|
|
exit hooks provided (see HOOKS for details). These hooks will allow the
|
|
user to override the default behaviour of the client in creating a
|
|
<B>/etc/resolv.conf</B>
|
|
|
|
file.
|
|
<P>
|
|
|
|
No standard client script exists for some operating systems, even though
|
|
the actual client may work, so a pioneering user may well need to create
|
|
a new script or modify an existing one. In general, customizations specific
|
|
to a particular computer should be done in the
|
|
<B>/etc/dhcp/dhclient.conf</B>
|
|
|
|
file. If you find that you can't make such a customization without
|
|
customizing
|
|
<B>/etc/dhcp/dhclient.conf</B>
|
|
|
|
or using the enter and exit hooks, please submit a bug report.
|
|
<A NAME="lbAD"> </A>
|
|
<H2>HOOKS</H2>
|
|
|
|
When it starts, the client script first defines a shell function,
|
|
<B>make_resolv_conf ,</B>
|
|
|
|
which is later used to create the
|
|
<B>/etc/resolv.conf</B>
|
|
|
|
file. To override the default behaviour, redefine this function in
|
|
the enter hook script.
|
|
<P>
|
|
|
|
After defining the make_resolv_conf function, the client script checks
|
|
for the presence of an executable
|
|
<B>/etc/dhcp/dhclient-enter-hooks</B>
|
|
|
|
script, and if present, it invokes the script inline, using the Bourne
|
|
shell '.' command. It also invokes all executable scripts in
|
|
<B>/etc/dhcp/dhclient-enter-hooks.d/*</B>
|
|
|
|
in the same way. The entire environment documented under OPERATION is
|
|
available to this script, which may modify the environment if needed to
|
|
change the behaviour of the script. If an error occurs during the
|
|
execution of the script, it can set the exit_status variable to a nonzero
|
|
value, and
|
|
<B>/sbin/dhclient-script</B>
|
|
|
|
will exit with that error code immediately after the client script exits.
|
|
<P>
|
|
|
|
After all processing has completed,
|
|
<B>/sbin/dhclient-script</B>
|
|
|
|
checks for the presence of an executable
|
|
<B>/etc/dhcp/dhclient-exit-hooks</B>
|
|
|
|
script, which if present is invoked using the '.' command. All executable
|
|
scripts in
|
|
<B>/etc/dhcp/dhclient-exit-hooks.d/*</B>
|
|
|
|
are also invoked. The exit status of dhclient-script will be passed
|
|
to dhclient-exit-hooks in the exit_status shell variable, and will
|
|
always be zero if the script succeeded at the task for which it was
|
|
invoked. The rest of the environment as described previously for
|
|
dhclient-enter-hooks is also present. The
|
|
<B>/etc/dhcp/dhclient-exit-hooks</B>
|
|
|
|
and
|
|
<B>/etc/dhcp/dhclient-exit-hooks.d/*</B>
|
|
|
|
scripts can modify the value of exit_status to change the exit status
|
|
of dhclient-script.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPERATION</H2>
|
|
|
|
When dhclient needs to invoke the client configuration script, it
|
|
defines a set of variables in the environment, and then invokes
|
|
<B>/sbin/dhclient-script.</B>
|
|
|
|
In all cases, $reason is set to the name of the reason why the script
|
|
has been invoked. The following reasons are currently defined:
|
|
MEDIUM, PREINIT, BOUND, RENEW, REBIND, REBOOT, EXPIRE, FAIL, STOP, RELEASE,
|
|
NBI and TIMEOUT.
|
|
<P>
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>MEDIUM</H2>
|
|
|
|
The DHCP client is requesting that an interface's media type
|
|
be set. The interface name is passed in $interface, and the media
|
|
type is passed in $medium.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>PREINIT</H2>
|
|
|
|
The DHCP client is requesting that an interface be configured as
|
|
required in order to send packets prior to receiving an actual
|
|
address. For clients which use the BSD socket library, this means
|
|
configuring the interface with an IP address of 0.0.0.0 and a
|
|
broadcast address of 255.255.255.255. For other clients, it may be
|
|
possible to simply configure the interface up without actually giving
|
|
it an IP address at all. The interface name is passed in $interface,
|
|
and the media type in $medium.
|
|
<P>
|
|
|
|
If an IP alias has been declared in dhclient.conf, its address will be
|
|
passed in $alias_ip_address, and that ip alias should be deleted from
|
|
the interface, along with any routes to it.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>BOUND</H2>
|
|
|
|
The DHCP client has done an initial binding to a new address. The
|
|
new ip address is passed in $new_ip_address, and the interface name is
|
|
passed in $interface. The media type is passed in $medium. Any
|
|
options acquired from the server are passed using the option name
|
|
described in <B>dhcp-options</B>, except that dashes ('-') are replaced
|
|
by underscores ('_') in order to make valid shell variables, and the
|
|
variable names start with new_. So for example, the new subnet mask
|
|
would be passed in $new_subnet_mask. Options from a non-default
|
|
universe will have the universe name prepended to the option name, for
|
|
example $new_dhcp6_server_id. The options that the client
|
|
explicitly requested via a PRL or ORO option are passed with the same
|
|
option name as above but prepended with requested_ and with a value of 1,
|
|
for example requested_subnet_mask=1. No such variable is defined for
|
|
options not requested by the client or options that don't require a
|
|
request option, such as the ip address (*_ip_address) or expiration
|
|
time (*_expiry).
|
|
<P>
|
|
|
|
Before actually configuring the address, dhclient-script should
|
|
somehow ARP for it and exit with a nonzero status if it receives a
|
|
reply. In this case, the client will send a DHCPDECLINE message to
|
|
the server and acquire a different address. This may also be done in
|
|
the RENEW, REBIND, or REBOOT states, but is not required, and indeed
|
|
may not be desirable.
|
|
<P>
|
|
|
|
When a binding has been completed, a lot of network parameters are
|
|
likely to need to be set up. A new /etc/resolv.conf needs to be
|
|
created, using the values of $new_domain_name and
|
|
$new_domain_name_servers (which may list more than one server,
|
|
separated by spaces). A default route should be set using
|
|
$new_routers, and static routes may need to be set up using
|
|
$new_static_routes.
|
|
<P>
|
|
|
|
If an IP alias has been declared, it must be set up here. The alias
|
|
IP address will be written as $alias_ip_address, and other DHCP
|
|
options that are set for the alias (e.g., subnet mask) will be passed
|
|
in variables named as described previously except starting with
|
|
$alias_ instead of $new_. Care should be taken that the alias IP
|
|
address not be used if it is identical to the bound IP address
|
|
($new_ip_address), since the other alias parameters may be incorrect
|
|
in this case.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>RENEW</H2>
|
|
|
|
When a binding has been renewed, the script is called as in BOUND,
|
|
except that in addition to all the variables starting with $new_, and
|
|
$requested_ there is another set of variables starting with $old_.
|
|
Persistent settings that may have changed need to be deleted - for
|
|
example, if a local route to the bound address is being configured,
|
|
the old local route should be deleted. If the default route has changed,
|
|
the old default route should be deleted. If the static routes have changed,
|
|
the old ones should be deleted. Otherwise, processing can be done as with
|
|
BOUND.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>REBIND</H2>
|
|
|
|
The DHCP client has rebound to a new DHCP server. This can be handled
|
|
as with RENEW, except that if the IP address has changed, the ARP
|
|
table should be cleared.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>REBOOT</H2>
|
|
|
|
The DHCP client has successfully reacquired its old address after a
|
|
reboot. This can be processed as with BOUND.
|
|
<A NAME="lbAL"> </A>
|
|
<H2>EXPIRE</H2>
|
|
|
|
The DHCP client has failed to renew its lease or acquire a new one,
|
|
and the lease has expired. The IP address must be relinquished, and
|
|
all related parameters should be deleted, as in RENEW and REBIND.
|
|
<A NAME="lbAM"> </A>
|
|
<H2>FAIL</H2>
|
|
|
|
The DHCP client has been unable to contact any DHCP servers, and any
|
|
leases that have been tested have not proved to be valid. The
|
|
parameters from the last lease tested should be deconfigured. This
|
|
can be handled in the same way as EXPIRE.
|
|
<A NAME="lbAN"> </A>
|
|
<H2>STOP</H2>
|
|
|
|
The dhclient has been informed to shut down gracefully, the
|
|
dhclient-script should unconfigure or shutdown the interface as
|
|
appropriate.
|
|
<A NAME="lbAO"> </A>
|
|
<H2>RELEASE</H2>
|
|
|
|
The dhclient has been executed using the -r flag, indicating that the
|
|
administrator wishes it to release its lease(s). dhclient-script should
|
|
unconfigure or shutdown the interface.
|
|
<A NAME="lbAP"> </A>
|
|
<H2>NBI</H2>
|
|
|
|
No-Broadcast-Interfaces...dhclient was unable to find any interfaces
|
|
upon which it believed it should commence DHCP. What dhclient-script
|
|
should do in this situation is entirely up to the implementor.
|
|
<A NAME="lbAQ"> </A>
|
|
<H2>TIMEOUT</H2>
|
|
|
|
The DHCP client has been unable to contact any DHCP servers.
|
|
However, an old lease has been identified, and its parameters have
|
|
been passed in as with BOUND. The client configuration script should
|
|
test these parameters and, if it has reason to believe they are valid,
|
|
should exit with a value of zero. If not, it should exit with a
|
|
nonzero value.
|
|
<P>
|
|
|
|
The usual way to test a lease is to set up the network as with REBIND
|
|
(since this may be called to test more than one lease) and then ping
|
|
the first router defined in $routers. If a response is received, the
|
|
lease must be valid for the network to which the interface is
|
|
currently connected. It would be more complete to try to ping all of
|
|
the routers listed in $new_routers, as well as those listed in
|
|
$new_static_routes, but current scripts do not do this.
|
|
<A NAME="lbAR"> </A>
|
|
<H2>FILES</H2>
|
|
|
|
Each operating system should generally have its own script file,
|
|
although the script files for similar operating systems may be similar
|
|
or even identical. The script files included in Internet
|
|
Systems Consortium DHCP distribution appear in the distribution tree
|
|
under client/scripts, and bear the names of the operating systems on
|
|
which they are intended to work.
|
|
<A NAME="lbAS"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
If more than one interface is being used, there's no obvious way to
|
|
avoid clashes between server-supplied configuration parameters - for
|
|
example, the stock dhclient-script rewrites /etc/resolv.conf. If
|
|
more than one interface is being configured, /etc/resolv.conf will be
|
|
repeatedly initialized to the values provided by one server, and then
|
|
the other. Assuming the information provided by both servers is
|
|
valid, this shouldn't cause any real problems, but it could be
|
|
confusing.
|
|
<A NAME="lbAT"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<A HREF="/cgi-bin/man/man2html?8+dhclient">dhclient</A>(8), <A HREF="/cgi-bin/man/man2html?8+dhcpd">dhcpd</A>(8), <A HREF="/cgi-bin/man/man2html?8+dhcrelay">dhcrelay</A>(8), <A HREF="/cgi-bin/man/man2html?5+dhclient.conf">dhclient.conf</A>(5) and
|
|
<A HREF="/cgi-bin/man/man2html?5+dhclient.leases">dhclient.leases</A>(5).
|
|
<A NAME="lbAU"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+dhclient-script">dhclient-script</A>(8)</B>
|
|
|
|
To learn more about Internet Systems Consortium,
|
|
see
|
|
<B><A HREF="https://www.isc.org.">https://www.isc.org.</A></B>
|
|
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">DESCRIPTION</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">HOOKS</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">OPERATION</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">MEDIUM</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">PREINIT</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">BOUND</A><DD>
|
|
<DT id="8"><A HREF="#lbAI">RENEW</A><DD>
|
|
<DT id="9"><A HREF="#lbAJ">REBIND</A><DD>
|
|
<DT id="10"><A HREF="#lbAK">REBOOT</A><DD>
|
|
<DT id="11"><A HREF="#lbAL">EXPIRE</A><DD>
|
|
<DT id="12"><A HREF="#lbAM">FAIL</A><DD>
|
|
<DT id="13"><A HREF="#lbAN">STOP</A><DD>
|
|
<DT id="14"><A HREF="#lbAO">RELEASE</A><DD>
|
|
<DT id="15"><A HREF="#lbAP">NBI</A><DD>
|
|
<DT id="16"><A HREF="#lbAQ">TIMEOUT</A><DD>
|
|
<DT id="17"><A HREF="#lbAR">FILES</A><DD>
|
|
<DT id="18"><A HREF="#lbAS">BUGS</A><DD>
|
|
<DT id="19"><A HREF="#lbAT">SEE ALSO</A><DD>
|
|
<DT id="20"><A HREF="#lbAU">AUTHOR</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:11 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|