DHCPCD-RUN-HOOKS(8)
๐ DHCPCD-RUN-HOOKS(8) โ dhcpcd-run-hooks ๐
okay bestie, so this is the manual page for dhcpcd-run-hooks, part of the System Manager's Manual, and it's basically the little script-runner that makes your DHCP client do โจstuffโจ when things happen. let's get into it ๐ซถ
โจ NAME โจ
dhcpcd-run-hooks โ DHCP client configuration script
so like. it's a script. it configures. it's the DHCP client's bestie. periodt. ๐
๐ธ DESCRIPTION ๐ธ
ngl, here's the tea: dhcpcd-run-hooks is used by dhcpcd(8) to run any system and user defined hook scripts.
- the system hook scripts live in
/usr/libexec/dhcpcd-hooks - the user defined hooks are
/etc/dhcpcd.enter-hook.and/etc/dhcpcd.exit-hook.
the default install ships hook scripts for configuring /etc/resolv.conf and the hostname. your distribution may have thrown in extra hook scripts too โ like ones to configure ntp or ypbind, iykyk. there's also a test hook supplied that literally just echos the dhcp variables to the console from a DISCOVER message. iconic for debugging fr fr ๐ฅ
ok so this next part? this is the important vibe check:
the hook scripts are loaded into the current shell rather than executed in their own process. this is because it lets each hook script โ like /etc/dhcpcd.enter-hook โ customise environment variables or provide alternative functions to hooks further down the chain. ๐
but bestie. because of that, using the shell builtins exit, exec or similar will cause dhcpcd-run-hooks to exit at that point. no cap, it just ends. ๐ญ
๐ฆ the variables you get ๐ฆ
each time dhcpcd-run-hooks is invoked:
$interfaceis set to the interface thatdhcpcdis run on$reasonis set to the reason whydhcpcd-run-hookswas invoked- DHCP info to be configured lives in variables starting with the word
new_ - old DHCP info to be removed lives in variables starting with the word
old_
and dhcpcd can show you the full list of variables it knows about by using the -V, --variables argument. slay. โจ
๐ the reasons (aka why we're even here) ๐
here's the full list of reasons why dhcpcd-run-hooks could be invoked โ bestie do NOT skip these, they're the whole point:
PREINITโdhcpcdis starting up and any pre-initialisation required should be performed now.CARRIERโdhcpcdhas detected the carrier is up. this is generally just a notification and no action need be taken.NOCARRIERโdhcpcdlost the carrier. the cable may have been unplugged or association to the wireless point lost. ๐ญNOCARRIER_ROAMINGโdhcpcdlost the carrier but the interface configuration is persisted. the OS has to support wireless roaming or IP Persistence for this to happen.INFORM|INFORM6โdhcpcdinformed a DHCP server about its address and obtained other configuration details.BOUND|BOUND6โdhcpcdobtained a new lease from a DHCP server. ๐RENEW|RENEW6โdhcpcdrenewed its lease.REBIND|REBIND6โdhcpcdhas rebound to a new DHCP server.REBOOT|REBOOT6โdhcpcdsuccessfully requested a lease from a DHCP server.RELEASE|RELEASE6โdhcpcdhas released the lease.DELEGATED6โdhcpcdassigned a delegated prefix to the interface.IPV4LLโdhcpcdobtained an IPV4LL address, or one was removed.STATICโdhcpcdhas been configured with a static configuration which has not been obtained from a DHCP server.3RDPARTYโdhcpcdis monitoring the interface for a 3rd party to give it an IP address.TIMEOUT|TIMEOUT6โdhcpcdfailed to contact any DHCP servers but was able to use an old lease.EXPIRE|EXPIRE6โdhcpcd's lease or state expired and it failed to obtain a new one.NAKโdhcpcdreceived a NAK from the DHCP server. this should be treated asEXPIRE.RECONFIGUREโdhcpcdhas been instructed to reconfigure an interface.ROUTERADVERTโdhcpcdhas received an IPv6 Router Advertisement, or one has expired.STOP|STOP6โdhcpcdstopped running on the interface.STOPPEDโdhcpcdhas stopped entirely. ๐DEPARTEDโ the interface has been removed.FAILโdhcpcdfailed to operate on the interface. this normally happens whendhcpcddoes not support the raw interface, which means it cannot work as a DHCP or ZeroConf client. static configuration and DHCP INFORM is still allowed.TESTโdhcpcdreceived 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.
๐ง ENVIRONMENT ๐ง
heads up bestie: dhcpcd will clear the environment variables aside from $PATH. then these following variables get set, along with any protocol supplied ones:
$interfaceโ the name of the interface.$protocolโ the protocol that triggered the event.$reasonโ as described above.$pidโ the pid ofdhcpcd.$ifcarrierโ the link status of$interface:unknown,upordown.$ifmetricโ$interfacepreference, lower is better.$ifwirelessโ1if$interfaceis wireless, otherwise0.$ifflagsโ$interfaceflags.$ifmtuโ$interfaceMTU.$ifssidโ the SSID the interface is connected to.$interface_orderโ a list of interfaces, in order of preference.$if_configuredโtrueifdhcpcdhas configured the interface otherwisefalse.$if_upโtrueif the interface is up, otherwisefalse. this is more thanIFF_UPand may not be equal.$if_downโtrueif the interface is down, otherwisefalse. this is more thanIFF_UPand may not be equal.$af_waitingโ Address family waiting for, as defined indhcpcd.conf(5).$profileโ the name of the profile selected fromdhcpcd.conf(5).$new_delegated_dhcp6_prefixโ space-separated list of addresses assigned from delegated prefixes.
๐ FILES ๐
when dhcpcd-run-hooks runs, it loads stuff in this exact order, bestie:
/etc/dhcpcd.enter-hook- any scripts found in
/usr/libexec/dhcpcd-hooks, in lexical order - and finally
/etc/dhcpcd.exit-hook
that's the order. no skipping. ๐
๐ SEE ALSO ๐
๐ AUTHORS ๐
Roy Marples <roy@marples.name>
๐ BUGS ๐
please report them to https://roy.marples.name/projects/dhcpcd
๐ SECURITY CONSIDERATIONS ๐
okay this part is serious, so listen up:
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.
and when used in a shell script, each variable must be quoted correctly. non-negotiable. this is the rule. ๐ซถ
that's the whole page, bestie!! this one came from Debian, dated August 14, 2026 โ go forth and hook responsibly ๐โจ๐๐ฆ
๐ฆ where this page comes from
- opensuse-leap 16.0: dhcpcd 10.5.2-160000.2.1 ยท BSD-2-Clause
- opensuse-leap 16.0: dhcpcd 10.5.2-160000.2.1 ยท BSD-2-Clause
- opensuse-leap 16.0: dhcpcd 10.5.2-160000.2.1 ยท BSD-2-Clause
- opensuse-leap 16.0: dhcpcd 10.5.2-160000.2.1 ยท BSD-2-Clause
- ubuntu stonking: dhcpcd-base 1:10.5.2-6 ยท BSD-2-Clause
- ๐ the page's license: BSD-2-Clause
- Copyright (c) 2006-2025 Roy Marples
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms