{"id":646,"date":"2021-07-23T12:34:43","date_gmt":"2021-07-23T12:34:43","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/cloud-hosted-hostname-solution\/"},"modified":"2021-07-23T12:34:43","modified_gmt":"2021-07-23T12:34:43","slug":"cloud-hosted-hostname-solution","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/cloud-hosted-hostname-solution\/","title":{"rendered":"Cloud-Hosted Hostname Solution"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<p>To configure VPS deployments, many cloud hosting providers use the <code>dhclient<\/code> script, which includes the configuration of the instance\u2019s hostname.<\/p>\n<p>The <code>dhclient<\/code> script may not preserve the locally-configured hostname, so hosting providers use scripts to work around this issue. For example, Google Cloud Platform Services\u2122 uses the <code>google_set_hostname<\/code> script.<\/p>\n<p>The workaround scripts may interfere with WHM\u2019s <em>Change Hostname<\/em> feature <em>(WHM &gt;&gt; Home &gt;&gt; Networking Setup &gt;&gt; Change Hostname)<\/em>, which causes hostname configuration issues and a locked cPanel &#038; WHM license.<\/p>\n<h2 id=\"the-solution\">The solution<\/h2>\n<p>To resolve this issue, you <strong>must<\/strong> create a <code>dhclient<\/code> exit hook script to set the hostname properly.<\/p>\n<p>Create the <code>zzz-set-hostname.sh<\/code> file with the following contents in the <code>\/etc\/dhcp\/dhclient-exit-hooks.d\/<\/code> directory, where <code>hostname.example.com<\/code> represents your server\u2019s new hostname:<\/p>\n<pre><code>#!\/bin\/sh\nhostname hostname.example.com\n\/scripts\/fixetchosts\n<\/code><\/pre>\n<p>You can also create the file with the following command, where <code>hostname.example.com<\/code> represents your server\u2019s new hostname:<\/p>\n<pre><code>mkdir -p \/etc\/dhcp\/dhclient-exit-hooks.d\/ && echo -ne '#!\/bin\/shnhostname hostname.example.comn\/scripts\/fixetchostsn' &gt; \/etc\/dhcp\/dhclient-exit-hooks.d\/zzz-set-hostname.sh && chmod +x \/etc\/dhcp\/dhclient-exit-hooks.d\/zzz-set-hostname.sh\n<\/code><\/pre>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n<p>Make <strong>certain<\/strong> that you set the <code>zzz-set-hostname.sh<\/code> file with 0755 permissions. If you don\u2019t perform this action, the script won\u2019t run.<\/p>\n<\/p><\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview To configure VPS deployments, many cloud hosting providers use the dhclient script, which includes the configuration of the instance\u2019s hostname. 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\u2122 uses the google_set_hostname script. The workaround scripts may interfere &hellip;<\/p>\n","protected":false},"author":1,"featured_media":647,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/646"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=646"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/646\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/647"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}