Skip to content

Troubleshooting hostname and OS configuration

View as Markdown

Three things come up after launching a node: a hostname that reverts after a reboot, a cPanel server that shows the old hostname, and installing Node.js and npm on CentOS or RHEL. All are ordinary Linux administration tasks. They work the same on any provider.

You change the hostname, reboot, and it is back to the old value. On E2E Linux nodes this happens because the OpenNebula context package resets the hostname from the original boot configuration on every boot. A context package is a small set of scripts E2E’s images run at boot to configure the node, its network, hostname, and credentials, from the settings it was created with. The script that does this is 05-hostname (or net-15-hostname on KVM servers), and it is still in the directory /etc/one-context.d/. To make your change permanent, move that script out of the directory.

Log into the node as root first. See Connect to a Linux node.

Check the current hostname:

hostname

Apply the new hostname to the running session. Replace new-hostname with the name you want:

hostnamectl set-hostname new-hostname

Edit /etc/hostname and replace the old hostname with the new one:

vi /etc/hostname

Edit /etc/hosts and update the entries that still name the old hostname:

vi /etc/hosts

Save and exit both files. Now stop the context script from undoing your work on the next reboot. Move the hostname script out of the context directory:

cd /etc/one-context.d/

List the contents so you can see which script is present:

ls -la

For most VMs, move 05-hostname:

mv 05-hostname /root/

For a KVM-based server, the equivalent script is named net-15-hostname:

mv net-15-hostname /root/

Once the script is moved, the hostname survives reboots. The change will not take full effect on the running system until you reboot or restart the affected services.

New hostname does not show in the terminal

Section titled “New hostname does not show in the terminal”

You ran hostnamectl set-hostname and it reported success, but the prompt still shows the old name. That is expected: the new name applies to new sessions, not the one you are already in. Open a new shell, or refresh the current one:

exec bash

Your prompt now shows the new hostname.

Some services bind to or log the hostname when they start. If a service fails to start after you change the hostname, restart the affected service. If it still will not start, revert the hostname and plan a maintenance window for the change, then apply it when you can restart the services that depend on it.

cPanel keeps its own copy of the hostname, separate from the one the operating system uses. If you changed the OS hostname but cPanel still shows the old one, update cPanel’s copy after you fix the OS side. In WHM, go to Networking Setup → Change Hostname and enter the new hostname.

To make the change stick across reboots, add the hostname and domain name to /etc/sysctl.conf. Open it:

vi /etc/sysctl.conf

Add lines naming your full hostname and its domain, replacing the example values:

kernel.hostname = hostname.domainname.com
kernel.domainname = domainname.com

Apply the settings:

sysctl -p /etc/sysctl.conf

cPanel now uses the hostname you set.

Installing Node.js and npm on CentOS or RHEL

Section titled “Installing Node.js and npm on CentOS or RHEL”

A common follow-up to launching a CentOS or RHEL node is installing Node.js to run an application. It is a straightforward install from your distribution’s package source; see Install Node.js and npm for the full steps, including how to confirm the install works with a small test server.

If a change here leaves the node unreachable, see Troubleshooting node networking and connectivity.