DHCP client configuration script
is used by
to run any system and user defined hook scripts. System hook scripts are found
and the user
defined hooks are /etc/dhcpcd.enter-hook
. The default install
supplies hook scripts for configuring
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
to customise environment
variables or provide alternative functions to hooks further down the chain. As
such, using the shell builtins exit
or similar will cause
to exit at that point.
Each time dhcpcd-run-hooks
is set to the interface that
is run on and
is to the reason why
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_.
can display the full list of variables it
knows how about by using the -V
Here's a list of reasons why dhcpcd-run-hooks
- dhcpcd is starting up and any pre-initialisation should be
- dhcpcd has detected the carrier is up. This is generally
just a notification and no action need be taken.
- dhcpcd lost the carrier. The cable may have been unplugged
or association to the wireless point lost.
- dhcpcd informed a DHCP server about it's address and
obtained other configuration details.
- dhcpcd obtained a new lease from a DHCP server.
- dhcpcd renewed it's lease.
- dhcpcd has rebound to a new DHCP server.
- dhcpcd successfully requested a lease from a DHCP
- dhcpcd assigned a delegated prefix to the interface.
- dhcpcd obtained an IPV4LL address, or one was removed.
- dhcpcd has been configured with a static configuration
which has not been obtained from a DHCP server.
- dhcpcd is monitoring the interface for a 3rd party to give
it an IP address.
- dhcpcd failed to contact any DHCP servers but was able to
use an old lease.
- dhcpcd's lease or state expired and it failed to obtain a
- dhcpcd received a NAK from the DHCP server. This should be
treated as EXPIRE.
- dhcpcd has been instructed to reconfigure an
- dhcpcd has received an IPv6 Router Advertisement, or one
- dhcpcd stopped running on the interface.
- dhcpcd has stopped entirely.
- The interface has been removed.
- dhcpcd failed to operate on the interface. This normally
happens when dhcpcd does not support the raw interface, which means it
cannot work as a DHCP or ZeroConf client. Static configuration and DHCP
INFORM is still allowed.
- dhcpcd has been asked to dump the last lease for the
- dhcpcd received an OFFER from a DHCP server but will not
configure the interface. This is primarily used to test the variables are
filled correctly for the script to process them.
will clear the environment variables aside
. The following variables will
then be set, along with any protocol supplied ones.
- the name of the interface.
- the protocol that triggered the event.
- as described above.
- the pid of dhcpcd.
- the link status of
preference, lower is better.
$interface is wireless,
- the name of the SSID the
interface is connected to.
- A list of interfaces, in order of preference.
interface is up, otherwise
interface is down, otherwise
- Address family waiting for, as defined in
- the name of the profile selected from
- space separated list of delegated prefixes.
runs, it loads
and any scripts found in
in a lexical order
and then finally /etc/dhcpcd.exit-hook
Please report them to
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.