diff options
-rw-r--r-- | docs/netctl.profile.5.txt | 4 | ||||
-rw-r--r-- | src/lib/ip | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/docs/netctl.profile.5.txt b/docs/netctl.profile.5.txt index a50dbed..fe0073e 100644 --- a/docs/netctl.profile.5.txt +++ b/docs/netctl.profile.5.txt @@ -139,6 +139,10 @@ network. In particular, these connection types are +ethernet+, The name of the preferred DHCP client. Supported options are `dhcpcd' and `dhclient'. Defaults to `dhcpcd'. +'DHCPReleaseOnStop=':: + Set to `++yes++' to release the DHCP lease when the profile is + stopped. + 'DhcpcdOptions=', 'DhclientOptions=', 'DhclientOptions6=':: Additional options to be passed to the DHCP client. Do not use this unless you know what you are doing. @@ -177,17 +177,19 @@ ip_set() { # $IP: type of IPv4 configuration # $IP6: type of IPv6 configuration ip_unset() { + local stop="-x" if [[ $IP == "dhcp" ]]; then case ${DHCPClient:-dhcpcd} in dhcpcd) if [[ -f "/run/dhcpcd-$Interface.pid" ]]; then - do_debug dhcpcd -qk "$Interface" >/dev/null + is_yes "${DHCPReleaseOnStop:-no}" && stop="-k" + do_debug dhcpcd -q $stop "$Interface" >/dev/null fi ;; dhclient) if [[ -f "/run/dhclient-$Interface.pid" ]]; then - # Alternatively, use -r instead of -x to also release the lease - do_debug dhclient -q -x "$Interface" -pf "/run/dhclient-$Interface.pid" >/dev/null + is_yes "${DHCPReleaseOnStop:-no}" && stop="-r" + do_debug dhclient -q $stop "$Interface" -pf "/run/dhclient-$Interface.pid" >/dev/null fi ;; esac |