dhcpcanon-script(8) | System Manager's Manual | dhcpcanon-script(8) |
NAME¶
dhcpcanon-script - DHCP client network configuration scriptDESCRIPTION¶
The DHCP client network configuration script is invoked from time to time by dhcpcanon(8). This script is used by the dhcp client to set each interface's initial configuration prior to requesting an address, to test the address once it has been offered, and to set the interface's final configuration once a lease has been acquired. If no lease is acquired, the script is used to test predefined leases, if any, and also called once if no valid lease can be identified.This script is not meant to be customized by the end user. If local customizations are needed, they should be possible using the enter and exit hooks provided (see HOOKS for details). These hooks will allow the user to override the default behaviour of the client in creating a /etc/resolv.conf file.
No standard client script exists for some operating systems, even though the actual client may work, so a pioneering user may well need to create a new script or modify an existing one.
HOOKS¶
When it starts, the client script first defines a shell function, make_resolv_conf , which is later used to create the /etc/resolv.conf file. To override the default behaviour, redefine this function in the enter hook script.On after defining the make_resolv_conf function, the client script checks for the presence of an executable ETCDIR/dhcpcanon-enter-hooks script, and if present, it invokes the script inline, using the Bourne shell ´.´ command. The entire environment documented under OPERATION is available to this script, which may modify the environment if needed to change the behaviour of the script. If an error occurs during the execution of the script, 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.
After all processing has completed, CLIENTBINDIR/dhcpcanon-script checks for the presence of an executable ETCDIR/dhcpcanon-exit-hooks script, which if present is invoked using the ´.´ command. The exit status of dhcpcanon-script will be passed to dhcpcanon-exit-hooks in the exit_status shell variable, and will always be zero if the script succeeded at the task for which it was invoked. The rest of the environment as described previously for dhcpcanon-enter-hooks is also present. 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. The following reasons are currently defined: 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.PREINIT¶
The DHCP client is requesting that an interface be configured as required in order to send packets prior to receiving an actual address. For clients which 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 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).
Before actually configuring the address, dhcpcanon-script should somehow ARP for it and exit with a nonzero status if it receives a reply. In this 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 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_. Care should be taken that the alias IP address 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.