| DHCPCD-RUN-HOOKS(8) | System Manager's Manual | DHCPCD-RUN-HOOKS(8) |
dhcpcd-run-hooks —
dhcpcd-run-hooks is used by
dhcpcd(8) to run any system and
user defined hook scripts. System hook scripts are found in
/libexec/dhcpcd-hooks and the user defined hooks are
/etc/dhcpcd.enter-hook. and
/etc/dhcpcd.exit-hook. The default install supplies
hook scripts for configuring /etc/resolv.conf and the
hostname. Your distribution may have included other hook scripts to say
configure ntp or ypbind. A test hook is also supplied that simply echos the
dhcp variables to the console from DISCOVER message.
The hooks scripts are loaded into the current shell rather than
executed in their own process. This allows each hook script, such as
/etc/dhcpcd.enter-hook to customise environment
variables or provide alternative functions to hooks further down the chain.
As such, using the shell builtins exit,
exec or similar will cause
dhcpcd-run-hooks to exit at that point.
Each time dhcpcd-run-hooks is invoked,
$interface is set to the interface that
dhcpcd is run on and $reason
is to the reason why dhcpcd-run-hooks was invoked.
DHCP information to be configured is held in variables starting with the
word new_ and old DHCP information to be removed is held in variables
starting with the word old_. dhcpcd can display the
full list of variables it knows how about by using the
-V, --variables
argument.
Here's a list of reasons why
dhcpcd-run-hooks could be invoked:
PREINITCARRIERNOCARRIERINFORM
|
INFORM6BOUND
|
BOUND6RENEW
|
RENEW6REBIND
|
REBIND6REBOOT
|
REBOOT6DELEGATED6IPV4LLSTATIC3RDPARTYTIMEOUTEXPIRE
|
EXPIRE6NAKRECONFIGUREROUTERADVERTSTOP
|
STOP6STOPPEDDEPARTEDFAILDUMPTESTdhcpcd will clear the environment variables aside from
$PATH and $RC_SVCNAME. The
following variables will then be set, along with any protocol supplied ones.
$interface$protocol$reason$piddhcpcd.$ifcarrier$interface:
unknown, up or
down.$ifmetric$interface
preference, lower is better.$ifwireless1
if $interface is wireless, otherwise
0.$ifflags$interface
flags.$ifmtu$interface
MTU.$ifssidinterface is connected
to.$interface_order$if_uptrue
if the interface is up, otherwise
false.$if_downtrue
if the interface is down, otherwise
false.$af_waiting$profile$new_delegated_dhcp6_prefixdhcpcd-run-hooks runs, it loads
/etc/dhcpcd.enter-hook and any scripts found in
/libexec/dhcpcd-hooks in a lexical order and then
finally /etc/dhcpcd.exit-hook
dhcpcd will validate the content of each option against
its encoding. For string, ascii, raw or binhex encoding it's up to the user to
validate it for the intended purpose.
When used in a shell script, each variable must be quoted correctly.
| February 20, 2018 | NetBSD 9.4 |