Symptoms
On Google Cloud Platform, the system hostname is changed either on boot or after some time. This can cause license errors.
Description
The dhclient
script may not preserve the locally configured hostname, so hosting providers use scripts to work around this issue. For example, Google Cloud Platform Services™ uses the google_set_hostname
script.
Workaround
Please note that the following workaround scripts may interfere with WHM's "Change Hostname" feature, which causes hostname configuration issues and a locked cPanel & WHM license.
- Access the server's command line as the 'root' user via SSH or "Terminal" in WHM.
- Create the
/etc/dhcp/dhclient-exit-hooks.d
directory.mkdir -p /etc/dhcp/dhclient-exit-hooks.d/
- Create the
zzz-set-hostname.sh
file.touch /etc/dhcp/dhclient-exit-hooks.d/zzz-set-hostname.sh
- Open
zzz-set-hostname.sh
in your preferred text editor. - Add the following information.
#!/bin/sh
Please note that "$host.domain.tld" must be replaced with the server's hostname.
hostname $host.domain.tld
/scripts/fixetchosts - Save the changes and exit the text editor.
- Set the executable permission on
zzz-set-hostname.sh
.chmod +x /etc/dhcp/dhclient-exit-hooks.d/zzz-set-hostname.sh
Please note that on Ubuntu servers, the file name must be "zzz-set-hostname," not "zzz-set-hostname.sh." - If your server uses NetworkManager, add "hostname-mode=none" under the "[main]" section of the /etc/NetworkManager/NetworkManager.conf file as below.
[main]
hostname-mode=none