Problems with graceful shutdown of dhclient
Dallas Clement
dallas at clementkin.com
Wed Apr 15 13:29:02 UTC 2009
Hello All,
I'm having troubles getting my dhclient to exit gracefully when the
interface has not yet been configured with an IP address.
The computer which is running dhclient is attached to an ethernet switch.
When the link is up, I start dhclient. However, there is no DHCP server
attached to this switch and hence dhclient fails to get a lease. If I pull
out my ethernet cable forcing the link down, I try to gracefully stop
dhclient. For some reason neither the -x or -r options are working for me.
The dhclient -x returns 0 -- which I am assuming means success. However,
the dhclient daemon process continues to execute and does not remove its PID
file.
Is the -x option only applicable after a lease has been obtained? Maybe I'm
doing something stupid, but it's not obvious to me. Any help greatly
appreciated!
~Dallas
===============
Here is a snippet of the script file which performs these actions:
DHCP_CONF_FILE="/tmp/dhclient.${IFACE_NAME}.conf"
DHCP_PID_FILE="/tmp/dhclient.${IFACE_NAME}.pid"
DHCP_LEASE_FILE="/tmp/dhclient.${IFACE_NAME}.leases"
DHCP_SCRIPT="/etc/dhclient-script"
linkup()
{
if [ x$IFACE_NAME != x ]; then
if [ $DHCP_ENABLED -eq 1 ]; then
# Create DHCP configuration file
echo "interface \"$IFACE_NAME\" {" > $DHCP_CONF_FILE
echo "}" >> $DHCP_CONF_FILE
# Start an instance of the DHCP daemon for this interface
dhclient -nw -pf $DHCP_PID_FILE -lf $DHCP_LEASE_FILE \
-cf $DHCP_CONF_FILE -sf $DHCP_SCRIPT $IFACE_NAME
else # DHCP is disabled
ifconfig $IFACE_NAME $IP_ADDRESS netmask $NETMASK
fi
fi
}
linkdown()
{
if [ x$IFACE_NAME != x ]; then
if [ $DHCP_ENABLED -eq 1 ]; then
dhclient -x -pf $DHCP_PID_FILE -lf $DHCP_LEASE_FILE \
-cf $DHCP_CONF_FILE -sf $DHCP_SCRIPT $IFACE_NAME
if [ $? -eq 0 ]; then
while [ -f "$DHCP_PID_FILE" ]; do
sleep 1
done
rm $DHCP_LEASE_FILE
fi
fi
fi
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20090415/2d5bb718/attachment.html>
More information about the dhcp-users
mailing list