dhcpcanon-script(8)

πŸ“¦ version 0.8.5, in ubuntu jammy, ubuntu noble

✨ dhcpcanon-script(8) β€” the manual page, but make it cute ✨

okay bestie, sit down, hydrate, because this is the dhcpcanon-script page from the System Manager's Manual and it's honestly a lot, but we're gonna get through it together πŸ’–


🌸 NAME 🌸

dhcpcanon-script β€” the DHCP client network configuration script 🧚


πŸ’… DESCRIPTION πŸ’…

so basically, dhcpcanon(8) calls this script from time to time β€” like, whenever it needs it. The dhcp client uses this script to:

  • set up each interface's initial configuration before it asks for an address,
  • test the address once one has been offered,
  • and set the interface's final configuration once a lease has actually been acquired πŸ‘‘

And if no lease gets acquired? The script is also used to test any predefined leases (if there even are any), and it gets called one more time if no valid lease can be identified. F, but okay.

lowkey important: this script is not meant to be customized by the end user. Like, that's not its vibe. If you need local customizations, do it with the enter and exit hooks instead (scroll to HOOKS, iykyk). Those hooks let you override the client's default behaviour when it creates a /etc/resolv.conf file.

Also, some operating systems just… don't have a standard client script? Even when the actual client works fine?? So a pioneering user may well need to create a brand new script or modify an existing one. main character energy tbh 🌈


πŸŽ€ HOOKS πŸŽ€

When it starts up, the client script first defines a shell function, make_resolv_conf, which gets used later to create the /etc/resolv.conf file. Want to override the default behaviour? Redefine that function in the enter hook script. Easy. πŸ’…

After defining the make_resolv_conf function, the client script checks whether an executable ETCDIR/dhcpcanon-enter-hooks script exists, and if it does, it invokes that script inline, using the Bourne shell ´.´ command. The entire environment documented under OPERATION is available to this script, and it's allowed to modify the environment if it needs to change how the script behaves. If an error happens while that script runs, it can set the exit_status variable to a nonzero value, and CLIENTBINDIR/dhcpcanon-script will exit with that error code immediately after the client script exits. 😀

Then, after all the processing has finished, CLIENTBINDIR/dhcpcanon-script checks whether an executable ETCDIR/dhcpcanon-exit-hooks script exists, and if it does, it gets invoked using the Β΄.Β΄ command too. The exit status of dhcpcanon-script gets passed to dhcpcanon-exit-hooks in the exit_status shell variable, and that will always be zero if the script succeeded at the task it was invoked for. The rest of the environment, as described above for dhcpcanon-enter-hooks, is also present. And plot twist: the ETCDIR/dhcpcanon-exit-hooks script can modify the valid of exit_status to change the exit status of dhcpcanon-script. πŸ‘€


🌈 OPERATION 🌈

When dhcpcanon needs to invoke the client configuration script, it defines a set of variables in the environment, and then invokes CLIENTBINDIR/dhcpcanon-script. In all cases, $reason is set to the name of the reason why the script has been invoked. Here are the reasons currently defined, and yes, we're doing all of them:

MEDIUM, PREINIT, BOUND, RENEW, REBIND, REBOOT, EXPIRE, FAIL, STOP, RELEASE, NBI and TIMEOUT ✨


⭐ MEDIUM ⭐

The DHCP client is requesting that an interface's media type be set. The interface name is passed in $interface, and the media type is passed in $medium. slay πŸ’…


⭐ PREINIT ⭐

The DHCP client is requesting that an interface be configured as required in order to send packets before receiving an actual address. For clients that use the BSD socket library, this means configuring the interface with an IP address of 0.0.0.0 and a broadcast address of 255.255.255.255. For other clients, it may be possible to simply configure the interface up without actually giving it an IP address at all. The interface name is passed in $interface, and the media type in $medium.


⭐ (the initial-binding one β€” the BOUND reason) ⭐

The DHCP client has done an initial binding to a new address. The new ip address is passed in $new_ip_address, and the interface name is passed in $interface. The media type is passed in $medium. Any options acquired from the server are passed using the option name described in dhcp-options, except that dashes (´-´) are replaced by underscores (´_´) in order to make valid shell variables, and the variable names start with new_. So for example, the new subnet mask would be passed in $new_subnet_mask. Options from a non-default universe will have the universe name prepended to the option name, for example $new_dhcp6_server_id. The options that the client explicitly requested via a PRL or ORO option are passed with the same option name as above but prepended with requested_ and with a value of 1, for example requested_subnet_mask=1. No such variable is defined for options not requested by the client or options that don't require a request option, such as the ip address (*_ip_address) or expiration time (*_expire). no cap 🧚

