On some Cloud Hosting providers, the system hostname is changed either on boot or after some time. This can cause license errors.
To configure VPS deployments, many cloud hosting providers use the
dhclient script, which includes the configuration of the instance’s hostname.
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
The workaround scripts may interfere with WHM’s Change Hostname feature (WHM > Home > Networking Setup > Change Hostname), which causes hostname configuration issues and a locked cPanel & WHM license.
To resolve this issue, you must create a
dhclient exit hook script to set the hostname properly.
First, create the directory
# mkdir -p /etc/dhcp/dhclient-exit-hooks.d/
Next, create the file, remembering to change the "hostname.example.com" to your server hostname.
# nano /etc/dhcp/dhclient-exit-hooks.d/zzz-set-hostname.sh
Or, optionally, you can skip the text editor and use a one-line command to create the file. Again, be sure to insert your hostname.
# echo -ne '#!/bin/sh\nhostname hostname.example.com\n/scripts/fixetchosts\n' > /etc/dhcp/dhclient-exit-hooks.d/zzz-set-hostname.sh
Finally, once you have created the script with either method, ensure it has the correct permissions:
# chmod +x /etc/dhcp/dhclient-exit-hooks.d/zzz-set-hostname.sh