xref: /freebsd/sbin/dhclient/dhclient-script.8 (revision 47c0859616bfefdd59ce6bbd8dd46882cef4527a)
147c08596SBrooks Davis.\"	$OpenBSD: dhclient-script.8,v 1.2 2004/04/09 18:30:15 jmc Exp $
247c08596SBrooks Davis.\"
347c08596SBrooks Davis.\" Copyright (c) 1997 The Internet Software Consortium.
447c08596SBrooks Davis.\" All rights reserved.
547c08596SBrooks Davis.\"
647c08596SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
747c08596SBrooks Davis.\" modification, are permitted provided that the following conditions
847c08596SBrooks Davis.\" are met:
947c08596SBrooks Davis.\"
1047c08596SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
1147c08596SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
1247c08596SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
1347c08596SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
1447c08596SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
1547c08596SBrooks Davis.\" 3. Neither the name of The Internet Software Consortium nor the names
1647c08596SBrooks Davis.\"    of its contributors may be used to endorse or promote products derived
1747c08596SBrooks Davis.\"    from this software without specific prior written permission.
1847c08596SBrooks Davis.\"
1947c08596SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
2047c08596SBrooks Davis.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
2147c08596SBrooks Davis.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2247c08596SBrooks Davis.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2347c08596SBrooks Davis.\" DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
2447c08596SBrooks Davis.\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2547c08596SBrooks Davis.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2647c08596SBrooks Davis.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
2747c08596SBrooks Davis.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2847c08596SBrooks Davis.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2947c08596SBrooks Davis.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
3047c08596SBrooks Davis.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3147c08596SBrooks Davis.\" SUCH DAMAGE.
3247c08596SBrooks Davis.\"
3347c08596SBrooks Davis.\" This software has been written for the Internet Software Consortium
3447c08596SBrooks Davis.\" by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
3547c08596SBrooks Davis.\" Enterprises.  To learn more about the Internet Software Consortium,
3647c08596SBrooks Davis.\" see ``http://www.isc.org/isc''.  To learn more about Vixie
3747c08596SBrooks Davis.\" Enterprises, see ``http://www.vix.com''.
3847c08596SBrooks Davis.\"
3947c08596SBrooks Davis.Dd January 1, 1997
4047c08596SBrooks Davis.Dt DHCLIENT-SCRIPT 8
4147c08596SBrooks Davis.Os
4247c08596SBrooks Davis.Sh NAME
4347c08596SBrooks Davis.Nm dhclient-script
4447c08596SBrooks Davis.Nd DHCP client network configuration script
4547c08596SBrooks Davis.Sh DESCRIPTION
4647c08596SBrooks DavisThe DHCP client network configuration script is invoked from time to
4747c08596SBrooks Davistime by
4847c08596SBrooks Davis.Xr dhclient 8 .
4947c08596SBrooks DavisThis script is used by the DHCP client to set each interface's initial
5047c08596SBrooks Davisconfiguration prior to requesting an address, to test the address once it
5147c08596SBrooks Davishas been offered, and to set the interface's final configuration once a
5247c08596SBrooks Davislease has been acquired.
5347c08596SBrooks DavisIf no lease is acquired, the script is used to test predefined leases, if
5447c08596SBrooks Davisany, and also called once if no valid lease can be identified.
5547c08596SBrooks Davis.Pp
5647c08596SBrooks Davis.\" No standard client script exists for some operating systems, even though
5747c08596SBrooks Davis.\" the actual client may work, so a pioneering user may well need to create
5847c08596SBrooks Davis.\" a new script or modify an existing one.
5947c08596SBrooks DavisIn general, customizations specific to a particular computer should be done
6047c08596SBrooks Davisin the
6147c08596SBrooks Davis.Pa /etc/dhclient.conf
6247c08596SBrooks Davisfile.
6347c08596SBrooks Davis.Sh OPERATION
6447c08596SBrooks DavisWhen
6547c08596SBrooks Davis.Xr dhclient 8
6647c08596SBrooks Davisneeds to invoke the client configuration script, it sets up a number of
6747c08596SBrooks Davisenvironment variables and runs
6847c08596SBrooks Davis.Nm dhclient-script .
6947c08596SBrooks DavisIn all cases,
7047c08596SBrooks Davis.Va $reason
7147c08596SBrooks Davisis set to the name of the reason why the script has been invoked.
7247c08596SBrooks DavisThe following reasons are currently defined:
7347c08596SBrooks DavisMEDIUM, PREINIT, ARPCHECK, ARPSEND, BOUND, RENEW, REBIND, REBOOT,
7447c08596SBrooks DavisEXPIRE, FAIL and TIMEOUT.
7547c08596SBrooks Davis.Bl -tag -width "ARPCHECK"
7647c08596SBrooks Davis.It MEDIUM
7747c08596SBrooks DavisThe DHCP client is requesting that an interface's media type be set.
7847c08596SBrooks DavisThe interface name is passed in
7947c08596SBrooks Davis.Va $interface ,
8047c08596SBrooks Davisand the media type is passed in
8147c08596SBrooks Davis.Va $medium .
8247c08596SBrooks Davis.It PREINIT
8347c08596SBrooks DavisThe DHCP client is requesting that an interface be configured as
8447c08596SBrooks Davisrequired in order to send packets prior to receiving an actual address.
8547c08596SBrooks Davis.\" For clients which use the BSD socket library,
8647c08596SBrooks DavisThis means configuring the interface with an IP address of 0.0.0.0
8747c08596SBrooks Davisand a broadcast address of 255.255.255.255.
8847c08596SBrooks Davis.\" For other clients, it may be possible to simply configure the interface up
8947c08596SBrooks Davis.\" without actually giving it an IP address at all.
9047c08596SBrooks DavisThe interface name is passed in
9147c08596SBrooks Davis.Va $interface ,
9247c08596SBrooks Davisand the media type in
9347c08596SBrooks Davis.Va $medium .
9447c08596SBrooks Davis.Pp
9547c08596SBrooks DavisIf an IP alias has been declared in
9647c08596SBrooks Davis.Xr dhclient.conf 5 ,
9747c08596SBrooks Davisits address will be passed in
9847c08596SBrooks Davis.Va $alias_ip_address ,
9947c08596SBrooks Davisand that IP alias should be deleted from the interface,
10047c08596SBrooks Davisalong with any routes to it.
10147c08596SBrooks Davis.It ARPSEND
10247c08596SBrooks DavisThe DHCP client is requesting that an address that has been offered to
10347c08596SBrooks Davisit be checked to see if somebody else is using it, by sending an ARP
10447c08596SBrooks Davisrequest for that address.
10547c08596SBrooks DavisIt's not clear how to implement this, so no examples exist yet.
10647c08596SBrooks DavisThe IP address to check is passed in
10747c08596SBrooks Davis.Va $new_ip_address ,
10847c08596SBrooks Davisand the interface name is passed in
10947c08596SBrooks Davis.Va $interface .
11047c08596SBrooks Davis.It ARPCHECK
11147c08596SBrooks DavisThe DHCP client wants to know if a response to the ARP request sent
11247c08596SBrooks Davisusing ARPSEND has been received.
11347c08596SBrooks DavisIf one has, the script should exit with a nonzero status, indicating that
11447c08596SBrooks Davisthe offered address has already been requested and should be declined.
11547c08596SBrooks Davis.Va $new_ip_address
11647c08596SBrooks Davisand
11747c08596SBrooks Davis.Va $interface
11847c08596SBrooks Davisare set as with ARPSEND.
11947c08596SBrooks Davis.It BOUND
12047c08596SBrooks DavisThe DHCP client has done an initial binding to a new address.
12147c08596SBrooks DavisThe new IP address is passed in
12247c08596SBrooks Davis.Va $new_ip_address ,
12347c08596SBrooks Davisand the interface name is passed in
12447c08596SBrooks Davis.Va $interface .
12547c08596SBrooks DavisThe media type is passed in
12647c08596SBrooks Davis.Va $medium .
12747c08596SBrooks DavisAny options acquired from the server are passed using the option name
12847c08596SBrooks Davisdescribed in
12947c08596SBrooks Davis.Xr dhcp-options 5 ,
13047c08596SBrooks Davisexcept that dashes
13147c08596SBrooks Davis.Pq Sq -
13247c08596SBrooks Davisare replaced by underscores
13347c08596SBrooks Davis.Pq Sq _
13447c08596SBrooks Davisin order to make valid shell variables, and the variable names start with new_.
13547c08596SBrooks DavisSo for example, the new subnet mask would be passed in
13647c08596SBrooks Davis.Va $new_subnet_mask .
13747c08596SBrooks Davis.Pp
13847c08596SBrooks DavisWhen a binding has been completed, a lot of network parameters are
13947c08596SBrooks Davislikely to need to be set up.
14047c08596SBrooks DavisA new
14147c08596SBrooks Davis.Pa /etc/resolv.conf
14247c08596SBrooks Davisneeds to be created, using the values of
14347c08596SBrooks Davis.Va $new_domain_name
14447c08596SBrooks Davisand
14547c08596SBrooks Davis.Va $new_domain_name_servers
14647c08596SBrooks Davis(which may list more than one server, separated by spaces).
14747c08596SBrooks DavisA default route should be set using
14847c08596SBrooks Davis.Va $new_routers ,
14947c08596SBrooks Davisand static routes may need to be set up using
15047c08596SBrooks Davis.Va $new_static_routes .
15147c08596SBrooks Davis.Pp
15247c08596SBrooks DavisIf an IP alias has been declared, it must be set up here.
15347c08596SBrooks DavisThe alias IP address will be written as
15447c08596SBrooks Davis.Va $alias_ip_address ,
15547c08596SBrooks Davisand other DHCP options that are set for the alias (e.g., subnet mask)
15647c08596SBrooks Daviswill be passed in variables named as described previously except starting with
15747c08596SBrooks Davis$alias_ instead of $new_.
15847c08596SBrooks DavisCare should be taken that the alias IP address not be used if it is identical
15947c08596SBrooks Davisto the bound IP address
16047c08596SBrooks Davis.Pq Va $new_ip_address ,
16147c08596SBrooks Davissince the other alias parameters may be incorrect in this case.
16247c08596SBrooks Davis.It RENEW
16347c08596SBrooks DavisWhen a binding has been renewed, the script is called as in BOUND,
16447c08596SBrooks Davisexcept that in addition to all the variables starting with $new_,
16547c08596SBrooks Davisthere is another set of variables starting with $old_.
16647c08596SBrooks DavisPersistent settings that may have changed need to be deleted \- for example,
16747c08596SBrooks Davisif a local route to the bound address is being configured, the old local
16847c08596SBrooks Davisroute should be deleted.
16947c08596SBrooks DavisIf the default route has changed, the old default route should be deleted.
17047c08596SBrooks DavisIf the static routes have changed, the old ones should be deleted.
17147c08596SBrooks DavisOtherwise, processing can be done as with BOUND.
17247c08596SBrooks Davis.It REBIND
17347c08596SBrooks DavisThe DHCP client has rebound to a new DHCP server.
17447c08596SBrooks DavisThis can be handled as with RENEW, except that if the IP address has changed,
17547c08596SBrooks Davisthe ARP table should be cleared.
17647c08596SBrooks Davis.It REBOOT
17747c08596SBrooks DavisThe DHCP client has successfully reacquired its old address after a reboot.
17847c08596SBrooks DavisThis can be processed as with BOUND.
17947c08596SBrooks Davis.It EXPIRE
18047c08596SBrooks DavisThe DHCP client has failed to renew its lease or acquire a new one,
18147c08596SBrooks Davisand the lease has expired.
18247c08596SBrooks DavisThe IP address must be relinquished, and all related parameters should be
18347c08596SBrooks Davisdeleted, as in RENEW and REBIND.
18447c08596SBrooks Davis.It FAIL
18547c08596SBrooks DavisThe DHCP client has been unable to contact any DHCP servers, and any
18647c08596SBrooks Davisleases that have been tested have not proved to be valid.
18747c08596SBrooks DavisThe parameters from the last lease tested should be deconfigured.
18847c08596SBrooks DavisThis can be handled in the same way as EXPIRE.
18947c08596SBrooks Davis.It TIMEOUT
19047c08596SBrooks DavisThe DHCP client has been unable to contact any DHCP servers.
19147c08596SBrooks DavisHowever, an old lease has been identified, and its parameters have
19247c08596SBrooks Davisbeen passed in as with BOUND.
19347c08596SBrooks DavisThe client configuration script should test these parameters and,
19447c08596SBrooks Davisif it has reason to believe they are valid, should exit with a value of zero.
19547c08596SBrooks DavisIf not, it should exit with a nonzero value.
19647c08596SBrooks Davis.El
19747c08596SBrooks Davis.Pp
19847c08596SBrooks DavisThe usual way to test a lease is to set up the network as with REBIND
19947c08596SBrooks Davis(since this may be called to test more than one lease) and then ping
20047c08596SBrooks Davisthe first router defined in
20147c08596SBrooks Davis.Va $routers .
20247c08596SBrooks DavisIf a response is received, the lease must be valid for the network to
20347c08596SBrooks Daviswhich the interface is currently connected.
20447c08596SBrooks DavisIt would be more complete to try to ping all of the routers listed in
20547c08596SBrooks Davis.Va $new_routers ,
20647c08596SBrooks Davisas well as those listed in
20747c08596SBrooks Davis.Va $new_static_routes ,
20847c08596SBrooks Davisbut current scripts do not do this.
20947c08596SBrooks Davis.\" .Sh FILES
21047c08596SBrooks Davis.\" Each operating system should generally have its own script file,
21147c08596SBrooks Davis.\" although the script files for similar operating systems may be similar
21247c08596SBrooks Davis.\" or even identical.
21347c08596SBrooks Davis.\" The script files included in the Internet Software Consortium DHCP
21447c08596SBrooks Davis.\" distribution appear in the distribution tree under client/scripts,
21547c08596SBrooks Davis.\" and bear the names of the operating systems on which they are intended
21647c08596SBrooks Davis.\" to work.
21747c08596SBrooks Davis.Sh SEE ALSO
21847c08596SBrooks Davis.Xr dhclient.conf 5 ,
21947c08596SBrooks Davis.Xr dhclient.leases 5 ,
22047c08596SBrooks Davis.Xr dhclient 8 ,
22147c08596SBrooks Davis.Xr dhcpd 8 ,
22247c08596SBrooks Davis.Xr dhcrelay 8
22347c08596SBrooks Davis.Sh AUTHORS
22447c08596SBrooks DavisThe original version of
22547c08596SBrooks Davis.Nm
22647c08596SBrooks Daviswas written for the Internet Software Consortium by
22747c08596SBrooks Davis.An Ted Lemon Aq mellon@fugue.com
22847c08596SBrooks Davisin cooperation with Vixie Enterprises.
22947c08596SBrooks Davis.Pp
23047c08596SBrooks DavisThe
23147c08596SBrooks Davis.Ox
23247c08596SBrooks Davisimplementation of
23347c08596SBrooks Davis.Nm
23447c08596SBrooks Daviswas written by
23547c08596SBrooks Davis.An Kenneth R. Westerback Aq krw@openbsd.org .
23647c08596SBrooks Davis.Sh BUGS
23747c08596SBrooks DavisIf more than one interface is being used, there's no obvious way to
23847c08596SBrooks Davisavoid clashes between server-supplied configuration parameters \- for
23947c08596SBrooks Davisexample, the stock dhclient-script rewrites
24047c08596SBrooks Davis.Pa /etc/resolv.conf .
24147c08596SBrooks DavisIf more than one interface is being configured,
24247c08596SBrooks Davis.Pa /etc/resolv.conf
24347c08596SBrooks Daviswill be repeatedly initialized to the values provided by one server, and then
24447c08596SBrooks Davisthe other.
24547c08596SBrooks DavisAssuming the information provided by both servers is valid, this shouldn't
24647c08596SBrooks Daviscause any real problems, but it could be confusing.
247