1*794dfa77Sroy.\" Copyright (c) 2006-2023 Roy Marples 22364920bSroy.\" All rights reserved 32364920bSroy.\" 42364920bSroy.\" Redistribution and use in source and binary forms, with or without 52364920bSroy.\" modification, are permitted provided that the following conditions 62364920bSroy.\" are met: 72364920bSroy.\" 1. Redistributions of source code must retain the above copyright 82364920bSroy.\" notice, this list of conditions and the following disclaimer. 92364920bSroy.\" 2. Redistributions in binary form must reproduce the above copyright 102364920bSroy.\" notice, this list of conditions and the following disclaimer in the 112364920bSroy.\" documentation and/or other materials provided with the distribution. 122364920bSroy.\" 132364920bSroy.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 142364920bSroy.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 152364920bSroy.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 162364920bSroy.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 172364920bSroy.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 182364920bSroy.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 192364920bSroy.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 202364920bSroy.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 212364920bSroy.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 222364920bSroy.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 232364920bSroy.\" SUCH DAMAGE. 242364920bSroy.\" 25*794dfa77Sroy.Dd August 31, 2022 262364920bSroy.Dt DHCPCD-RUN-HOOKS 8 272364920bSroy.Os 282364920bSroy.Sh NAME 292364920bSroy.Nm dhcpcd-run-hooks 302364920bSroy.Nd DHCP client configuration script 312364920bSroy.Sh DESCRIPTION 322364920bSroy.Nm 332364920bSroyis used by 342364920bSroy.Xr dhcpcd 8 352364920bSroyto run any system and user defined hook scripts. 362364920bSroySystem hook scripts are found in 372364920bSroy.Pa /libexec/dhcpcd-hooks 382364920bSroyand the user defined hooks are 392364920bSroy.Pa /etc/dhcpcd.enter-hook . 402364920bSroyand 412364920bSroy.Pa /etc/dhcpcd.exit-hook . 422364920bSroyThe default install supplies hook scripts for configuring 432364920bSroy.Pa /etc/resolv.conf 442364920bSroyand the hostname. 452364920bSroyYour distribution may have included other hook scripts to say configure 462364920bSroyntp or ypbind. 472364920bSroyA test hook is also supplied that simply echos the dhcp variables to the 482364920bSroyconsole from DISCOVER message. 492364920bSroy.Pp 502364920bSroyThe hooks scripts are loaded into the current shell rather than executed 512364920bSroyin their own process. 522364920bSroyThis allows each hook script, such as 532364920bSroy.Pa /etc/dhcpcd.enter-hook 542364920bSroyto customise environment variables or provide alternative functions to hooks 552364920bSroyfurther down the chain. 562364920bSroyAs such, using the shell builtins 572364920bSroy.Ic exit , 582364920bSroy.Ic exec 592364920bSroyor similar will cause 602364920bSroy.Nm 612364920bSroyto exit at that point. 622364920bSroy.Pp 632364920bSroyEach time 642364920bSroy.Nm 652364920bSroyis invoked, 662364920bSroy.Ev $interface 672364920bSroyis set to the interface that 682364920bSroy.Nm dhcpcd 692364920bSroyis run on and 702364920bSroy.Ev $reason 71*794dfa77Sroyis set to the reason why 722364920bSroy.Nm 732364920bSroywas invoked. 742364920bSroyDHCP information to be configured is held in variables starting with the word 752364920bSroynew_ and old DHCP information to be removed is held in variables starting with 762364920bSroythe word old_. 772364920bSroy.Nm dhcpcd 78*794dfa77Sroycan display the full list of variables it knows about by using the 792364920bSroy.Fl V , -variables 802364920bSroyargument. 812364920bSroy.Pp 822364920bSroyHere's a list of reasons why 832364920bSroy.Nm 842364920bSroycould be invoked: 852364920bSroy.Bl -tag -width EXPIREXXXEXPIRE6 862364920bSroy.It Dv PREINIT 87*794dfa77Sroydhcpcd is starting up and any pre-initialisation required should be performed now. 882364920bSroy.It Dv CARRIER 892364920bSroydhcpcd has detected the carrier is up. 902364920bSroyThis is generally just a notification and no action need be taken. 912364920bSroy.It Dv NOCARRIER 922364920bSroydhcpcd lost the carrier. 932364920bSroyThe cable may have been unplugged or association to the wireless point lost. 942364920bSroy.It Dv NOCARRIER_ROAMING 952364920bSroydhcpcd lost the carrier but the interface configuration is persisted. 96*794dfa77SroyThe OS has to support wireless roaming or IP Persistence for this to happen. 972364920bSroy.It Dv INFORM | Dv INFORM6 982364920bSroydhcpcd informed a DHCP server about its address and obtained other 992364920bSroyconfiguration details. 1002364920bSroy.It Dv BOUND | Dv BOUND6 1012364920bSroydhcpcd obtained a new lease from a DHCP server. 1022364920bSroy.It Dv RENEW | Dv RENEW6 103*794dfa77Sroydhcpcd renewed its lease. 1042364920bSroy.It Dv REBIND | Dv REBIND6 1052364920bSroydhcpcd has rebound to a new DHCP server. 1062364920bSroy.It Dv REBOOT | Dv REBOOT6 1072364920bSroydhcpcd successfully requested a lease from a DHCP server. 1082364920bSroy.It Dv DELEGATED6 1092364920bSroydhcpcd assigned a delegated prefix to the interface. 1102364920bSroy.It Dv IPV4LL 1112364920bSroydhcpcd obtained an IPV4LL address, or one was removed. 1122364920bSroy.It Dv STATIC 1132364920bSroydhcpcd has been configured with a static configuration which has not been 1142364920bSroyobtained from a DHCP server. 1152364920bSroy.It Dv 3RDPARTY 1162364920bSroydhcpcd is monitoring the interface for a 3rd party to give it an IP address. 1172364920bSroy.It Dv TIMEOUT 1182364920bSroydhcpcd failed to contact any DHCP servers but was able to use an old lease. 1192364920bSroy.It Dv EXPIRE | EXPIRE6 1202364920bSroydhcpcd's lease or state expired and it failed to obtain a new one. 1212364920bSroy.It Dv NAK 1222364920bSroydhcpcd received a NAK from the DHCP server. 1232364920bSroyThis should be treated as EXPIRE. 1242364920bSroy.It Dv RECONFIGURE 1252364920bSroydhcpcd has been instructed to reconfigure an interface. 1262364920bSroy.It Dv ROUTERADVERT 1272364920bSroydhcpcd has received an IPv6 Router Advertisement, or one has expired. 1282364920bSroy.It Dv STOP | Dv STOP6 1292364920bSroydhcpcd stopped running on the interface. 1302364920bSroy.It Dv STOPPED 1312364920bSroydhcpcd has stopped entirely. 1322364920bSroy.It Dv DEPARTED 1332364920bSroyThe interface has been removed. 1342364920bSroy.It Dv FAIL 1352364920bSroydhcpcd failed to operate on the interface. 1362364920bSroyThis normally happens when dhcpcd does not support the raw interface, which 1372364920bSroymeans it cannot work as a DHCP or ZeroConf client. 1382364920bSroyStatic configuration and DHCP INFORM is still allowed. 1392364920bSroy.It Dv TEST 1402364920bSroydhcpcd received an OFFER from a DHCP server but will not configure the 1412364920bSroyinterface. 1422364920bSroyThis is primarily used to test the variables are filled correctly for the 1432364920bSroyscript to process them. 1442364920bSroy.El 1452364920bSroy.Sh ENVIRONMENT 1462364920bSroy.Nm dhcpcd 1472364920bSroywill clear the environment variables aside from 1482364920bSroy.Ev $PATH . 1492364920bSroyThe following variables will then be set, along with any protocol supplied 1502364920bSroyones. 1512364920bSroy.Bl -tag -width xnew_delegated_dhcp6_prefix 1522364920bSroy.It Ev $interface 1532364920bSroythe name of the interface. 1542364920bSroy.It Ev $protocol 1552364920bSroythe protocol that triggered the event. 1562364920bSroy.It Ev $reason 1572364920bSroyas described above. 1582364920bSroy.It Ev $pid 1592364920bSroythe pid of 1602364920bSroy.Nm dhcpcd . 1612364920bSroy.It Ev $ifcarrier 1622364920bSroythe link status of 1632364920bSroy.Ev $interface : 1642364920bSroy.Dv unknown , 1652364920bSroy.Dv up 1662364920bSroyor 1672364920bSroy.Dv down . 1682364920bSroy.It Ev $ifmetric 1692364920bSroy.Ev $interface 1702364920bSroypreference, lower is better. 1712364920bSroy.It Ev $ifwireless 1722364920bSroy.Dv 1 if 1732364920bSroy.Ev $interface 1742364920bSroyis wireless, otherwise 1752364920bSroy.Dv 0 . 1762364920bSroy.It Ev $ifflags 1772364920bSroy.Ev $interface 1782364920bSroyflags. 1792364920bSroy.It Ev $ifmtu 1802364920bSroy.Ev $interface 1812364920bSroyMTU. 1822364920bSroy.It Ev $ifssid 183*794dfa77Sroythe SSID the 1842364920bSroy.Ev interface 1852364920bSroyis connected to. 1862364920bSroy.It Ev $interface_order 1872364920bSroyA list of interfaces, in order of preference. 1882364920bSroy.It Ev $if_up 1892364920bSroy.Dv true 1902364920bSroyif the 1912364920bSroy.Ev interface 1922364920bSroyis up, otherwise 1932364920bSroy.Dv false . 1942364920bSroyThis is more than IFF_UP and may not be equal. 1952364920bSroy.It Ev $if_down 1962364920bSroy.Dv true 1972364920bSroyif the 1982364920bSroy.Ev interface 1992364920bSroyis down, otherwise 2002364920bSroy.Dv false . 2012364920bSroyThis is more than IFF_UP and may not be equal. 2022364920bSroy.It Ev $af_waiting 2032364920bSroyAddress family waiting for, as defined in 2042364920bSroy.Xr dhcpcd.conf 5 . 2052364920bSroy.It Ev $profile 2062364920bSroythe name of the profile selected from 2072364920bSroy.Xr dhcpcd.conf 5 . 2082364920bSroy.It Ev $new_delegated_dhcp6_prefix 209*794dfa77Sroyspace-separated list of delegated prefixes. 2102364920bSroy.El 2112364920bSroy.Sh FILES 2122364920bSroyWhen 2132364920bSroy.Nm 2142364920bSroyruns, it loads 215*794dfa77Sroy.Pa /etc/dhcpcd.enter-hook , 216*794dfa77Sroyany scripts found in 2172364920bSroy.Pa /libexec/dhcpcd-hooks 218*794dfa77Sroyin lexical order, then finally 219*794dfa77Sroy.Pa /etc/dhcpcd.exit-hook . 2202364920bSroy.Sh SEE ALSO 2212364920bSroy.Xr dhcpcd 8 2222364920bSroy.Sh AUTHORS 2232364920bSroy.An Roy Marples Aq Mt roy@marples.name 2242364920bSroy.Sh BUGS 2252364920bSroyPlease report them to 226*794dfa77Sroy.Lk https://roy.marples.name/projects/dhcpcd 2272364920bSroy.Sh SECURITY CONSIDERATIONS 2282364920bSroy.Nm dhcpcd 2292364920bSroywill validate the content of each option against its encoding. 2302364920bSroyFor string, ascii, raw or binhex encoding it's up to the user to validate it 2312364920bSroyfor the intended purpose. 2322364920bSroy.Pp 2332364920bSroyWhen used in a shell script, each variable must be quoted correctly. 234