Dhcp renewal after wakeup: Difference between revisions

From SlackWiki
Jump to navigation Jump to search
(dhcp renew after sleep tip)
 
No edit summary
 
Line 11: Line 11:
case "$1" in
case "$1" in
         hibernate|suspend)
         hibernate|suspend)
                 ;;
                dhcpcd -k eth0
                 ;;
         thaw|resume)
         thaw|resume)
                 dhcpcd -n
                 dhcpcd eth0
                 ;;  
                 ;;
         *) exit $NA
         *) exit $NA
                 ;;  
                 ;;
esac
esac
</pre>
</pre>


The script probably needs to be executable.
The script probably needs to be executable.

Latest revision as of 15:39, 28 November 2010


Sometimes you need a new IP address after waking up from sleep/standby/hibernate modes. Network managers like Wicd can do this and are recommended for laptops, but you can use the pm-utils triggers yourself without installing and running more software too. The following script works for me:

#!/bin/sh
#
# put this to:  /usr/lib64/pm-utils/sleep.d/05DhcpcdRenew
# /usr/lib/pm-utils/ .. on 32-bit systems

case "$1" in
        hibernate|suspend)
                dhcpcd -k eth0
                ;;
        thaw|resume)
                dhcpcd eth0
                ;;
        *) exit $NA
                ;;
esac

The script probably needs to be executable.