Cloud-Based Hostname Workaround

It’s very common these days for hosting providers to offer cloud-based hosting solutions to their customers. In configuring these servers ourselves, and in interactions with our customers’ servers, an issue has come to our attention where the dhclient script does not preserve locally-configured hostnames. This means that hostnames configured on the command line might not remain through a reboot. We wante to provide a workaround solution for this while continuing to investigate a more permanent, long-term solution. What …

Spread the love

It’s very common these days for hosting providers to offer cloud-based hosting solutions to their customers. In configuring these servers ourselves, and in interactions with our customers’ servers, an issue has come to our attention where the dhclient script does not preserve locally-configured hostnames. This means that hostnames configured on the command line might not remain through a reboot. We wante to provide a workaround solution for this while continuing to investigate a more permanent, long-term solution.

What is the issue?

For many cloud hosting providers, configuring automated deployments is done by invoking the dhclient script at boot-time, which includes configuring the server’s hostname incorrectly. Commonly, hosting providers will use additional scripting to work around this issue. For example, Google Cloud Engine uses the google_set_hostname script.

However, this solution creates a new problem: these scripts may interfere with WHM’s Change Hostname feature (WHM >> Home >> Networking Setup >> Change Hostname). If your hostname is set in WHM to something that conflicts with the hostname set by the dhclient script, there will be problems in cPanel & WHM, up to and including the invalidation of the server’s cPanel Software license.

The workaround

To resolve this issue, you must create a dhclient exit hook script, which will then set the hostname properly at boot-time. You first create a script like the one below, which we have named set-hostname.sh, in the /etc/dhcp/dhclient-exit-hooks.d/ directory. In this example, replace hostname.example.com with your desired server hostname:

You can also use the below command to create the script, input the proper information, and set the file’s permissions correctly. Make sure to replace hostname.example.com with your desired 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/set-hostname.sh && chmod +x /etc/dhcp/dhclient-exit-hooks.d/set-hostname.sh

If you have any further questions or concerns, comment below, or reach out to us via our Slack or Discord channels, or join the discussion on the Official cPanel & WHM Subreddit!

Facebook Comments

More Stuff

Tomcat 7, it’s Nearly Here EasyApache 3.20 Impending Release We are proud to announce the impending release of EasyApache 3.20, which includes the long-awaited Tomcat version 7....
Maintaining Application Compatibility With version 11.28 of cPanel & WHM making it’s way into the production update tiers, now is a great time to discuss your application testing strat...
May 2017 Development Update With version 64 in the STABLE tier, we’re getting more and more time to work on what’s next. Let’s talk about some of the stuff that you can test righ...
Fast Install Mode: Install cPanel & WHM in record time! A few months ago, we posted about our plans to speed up the cPanel & WHM installer. We are excited to announce that in cPanel & WHM version 1...
Spread the love

Posted by News Monkey