The patch from #604883 does not help.
The current logic is clear (dhclient-script file):
# current host name is empty, '(none)' or 'localhost' or differs from
new one from DHCP
if [ -z "$current_hostname" ] ||
[ "$current_hostname" = '(none)' ] ||
[ "$current_hostname" = 'localhost' ] ||
[ "$current_hostname" == "$old_host_name" ]; then
if [ "$new_host_name" != "$current_host_name" ]; then
hostname "$new_host_name"
fi
according to bug #667647 and the script:
- old_host_name is the hostname sent by the client to the DHCP server
- current_hostname is the current return value of hostname(1)
- new_host_name is the proposed hostname from DHCP (option 12)
The new hostname is set if one of that conditions are true:
- current_hostname is not set
- current_hostname is "(none)"
- current_hostname is "localhost"
- current_hostname is the same as the old_host_name
mind that current_hostname will be practically always old_host_name.
The bug
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=667647
Is accurate describing it, and the documentation shall be changed, as this is a
misbehavior compared to all the other clients, and compared to the
specification of DHCP.
The patch is rather simple:
--- dhclient-script_old 2023-02-20 08:19:43.000000000 +0000
+++ dhclient-script 2023-09-12 18:08:25.172475371 +0100
@@ -128,7 +128,7 @@
if [ -z "$current_hostname" ] ||
[ "$current_hostname" = '(none)' ] ||
[ "$current_hostname" = 'localhost' ] ||
- [ "$current_hostname" = "$old_host_name" ]; then
+ [ "$current_hostname" != "$old_host_name" ]; then
if [ "$new_host_name" != "$current_host_name" ]; then
hostname "$new_host_name"
fi
The logic would be then that if the hostname is different from the one provided
(not the same) the proposed hostname is used.
Best,