Before actually configuring the address, dhcpcanon-script should somehow ARP for it and exit with a nonzero status if it receives a reply. In that case, the client will send a DHCPDECLINE message to the server and acquire a different address. This may also be done in the RENEW, REBIND, or REBOOT states, but it is not required, and indeed may not be desirable. πŸ™ˆ

When a binding has been completed, a lot of network parameters are likely to need to be set up. A new /etc/resolv.conf needs to be created, using the values of $new_domain_name and $new_domain_name_servers (which may list more than one server, separated by spaces). A default route should be set using $new_routers, and static routes may need to be set up using $new_static_routes.

If an IP alias has been declared, it must be set up here. The alias IP address will be written as $alias_ip_address, and other DHCP options that are set for the alias (e.g., subnet mask) will be passed in variables named as described previously except starting with $alias_ instead of $new_.

careful bestie: the alias IP address should not be used if it is identical to the bound IP address ($new_ip_address), since the other alias parameters may be incorrect in this case. πŸ’€

⭐ RENEW ⭐

When a binding has been renewed, the script is called as in BOUND, except that in addition to all the variables starting with $new_, and $requested_ there is another set of variables starting with $old_.

Persistent settings that may have changed need to be deleted β€” for example, if a local route to the bound address is being configured, the old local route should be deleted. If the default route has changed, the old default route should be deleted. If the static routes have changed, the old ones should be deleted. Otherwise, processing can be done as with BOUND. out with the old, in with the new ✨


⭐ REBIND ⭐

The DHCP client has rebound to a new DHCP server. This can be handled as with RENEW, except that if the IP address has changed, the ARP table should be cleared. 🧹


⭐ REBOOT ⭐

The DHCP client has successfully reacquired its old address after a reboot. This can be processed as with BOUND. welcome back, bestie 🫢


⭐ EXPIRE ⭐

The DHCP client has failed to renew its lease or acquire a new one, and the lease has expired. The IP address must be relinquished, and all related parameters should be deleted, as in RENEW and REBIND. 😭


⭐ FAIL ⭐

The DHCP client has been unable to contact any DHCP servers, and any leases that have been tested have not proved to be valid. The parameters from the last lease tested should be deconfigured. This can be handled in the same way as EXPIRE.


⭐ STOP ⭐

The dhcpcanon has been informed to shut down gracefully, the dhcpcanon-script should unconfigure or shutdown the interface as appropriate.


⭐ RELEASE ⭐

The dhcpcanon has been executed using the -r flag, indicating that the administrator wishes it to release its lease(s). dhcpcanon-script should unconfigure or shutdown the interface.


⭐ NBI ⭐

No-Broadcast-Interfaces…dhcpcanon was unable to find any interfaces upon which it believed it should commence DHCP. What dhcpcanon-script should do in this situation is entirely up to the implementor. you're on your own, girl πŸ’€


⭐ TIMEOUT ⭐

The usual way to test a lease is to set up the network as with REBIND (since this may be called to test more than one lease) and then ping the first router defined in $routers. If a response is received, the lease must be valid for the network to which the interface is currently connected. It would be more complete to try to ping all of the routers listed in $new_routers, as well as those listed in $new_static_routes, but current scripts do not do this. it's giving "good enough" energy ngl πŸ“


πŸ¦‹ FILES πŸ¦‹

Each operating system should generally have its own script file, although the script files for similar operating systems may be similar or even identical. The script files included in Internet Systems Consortium DHCP distribution appear in the distribution tree under client/scripts, and bear the names of the operating systems on which they are intended to work.


πŸ’€ BUGS πŸ’€

If more than one interface is being used, there's no obvious way to avoid clashes between server-supplied configuration parameters β€” for example, the stock dhcpcanon-script rewrites /etc/resolv.conf. If more than one interface is being configured, /etc/resolv.conf will be repeatedly initialized to the values provided by one server, and then the other. Assuming the information provided by both servers is valid, this shouldn't cause any real problems, but it could be confusing. πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

dhcpcanon(8).


πŸ’œ AUTHOR πŸ’œ

dhcpcanon-script(8) β€” To learn more about Internet Systems Consortium, see https://www.isc.org.


and that's the whole page, bestie πŸŽ€ this was the dhcpcanon-script(8) entry from the System Manager's Manual, and yeah, that footer line at the bottom was just the same dhcpcanon-script(8) name doing a little encore. you're welcome, go touch some grass now 🌸🫢

πŸ“¦ where this page comes from