1DHCPCD-RUN-HOOKS(8)       BSD System Manager's Manual      DHCPCD-RUN-HOOKS(8)
2

NAME

4     dhcpcd-run-hooks — DHCP client configuration script
5

DESCRIPTION

7     dhcpcd-run-hooks is used by dhcpcd(8) to run any system and user defined
8     hook scripts.  System hook scripts are found in /usr/libexec/dhcpcd-hooks
9     and the user defined hooks are /etc/dhcpcd.enter-hook.  and
10     /etc/dhcpcd.exit-hook.  The default install supplies hook scripts for
11     configuring /etc/resolv.conf and the hostname.  Your distribution may
12     have included other hook scripts to say configure ntp or ypbind.  A test
13     hook is also supplied that simply echos the dhcp variables to the console
14     from DISCOVER message.
15
16     The hooks scripts are loaded into the current shell rather than executed
17     in their own process.  This allows each hook script, such as
18     /etc/dhcpcd.enter-hook to customise environment variables or provide al‐
19     ternative functions to hooks further down the chain.  As such, using the
20     shell builtins exit, exec or similar will cause dhcpcd-run-hooks to exit
21     at that point.
22
23     Each time dhcpcd-run-hooks is invoked, $interface is set to the interface
24     that dhcpcd is run on and $reason is to the reason why q dhcpcd-run-hooks
25     was invoked.  DHCP information to be configured is held in variables
26     starting with the word new_ and old DHCP information to be removed is
27     held in variables starting with the word old_.  dhcpcd can display the
28     full list of variables it knows how about by using the -V, --variables
29     argument.
30
31     Here's a list of reasons why dhcpcd-run-hooks could be invoked:
32
33     PREINIT           dhcpcd is starting up and any pre-initialisation should
34                       be done.
35
36     CARRIER           dhcpcd has detected the carrier is up.  This is gener‐
37                       ally just a notification and no action need be taken.
38
39     NOCARRIER         dhcpcd lost the carrier.  The cable may have been un‐
40                       plugged or association to the wireless point lost.
41
42     NOCARRIER_ROAMING
43                       dhcpcd lost the carrier but the interface configuration
44                       is persisted.  The OS has to support wireless roaming
45                       or IP Persistance for this to happen.
46
47     INFORM | INFORM6  dhcpcd informed a DHCP server about its address and ob‐
48                       tained other configuration details.
49
50     BOUND | BOUND6    dhcpcd obtained a new lease from a DHCP server.
51
52     RENEW | RENEW6    dhcpcd renewed it's lease.
53
54     REBIND | REBIND6  dhcpcd has rebound to a new DHCP server.
55
56     REBOOT | REBOOT6  dhcpcd successfully requested a lease from a DHCP
57                       server.
58
59     DELEGATED6        dhcpcd assigned a delegated prefix to the interface.
60
61     IPV4LL            dhcpcd obtained an IPV4LL address, or one was removed.
62
63     STATIC            dhcpcd has been configured with a static configuration
64                       which has not been obtained from a DHCP server.
65
66     3RDPARTY          dhcpcd is monitoring the interface for a 3rd party to
67                       give it an IP address.
68
69     TIMEOUT           dhcpcd failed to contact any DHCP servers but was able
70                       to use an old lease.
71
72     EXPIRE | EXPIRE6  dhcpcd's lease or state expired and it failed to obtain
73                       a new one.
74
75     NAK               dhcpcd received a NAK from the DHCP server.  This
76                       should be treated as EXPIRE.
77
78     RECONFIGURE       dhcpcd has been instructed to reconfigure an interface.
79
80     ROUTERADVERT      dhcpcd has received an IPv6 Router Advertisement, or
81                       one has expired.
82
83     STOP | STOP6      dhcpcd stopped running on the interface.
84
85     STOPPED           dhcpcd has stopped entirely.
86
87     DEPARTED          The interface has been removed.
88
89     FAIL              dhcpcd failed to operate on the interface.  This nor‐
90                       mally happens when dhcpcd does not support the raw in‐
91                       terface, which means it cannot work as a DHCP or Zero‐
92                       Conf client.  Static configuration and DHCP INFORM is
93                       still allowed.
94
95     TEST              dhcpcd received an OFFER from a DHCP server but will
96                       not configure the interface.  This is primarily used to
97                       test the variables are filled correctly for the script
98                       to process them.
99

ENVIRONMENT

101     dhcpcd will clear the environment variables aside from $PATH.  The fol‐
102     lowing variables will then be set, along with any protocol supplied ones.
103
104     $interface                   the name of the interface.
105
106     $protocol                    the protocol that triggered the event.
107
108     $reason                      as described above.
109
110     $pid                         the pid of dhcpcd.
111
112     $ifcarrier                   the link status of $interface: unknown, up
113                                  or down.
114
115     $ifmetric                    $interface preference, lower is better.
116
117     $ifwireless                  1 if $interface is wireless, otherwise 0.
118
119     $ifflags                     $interface flags.
120
121     $ifmtu                       $interface MTU.
122
123     $ifssid                      the name of the SSID the interface is con‐
124                                  nected to.
125
126     $interface_order             A list of interfaces, in order of prefer‐
127                                  ence.
128
129     $if_up                       true if the interface is up, otherwise
130                                  false.  This is more than IFF_UP and may not
131                                  be equal.
132
133     $if_down                     true if the interface is down, otherwise
134                                  false.  This is more than IFF_UP and may not
135                                  be equal.
136
137     $af_waiting                  Address family waiting for, as defined in
138                                  dhcpcd.conf(5).
139
140     $profile                     the name of the profile selected from
141                                  dhcpcd.conf(5).
142
143     $new_delegated_dhcp6_prefix  space separated list of delegated prefixes.
144

FILES

146     When dhcpcd-run-hooks runs, it loads /etc/dhcpcd.enter-hook and any
147     scripts found in /usr/libexec/dhcpcd-hooks in a lexical order and then
148     finally /etc/dhcpcd.exit-hook
149

SEE ALSO

151     dhcpcd(8)
152

AUTHORS

154     Roy Marples <roy@marples.name>
155

BUGS

157     Please report them to http://roy.marples.name/projects/dhcpcd
158

SECURITY CONSIDERATIONS

160     dhcpcd will validate the content of each option against its encoding.
161     For string, ascii, raw or binhex encoding it's up to the user to validate
162     it for the intended purpose.
163
164     When used in a shell script, each variable must be quoted correctly.
165
166BSD                            December 27, 2020                           BSD
Impressum