Cloud-Hosted Hostname Solution


Overview

To configure VPS deployments, many cloud hosting providers use the dhclient script, which includes the configuration of the instance’s hostname.

The dhclient script may not preserve the locally-configured hostname, so hosting providers use scripts to work around this issue. For example, the Google Cloud Platform™ service uses the google_set_hostname script.

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.

The solution

To resolve this issue, you must create a dhclient exit hook script to set the hostname properly.

Create the zzz-set-hostname file with the following contents in the /etc/dhcp/dhclient-exit-hooks.d/ directory, where hostname.example.com represents your server’s new hostname:

#!/bin/sh
hostname hostname.example.com
/scripts/fixetchosts

You can also create the file with the following command, where hostname.example.com represents your server’s new hostname:

mkdir -p /etc/dhcp/dhclient-exit-hooks.d/ && echo -ne '#!/bin/sh\nhostname hostname.example.com\n/scripts/fixetchosts\n' > /etc/dhcp/dhclient-exit-hooks.d/zzz-set-hostname && chmod +x /etc/dhcp/dhclient-exit-hooks.d/zzz-set-hostname
Warning:

Make certain that you set the zzz-set-hostname file with 0755 permissions. If you don’t perform this action, the script won’t run.


Did you find this article useful?



  • What Is Cpanel?

    cPanel, short for "control panel," is a web-based graphical interface that simplifies and streamlines the management of web hosting servers and websit...

  • How To Update DNS Settings in Cpanel?

    cPanel, a popular web hosting control panel, makes it easy for website owners and administrators to update DNS settings for their domains. Whether you...

  • Account Creation Errors

    Overview This document contains common account creation errors and the steps to troubleshoot them. Note: For more information about account creation...

  • Account Suspension Versus Bandwidth Limiting and Account Termination

    Overview This document explains the differences between account suspension, bandwidth limiting, and account termination. This document also describes ...

  • Addon Domain Conversion List

    Overview The following lists contain a brief overview of the data that the Convert Addon Domain to Account interface (WHM » Home »...