Hello All,<br><br>I'm having troubles getting my dhclient to exit gracefully when the interface has not yet been configured with an IP address.<br><br>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.<br>
<br>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!<br><br>~Dallas<br><br>===============<br><br>Here is a snippet of the script file which performs these actions:<br>
<br>DHCP_CONF_FILE="/tmp/dhclient.${IFACE_NAME}.conf"<br>DHCP_PID_FILE="/tmp/dhclient.${IFACE_NAME}.pid"<br>DHCP_LEASE_FILE="/tmp/dhclient.${IFACE_NAME}.leases"<br>DHCP_SCRIPT="/etc/dhclient-script"<br>
<br>linkup()<br>{<br> if [ x$IFACE_NAME != x ]; then<br> if [ $DHCP_ENABLED -eq 1 ]; then<br> # Create DHCP configuration file<br> echo "interface \"$IFACE_NAME\" {" > $DHCP_CONF_FILE<br>
echo "}" >> $DHCP_CONF_FILE<br> # Start an instance of the DHCP daemon for this interface<br> dhclient -nw -pf $DHCP_PID_FILE -lf $DHCP_LEASE_FILE \<br> -cf $DHCP_CONF_FILE -sf $DHCP_SCRIPT $IFACE_NAME<br>
else # DHCP is disabled<br> ifconfig $IFACE_NAME $IP_ADDRESS netmask $NETMASK <br> fi<br> fi<br>}<br><br>linkdown()<br>{<br> if [ x$IFACE_NAME != x ]; then<br> if [ $DHCP_ENABLED -eq 1 ]; then<br>
dhclient -x -pf $DHCP_PID_FILE -lf $DHCP_LEASE_FILE \<br> -cf $DHCP_CONF_FILE -sf $DHCP_SCRIPT $IFACE_NAME<br> if [ $? -eq 0 ]; then<br> while [ -f "$DHCP_PID_FILE" ]; do<br> sleep 1<br>
done<br> rm $DHCP_LEASE_FILE<br> fi<br> fi<br> fi<br>}<br>