DHCLIENT HOOKS: don't want to work

Colleagues, could you please tell me what I need to do to get dhclient hooks working?

I created the directories /etc/dhclient-enter-hooks and /etc/dhclient-exit-hooks. (That's how they're named in /sbin/dhclient-script. Without the ".d")
Then, I placed a test file in each of them, with the following content:
sh:
#!/bin/sh

# This script will be executed when dhclient enters a new state (e.g., BOUND, RENEW).
# The 'reason' variable indicates the current state.
# The 'interface' variable indicates the network interface.

logger "my_custom_script $reason"

Set the required permissions.
ogogon@devel:/% ls -alg /etc/dhclient-enter-hooks/test /etc/dhclient-exit-hooks/test
-rwxr-xr-x 1 wheel 245 Oct 12 02:24 /etc/dhclient-enter-hooks/test
-rwxr-xr-x 1 wheel 120 Oct 12 02:24 /etc/dhclient-exit-hooks/test


I ran the files manually - entries appeared in /var/log/messages.

In theory, everything should work automatically.

I plugged a USB Wi-Fi adapter into the computer and connected it to the base.
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=0
ether aa:bb:cc:dd:ee:ff
inet 192.168.2.112 netmask 0xffffff00 broadcast 192.168.2.255
groups: wlan
ssid XXXXXXXX channel 3 (2422 MHz 11g ht/20) bssid ff:ee:dd:cc:bb:aa
regdomain FCC country US authmode WPA2/802.11i privacy ON
deftxkey UNDEF TKIP 2:128-bit TKIP 3:128-bit txpower 30 bmiss 7
scanvalid 60 protmode CTS ht20 ampdulimit 64k ampdudensity 8 -stbc
-ldpc -uapsd wme roaming MANUAL
parent interface: run0
media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
status: associated
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>


It receives network settings via DHCP.
670 - Is 0:00.01 dhclient: system.syslog (dhclient)
673 - Is 0:00.01 dhclient: wlan0 [priv] (dhclient)
735 - ICs 0:00.01 dhclient: wlan0 (dhclient)


Theoretically, while the interface is receiving its lease, the hooks should be triggered, and I imagine more than once.

After rebooting the machine, the interface initializes normally, but there's no sign of any test hooks.

Did I do something wrong, or has this mechanism been inactive for a long time?

I'd appreciate any answers to my question,
Ogogon.
 
I created the directories /etc/dhclient-enter-hooks and /etc/dhclient-exit-hooks.
/etc/dhclient-enter-hooks and /etc/dhclient-exit-hooks are not directories in which scripts can be stored, these are the scripts for defining $reason.

dhclient-script(8)
Rich (BB code):
OPERATION
     ...
     Before taking action according to $reason, dhclient-script will check for
     the existence of /etc/dhclient-enter-hooks.  If found, it will be sourced
     (see sh(1)).  After taking action according to $reason, dhclient-script
     will check for the existence of /etc/dhclient-exit-hooks.  If found, it
     will be sourced (see sh(1)).  These hooks scripts can be used to
     dynamically modify the environment at appropriate times during the DHCP
     negotiations.  For example, if the administrator wishes to disable alias
     IP numbers on the DHCP interface, they might want to put the following in
     /etc/dhclient-enter-hooks:

           [ ."$reason" = .PREINIT ] && ifconfig $interface 0.0.0.0

dumpon(8)
Rich (BB code):
EXAMPLES
     ...
     The dumpon rc(8) script runs early during boot, typically before
     networking is configured.  This makes it unsuitable for configuring
     netdump(4) when the client address is dynamic.  To configure netdump(4)
     when dhclient(8) binds to a server, dhclient-script(8) can be used to run
     dumpon(8).  For example, to automatically configure netdump(4) on the
     vtnet0 interface, add the following to /etc/dhclient-exit-hooks.

     case $reason in
     BOUND|REBIND|REBOOT|RENEW)
             if [ "$interface" != vtnet0 ] || [ -n "$old_ip_address" -a \
                  "$old_ip_address" = "$new_ip_address" ]; then
                     break
             fi
             if [ -n "$new_routers" ]; then
                     # Take the first router in the list.
                     gateway_flag="-g ${new_routers%% *}"
             fi
             # Configure as the highest-priority dump device.
             dumpon -i 0 -c $new_ip_address -s $server $gateway_flag vtnet0
             ;;
     esac
 
Back
Top