15ba6b67aSAntonio Huete Jimenez.\" $OpenBSD: src/sbin/dhclient/dhclient-script.8,v 1.6 2011/04/04 11:43:20 krw Exp $ 2846204b6SHasso Tepper.\" 3846204b6SHasso Tepper.\" Copyright (c) 1997 The Internet Software Consortium. 4846204b6SHasso Tepper.\" All rights reserved. 5846204b6SHasso Tepper.\" 6846204b6SHasso Tepper.\" Redistribution and use in source and binary forms, with or without 7846204b6SHasso Tepper.\" modification, are permitted provided that the following conditions 8846204b6SHasso Tepper.\" are met: 9846204b6SHasso Tepper.\" 10846204b6SHasso Tepper.\" 1. Redistributions of source code must retain the above copyright 11846204b6SHasso Tepper.\" notice, this list of conditions and the following disclaimer. 12846204b6SHasso Tepper.\" 2. Redistributions in binary form must reproduce the above copyright 13846204b6SHasso Tepper.\" notice, this list of conditions and the following disclaimer in the 14846204b6SHasso Tepper.\" documentation and/or other materials provided with the distribution. 15846204b6SHasso Tepper.\" 3. Neither the name of The Internet Software Consortium nor the names 16846204b6SHasso Tepper.\" of its contributors may be used to endorse or promote products derived 17846204b6SHasso Tepper.\" from this software without specific prior written permission. 18846204b6SHasso Tepper.\" 19846204b6SHasso Tepper.\" THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND 20846204b6SHasso Tepper.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 21846204b6SHasso Tepper.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22846204b6SHasso Tepper.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23846204b6SHasso Tepper.\" DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR 24846204b6SHasso Tepper.\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25846204b6SHasso Tepper.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26846204b6SHasso Tepper.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27846204b6SHasso Tepper.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28846204b6SHasso Tepper.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29846204b6SHasso Tepper.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30846204b6SHasso Tepper.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31846204b6SHasso Tepper.\" SUCH DAMAGE. 32846204b6SHasso Tepper.\" 33846204b6SHasso Tepper.\" This software has been written for the Internet Software Consortium 34846204b6SHasso Tepper.\" by Ted Lemon <mellon@fugue.com> in cooperation with Vixie 35846204b6SHasso Tepper.\" Enterprises. To learn more about the Internet Software Consortium, 36846204b6SHasso Tepper.\" see ``http://www.isc.org/isc''. To learn more about Vixie 37846204b6SHasso Tepper.\" Enterprises, see ``http://www.vix.com''. 38846204b6SHasso Tepper.\" 395ba6b67aSAntonio Huete Jimenez.Dd August 4, 2012 40846204b6SHasso Tepper.Dt DHCLIENT-SCRIPT 8 41846204b6SHasso Tepper.Os 42846204b6SHasso Tepper.Sh NAME 43846204b6SHasso Tepper.Nm dhclient-script 44846204b6SHasso Tepper.Nd DHCP client network configuration script 45846204b6SHasso Tepper.Sh DESCRIPTION 46846204b6SHasso TepperThe DHCP client network configuration script is invoked from time to 47846204b6SHasso Teppertime by 48846204b6SHasso Tepper.Xr dhclient 8 . 49846204b6SHasso Tepper.Pp 50846204b6SHasso Tepper.\" No standard client script exists for some operating systems, even though 51846204b6SHasso Tepper.\" the actual client may work, so a pioneering user may well need to create 52846204b6SHasso Tepper.\" a new script or modify an existing one. 53846204b6SHasso TepperIn general, customizations specific to a particular computer should be done 54846204b6SHasso Tepperin the 55846204b6SHasso Tepper.Pa /etc/dhclient.conf 56846204b6SHasso Tepperfile. 57846204b6SHasso Tepper.Sh OPERATION 58846204b6SHasso TepperWhen 59846204b6SHasso Tepper.Xr dhclient 8 60846204b6SHasso Tepperneeds to invoke the client configuration script, it sets up a number of 61846204b6SHasso Tepperenvironment variables and runs 6268d52ec8SSascha Wildner.Nm . 63846204b6SHasso TepperIn all cases, 64846204b6SHasso Tepper.Va $reason 65846204b6SHasso Tepperis set to the name of the reason why the script has been invoked. 66846204b6SHasso TepperThe following reasons are currently defined: 675ba6b67aSAntonio Huete JimenezBOUND, RENEW, REBIND, REBOOT, EXPIRE, FAIL and TIMEOUT. 68846204b6SHasso Tepper.Bl -tag -width "ARPCHECK" 69846204b6SHasso Tepper.It BOUND 70846204b6SHasso TepperThe DHCP client has done an initial binding to a new address. 71846204b6SHasso TepperThe new IP address is passed in 72846204b6SHasso Tepper.Va $new_ip_address , 73846204b6SHasso Tepperand the interface name is passed in 74846204b6SHasso Tepper.Va $interface . 75846204b6SHasso TepperAny options acquired from the server are passed using the option name 76846204b6SHasso Tepperdescribed in 77846204b6SHasso Tepper.Xr dhcp-options 5 , 78846204b6SHasso Tepperexcept that dashes 79846204b6SHasso Tepper.Pq Sq - 80846204b6SHasso Tepperare replaced by underscores 81846204b6SHasso Tepper.Pq Sq _ 82846204b6SHasso Tepperin order to make valid shell variables, and the variable names start with new_. 83846204b6SHasso TepperSo for example, the new subnet mask would be passed in 84846204b6SHasso Tepper.Va $new_subnet_mask . 85846204b6SHasso Tepper.Pp 86846204b6SHasso TepperWhen a binding has been completed, a lot of network parameters are 87846204b6SHasso Tepperlikely to need to be set up. 88846204b6SHasso TepperA new 89846204b6SHasso Tepper.Pa /etc/resolv.conf 90846204b6SHasso Tepperneeds to be created, using the values of 91846204b6SHasso Tepper.Va $new_domain_name 92846204b6SHasso Tepperand 93846204b6SHasso Tepper.Va $new_domain_name_servers 94846204b6SHasso Tepper(which may list more than one server, separated by spaces). 95846204b6SHasso TepperA default route should be set using 96846204b6SHasso Tepper.Va $new_routers , 97846204b6SHasso Tepperand static routes may need to be set up using 98846204b6SHasso Tepper.Va $new_static_routes . 99846204b6SHasso Tepper.Pp 100846204b6SHasso TepperNote: since 101846204b6SHasso Tepper.Nm 102846204b6SHasso Teppereffectively overwrites 103846204b6SHasso Tepper.Pa /etc/resolv.conf , 104846204b6SHasso Tepperany information contained therein is lost. 105846204b6SHasso TepperIf options must be passed to the resolver, 106846204b6SHasso Tepperthey may be contained in 107846204b6SHasso Tepper.Pa /etc/resolv.conf.tail , 108846204b6SHasso Tepperwhich is appended to the generated 109846204b6SHasso Tepper.Pa /etc/resolv.conf 110846204b6SHasso Tepperby 111846204b6SHasso Tepper.Nm . 1125943b4b0SSascha Wildner.\"See 1135943b4b0SSascha Wildner.\".Xr resolv.conf.tail 5 1145943b4b0SSascha Wildner.\"for further information. 115846204b6SHasso Tepper.It RENEW 116846204b6SHasso TepperWhen a binding has been renewed, the script is called as in BOUND, 117846204b6SHasso Tepperexcept that in addition to all the variables starting with $new_, 118846204b6SHasso Tepperthere is another set of variables starting with $old_. 119846204b6SHasso TepperPersistent settings that may have changed need to be deleted \- for example, 120846204b6SHasso Tepperif a local route to the bound address is being configured, the old local 121846204b6SHasso Tepperroute should be deleted. 122846204b6SHasso TepperIf the default route has changed, the old default route should be deleted. 123846204b6SHasso TepperIf the static routes have changed, the old ones should be deleted. 124846204b6SHasso TepperOtherwise, processing can be done as with BOUND. 125846204b6SHasso Tepper.It REBIND 126846204b6SHasso TepperThe DHCP client has rebound to a new DHCP server. 127846204b6SHasso TepperThis can be handled as with RENEW, except that if the IP address has changed, 128846204b6SHasso Tepperthe ARP table should be cleared. 129846204b6SHasso Tepper.It REBOOT 130846204b6SHasso TepperThe DHCP client has successfully reacquired its old address after a reboot. 131846204b6SHasso TepperThis can be processed as with BOUND. 132846204b6SHasso Tepper.It EXPIRE 133846204b6SHasso TepperThe DHCP client has failed to renew its lease or acquire a new one, 134846204b6SHasso Tepperand the lease has expired. 135846204b6SHasso TepperThe IP address must be relinquished, and all related parameters should be 136846204b6SHasso Tepperdeleted, as in RENEW and REBIND. 137846204b6SHasso Tepper.It FAIL 138846204b6SHasso TepperThe DHCP client has been unable to contact any DHCP servers, and any 139846204b6SHasso Tepperleases that have been tested have not proved to be valid. 140846204b6SHasso TepperThe parameters from the last lease tested should be deconfigured. 141846204b6SHasso TepperThis can be handled in the same way as EXPIRE. 142846204b6SHasso Tepper.It TIMEOUT 143846204b6SHasso TepperThe DHCP client has been unable to contact any DHCP servers. 144846204b6SHasso TepperHowever, an old lease has been identified, and its parameters have 145846204b6SHasso Tepperbeen passed in as with BOUND. 146846204b6SHasso TepperThe client configuration script should test these parameters and, 147846204b6SHasso Tepperif it has reason to believe they are valid, should exit with a value of zero. 148846204b6SHasso TepperIf not, it should exit with a nonzero value. 149846204b6SHasso Tepper.El 150846204b6SHasso Tepper.Pp 151846204b6SHasso TepperThe usual way to test a lease is to set up the network as with REBIND 152846204b6SHasso Tepper(since this may be called to test more than one lease) and then ping 153846204b6SHasso Tepperthe first router defined in 154846204b6SHasso Tepper.Va $routers . 155846204b6SHasso TepperIf a response is received, the lease must be valid for the network to 156846204b6SHasso Tepperwhich the interface is currently connected. 157846204b6SHasso TepperIt would be more complete to try to ping all of the routers listed in 158846204b6SHasso Tepper.Va $new_routers , 159846204b6SHasso Tepperas well as those listed in 160846204b6SHasso Tepper.Va $new_static_routes , 161846204b6SHasso Tepperbut current scripts do not do this. 162846204b6SHasso Tepper.\" .Sh FILES 163846204b6SHasso Tepper.\" Each operating system should generally have its own script file, 164846204b6SHasso Tepper.\" although the script files for similar operating systems may be similar 165846204b6SHasso Tepper.\" or even identical. 166846204b6SHasso Tepper.\" The script files included in the Internet Software Consortium DHCP 167846204b6SHasso Tepper.\" distribution appear in the distribution tree under client/scripts, 168846204b6SHasso Tepper.\" and bear the names of the operating systems on which they are intended 169846204b6SHasso Tepper.\" to work. 170846204b6SHasso Tepper.Sh SEE ALSO 171846204b6SHasso Tepper.Xr dhclient.conf 5 , 172846204b6SHasso Tepper.Xr dhclient.leases 5 , 1735943b4b0SSascha Wildner.\".Xr resolv.conf.tail 5 , 174846204b6SHasso Tepper.Xr dhclient 8 , 175c8e8a2e5SSascha Wildner.Xr dhcpd 8 Pq Pa net/isc-dhcp42-server , 176c8e8a2e5SSascha Wildner.Xr dhcrelay 8 Pq Pa net/isc-dhcp42-relay 177846204b6SHasso Tepper.Sh AUTHORS 178846204b6SHasso Tepper.An -nosplit 179846204b6SHasso TepperThe original version of 180846204b6SHasso Tepper.Nm 181846204b6SHasso Tepperwas written for the Internet Software Consortium by 182*1cb631f7SFranco Fichtner.An Ted Lemon Aq Mt mellon@fugue.com 183846204b6SHasso Tepperin cooperation with Vixie Enterprises. 184846204b6SHasso Tepper.Pp 185846204b6SHasso TepperThe 186846204b6SHasso Tepper.Ox 187846204b6SHasso Tepperimplementation of 188846204b6SHasso Tepper.Nm 189846204b6SHasso Tepperwas written by 190*1cb631f7SFranco Fichtner.An Kenneth R. Westerback Aq Mt krw@openbsd.org . 191846204b6SHasso Tepper.Sh BUGS 192846204b6SHasso TepperIf more than one interface is being used, there's no obvious way to 193846204b6SHasso Tepperavoid clashes between server-supplied configuration parameters \- for 194846204b6SHasso Tepperexample, the stock dhclient-script rewrites 195846204b6SHasso Tepper.Pa /etc/resolv.conf . 196846204b6SHasso TepperIf more than one interface is being configured, 197846204b6SHasso Tepper.Pa /etc/resolv.conf 198846204b6SHasso Tepperwill be repeatedly initialized to the values provided by one server, and then 199846204b6SHasso Tepperthe other. 200846204b6SHasso TepperAssuming the information provided by both servers is valid, this shouldn't 201846204b6SHasso Teppercause any real problems, but it could be confusing. 202