Skip to main content

Hostname Changes and Related OS Configuration

This guide covers procedures that are often raised as troubleshooting questions but are really one-time OS configuration tasks — most commonly changing the hostname so it persists across reboots, or replacing the default rules on a custom image.

Common Hostname Issues

IssueWhat to do
Hostname reverts to the old value after rebootThe OpenNebula context script 05-hostname (or net-15-hostname on KVM) is still in /etc/one-context.d/. Move it to /root/.
hostnamectl set-hostname reports success but commands still show the old nameOpen a new shell, or run exec bash — the new name applies to new sessions.
cPanel still shows the old hostnamecPanel maintains its own hostname store. Update via WHM → Networking Setup → Change Hostname after fixing the OS hostname.
Hostname change broke service startupSome services bind to or log the hostname at start. Restart the affected service, or revert the hostname and plan a maintenance window for the change.

Changing a Linux Virtual Compute Node's Hostname

A naive hostname change does not persist across reboots on E2E Linux nodes — the OpenNebula context package resets the hostname from the original boot configuration. To make the change permanent, you must also move the context-managed hostname script out of its directory.

Step 1: Log In as Root

Connect to a Linux node as root.

Step 2: Check and Change the Hostname

Check the current hostname:

hostname

Apply a new hostname for the running session:

hostnamectl set-hostname new-hostname

Step 3: Update the Hostname File (CentOS)

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

vi /etc/hostname

Step 4: Update the /etc/hosts File

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

vi /etc/hosts

Save and exit.

Step 5: Make the Change Permanent

The change so far survives until the next reboot — at which point the OpenNebula context package's 05-hostname script will overwrite it. To prevent that, move the script out of the context directory:

cd /etc/one-context.d/

List the contents:

ls -la

For most VMs, move 05-hostname:

mv 05-hostname /root/

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

mv net-15-hostname /root/

After the move, the hostname change survives reboots.

Changing a cPanel Server's Hostname

cPanel keeps its own copy of the hostname. After the steps above:

  1. Use WHM → Networking Setup → Change Hostname to update the cPanel-side hostname.

  2. Add the following lines to /etc/sysctl.conf:

    kernel.hostname = hostname.domainname.com
    kernel.domainname = domainname.com
  3. Apply:

    sysctl -p /etc/sysctl.conf

Installing Node.js and npm on CentOS / RHEL

A common follow-up to launching a CentOS or RHEL-compatible node is installing Node.js. Use the package source that matches your OS lifecycle and application requirements. The old Node.js 6.x setup scripts are obsolete and should not be used for new deployments.

Step 1 — Check the available package stream or repository:

dnf module list nodejs

Step 2 — Install Node.js and npm:

dnf install -y nodejs npm

On older CentOS images that still use yum, use the OS-supported repository or an approved NodeSource LTS repository, then install:

yum install -y nodejs npm

Step 3 — Verify versions:

node -v
npm -v

Step 4 — Test the installation:

Create a test server file:

vim test_server.js

Add the following:

var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Welcome');
}).listen(3001, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3001/');

Start the server:

node test_server.js

Expected output:

Server running at http://127.0.0.1:3001/

Access http://127.0.0.1:3001/ from inside the node to confirm.


Last updated on May 19, 2026.