From 4f49686ff1c90be31ed25dcca52564675cc8b501 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Wed, 6 Apr 2022 16:46:44 -0500 Subject: [PATCH] Fix dhclient removing the IP address on renew For some reason, `dhclient` fires an *EXPIRE* event every time it renews the DHCP lease, even if the lease has not expired. `dhclient-script` then removes the IP address from the interface, which of course breaks the connection to the NBD server and blocks all reads from the root filesystem. To avoid this strange situation, we need to stop `dhclient-script` acting on the *EXPIRE* event. Luckily, it provides a "hook" mechanism that we can use; since the hook script is dot-sourced, we can just `exit` the process to avoid any further changes in that run. --- overlay/etc/dhcp/dhclient-enter-hooks | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 overlay/etc/dhcp/dhclient-enter-hooks diff --git a/overlay/etc/dhcp/dhclient-enter-hooks b/overlay/etc/dhcp/dhclient-enter-hooks new file mode 100644 index 0000000..c04296e --- /dev/null +++ b/overlay/etc/dhcp/dhclient-enter-hooks @@ -0,0 +1,7 @@ +# Avoid handling the EXPIRE event, which would ordinarily result in the +# IP address being removed from the interface. `dhclient` fires the +# EXPIRE event every time it renews the lease, even if the lease has not +# actually expired. +if [ "${reason}" = EXPIRE ]; then + exit 0 +fi