| 1 |
The /etc/dhcp/dhclient.d directory allows other packages and system
|
| 2 |
administrators to create application-specific option handlers for dhclient.
|
| 3 |
|
| 4 |
When dhclient is run, any option listed in the dhcp-options(5) man page can
|
| 5 |
be requested. dhclient-script does not handle every option available
|
| 6 |
because doing so would make the script unmaintainable as the components
|
| 7 |
using those options might change over time. The knowledge of how to handle
|
| 8 |
those options should be under the responsibility of the package maintainer
|
| 9 |
for that component (e.g., NTP options belong in a handler in the ntp
|
| 10 |
package).
|
| 11 |
|
| 12 |
To make maintenance easier, application specific DHCP options can be handled
|
| 13 |
by creating a script with two functions and placing it in /etc/dhcp/dhclient.d
|
| 14 |
|
| 15 |
The script must follow a specific form:
|
| 16 |
|
| 17 |
(1) The script must be named NAME.sh. NAME can be anything, but it makes
|
| 18 |
sense to name it for the service it handles. e.g., ntp.sh
|
| 19 |
|
| 20 |
(2) The script must provide a NAME_config() function to read the options and
|
| 21 |
do whatever it takes to put those options in place.
|
| 22 |
|
| 23 |
(3) The script must provide a NAME_restore() function to restore original
|
| 24 |
configuration state when dhclient stops.
|
| 25 |
|
| 26 |
(4) The script must be 'chmod +x' or dhclient-script will ignore it.
|
| 27 |
|
| 28 |
The scripts execute in the same environment as dhclient-script. That means
|
| 29 |
all of the functions and variables available to it are available to your
|
| 30 |
NAME.sh script. Things of note:
|
| 31 |
|
| 32 |
${SAVEDIR} is where original configuration files are saved. Save your
|
| 33 |
original configuration files here before you take the DHCP provided
|
| 34 |
values and generate new files.
|
| 35 |
|
| 36 |
Variables set in /etc/sysconfig/network, /etc/sysconfig/networking/network,
|
| 37 |
and /etc/sysconfig/network-scripts/ifcfg-$interface are available to
|
| 38 |
you.
|
| 39 |
|
| 40 |
See the scripts in /etc/dhcp/dhclient.d for examples.
|
| 41 |
|
| 42 |
NOTE: Do not use functions defined in /sbin/dhclient-script. Consider
|
| 43 |
dhclient-script a black box. This script may change over time, so the
|
| 44 |
dhclient.d scripts should not be using functions defined in it.
|
| 45 |
|
| 46 |
--
|
| 47 |
David Cantrell <dcantrell@redhat.com>
|