Package: isc-dhcp-client Version: 4.3.1-6+deb8u2 Severity: normal Tags: patch
When using the initrd system 'dracut', its built-in dhclient-script.sh sets IPv4 address lifetimes using the 'ip addr ... valid_lft n preferred_lft n' syntax [2]. The Debian dhclient-script.linux does not maintain IPv4 address lifetimes, so the dracut-assigned lifetimes eventually expire, and the address(es) are unexpectedly removed from the interfaces. Fedora/RedHat/CentOS's dhclient-script does maintain lifetimes [2], added in [3] and [4]. The attached patch ports the above IPv4 changes from Fedora's solution, to Debian's dhclient-script. It applies to the current master of [5]. A problem remains: If dhclient is terminated and started again, it starts with reason=REBOOT and attempts to do a 'ip -4 addr add ...'. Since the address is still configured on the interface, this results in 'RTNETLINK answers: File exists', and the lifetimes are not reset. If the lifetimes expire before the DHCP renew hits, the address(es) are removed from the interface. This should probably be fixed in a separate issue. [1]: Bug 1058519 - Should set address lifetimes in dhclient-script.sh https://bugzilla.redhat.com/show_bug.cgi?id=1058519 [2]: Bug 1032809 - dhclient-script: set address lifetimes https://bugzilla.redhat.com/show_bug.cgi?id=1032809 [3]: dhclient-script: set address lifetimes (#1032809) https://github.com/vaijab/fedora-dhcp/commit/e3ee5b17e9ffb46b1476ef97f532d6b81f2615dc [4]: update address lifetimes on RENEW/RENEW6 (#1032809) https://github.com/vaijab/fedora-dhcp/commit/543c1a58140be99fcd528a505ccdee7f4aaec535 [5]: git://anonscm.debian.org/pkg-dhcp/isc-dhcp.git
>From 60a6b8282bd145a6caa2e0451d5f777d01642e45 Mon Sep 17 00:00:00 2001 From: Sven Ulland <sve...@opera.com> Date: Tue, 16 Aug 2016 20:32:04 +0200 Subject: [PATCH] dhclient-script.linux: Set IPv4 address lifetime Set and maintain IPv4 address lifetimes so that they correspond with the DHCP lease. This patch is an adaption of the Fedora implementation [1,2]. [1]: dhclient-script: set address lifetimes (#1032809) https://github.com/vaijab/fedora-dhcp/commit/e3ee5b17e9ffb46b1476ef97f532d6b81f2615dc [2]: update address lifetimes on RENEW/RENEW6 (#1032809) https://github.com/vaijab/fedora-dhcp/commit/543c1a58140be99fcd528a505ccdee7f4aaec535 --- debian/dhclient-script.linux | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/debian/dhclient-script.linux b/debian/dhclient-script.linux index 4eabdd5..68c008d 100644 --- a/debian/dhclient-script.linux +++ b/debian/dhclient-script.linux @@ -217,6 +217,8 @@ case "$reason" in # new IP has been leased or leased IP changed => set it ip -4 addr add ${new_ip_address}${new_subnet_mask:+/$new_subnet_mask} \ ${new_broadcast_address:+broadcast $new_broadcast_address} \ + ${new_dhcp_lease_time:+valid_lft $new_dhcp_lease_time} \ + ${new_dhcp_lease_time:+preferred_lft $new_dhcp_lease_time} \ dev ${interface} label ${interface} if [ -n "$new_interface_mtu" ]; then @@ -248,6 +250,12 @@ case "$reason" in fi done fi + else # RENEW||REBIND + ip -4 addr change ${new_ip_address}${new_subnet_mask:+/$new_subnet_mask} \ + ${new_broadcast_address:+broadcast $new_broadcast_address} \ + ${new_dhcp_lease_time:+valid_lft $new_dhcp_lease_time} \ + ${new_dhcp_lease_time:+preferred_lft $new_dhcp_lease_time} \ + dev ${interface} label ${interface} fi if [ -n "$alias_ip_address" ] && @@ -294,6 +302,8 @@ case "$reason" in # set IP from recorded lease ip -4 addr add ${new_ip_address}${new_subnet_mask:+/$new_subnet_mask} \ ${new_broadcast_address:+broadcast $new_broadcast_address} \ + ${new_dhcp_lease_time:+valid_lft $new_dhcp_lease_time} \ + ${new_dhcp_lease_time:+preferred_lft $new_dhcp_lease_time} \ dev ${interface} label ${interface} if [ -n "$new_interface_mtu" ]; then -- 2.1.4