Dhcp renewal after wakeup

From SlackWiki
Jump to navigation Jump to search


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.