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 set to the reason why
25     dhcpcd-run-hooks was invoked.  DHCP information to be configured is held
26     in variables starting with the word new_ and old DHCP information to be
27     removed is held in variables starting with the word old_.  dhcpcd can
28     display the full list of variables it knows about by using the -V,
29     --variables 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 re‐
34                       quired should be performed now.
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 Persistence 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 its 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 SSID the interface is connected to.
124
125     $interface_order             A list of interfaces, in order of prefer‐
126                                  ence.
127
128     $if_up                       true if the interface is up, otherwise
129                                  false.  This is more than IFF_UP and may not
130                                  be equal.
131
132     $if_down                     true if the interface is down, otherwise
133                                  false.  This is more than IFF_UP and may not
134                                  be equal.
135
136     $af_waiting                  Address family waiting for, as defined in
137                                  dhcpcd.conf(5).
138
139     $profile                     the name of the profile selected from
140                                  dhcpcd.conf(5).
141
142     $new_delegated_dhcp6_prefix  space-separated list of delegated prefixes.
143

FILES

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

SEE ALSO

150     dhcpcd(8)
151

AUTHORS

153     Roy Marples <roy@marples.name>
154

BUGS

156     Please report them to https://roy.marples.name/projects/dhcpcd
157

SECURITY CONSIDERATIONS

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