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:

  • $interface is set to the interface that dhcpcd is run on
  • $reason is set to the reason why dhcpcd-run-hooks was 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 โ€” dhcpcd is starting up and any pre-initialisation required should be performed now.
  • CARRIER โ€” dhcpcd has detected the carrier is up. this is generally just a notification and no action need be taken.
  • NOCARRIER โ€” dhcpcd lost the carrier. the cable may have been unplugged or association to the wireless point lost. ๐Ÿ˜ญ
  • NOCARRIER_ROAMING โ€” dhcpcd lost the carrier but the interface configuration is persisted. the OS has to support wireless roaming or IP Persistence for this to happen.
  • INFORM | INFORM6 โ€” dhcpcd informed a DHCP server about its address and obtained other configuration details.
  • BOUND | BOUND6 โ€” dhcpcd obtained a new lease from a DHCP server. ๐ŸŽ‰
  • RENEW | RENEW6 โ€” dhcpcd renewed its lease.
  • REBIND | REBIND6 โ€” dhcpcd has rebound to a new DHCP server.
  • REBOOT | REBOOT6 โ€” dhcpcd successfully requested a lease from a DHCP server.
  • RELEASE | RELEASE6 โ€” dhcpcd has released the lease.
  • DELEGATED6 โ€” dhcpcd assigned a delegated prefix to the interface.
  • IPV4LL โ€” dhcpcd obtained an IPV4LL address, or one was removed.
  • STATIC โ€” dhcpcd has been configured with a static configuration which has not been obtained from a DHCP server.
  • 3RDPARTY โ€” dhcpcd is monitoring the interface for a 3rd party to give it an IP address.
  • TIMEOUT | TIMEOUT6 โ€” dhcpcd failed 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 โ€” dhcpcd received a NAK from the DHCP server. this should be treated as EXPIRE.
  • RECONFIGURE โ€” dhcpcd has been instructed to reconfigure an interface.
  • ROUTERADVERT โ€” dhcpcd has received an IPv6 Router Advertisement, or one has expired.
  • STOP | STOP6 โ€” dhcpcd stopped running on the interface.
  • STOPPED โ€” dhcpcd has stopped entirely. ๐Ÿ’€
  • DEPARTED โ€” the interface has been removed.
  • FAIL โ€” 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.
  • TEST โ€” 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.

๐Ÿงš 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 of dhcpcd.
  • $ifcarrier โ€” the link status of $interface: unknown, up or down.
  • $ifmetric โ€” $interface preference, lower is better.
  • $ifwireless โ€” 1 if $interface is wireless, otherwise 0.
  • $ifflags โ€” $interface flags.
  • $ifmtu โ€” $interface MTU.
  • $ifssid โ€” the SSID the interface is connected to.
  • $interface_order โ€” a list of interfaces, in order of preference.
  • $if_configured โ€” true if dhcpcd has configured the interface otherwise false.
  • $if_up โ€” true if the interface is up, otherwise false. this is more than IFF_UP and may not be equal.
  • $if_down โ€” true if the interface is down, otherwise false. this is more than IFF_UP and may not be equal.
  • $af_waiting โ€” Address family waiting for, as defined in dhcpcd.conf(5).
  • $profile โ€” the name of the profile selected from dhcpcd.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:

  1. /etc/dhcpcd.enter-hook
  2. any scripts found in /usr/libexec/dhcpcd-hooks, in lexical order
  3. 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