Changing the hostname of an instance

The cloud-init program not only lets you configure your Public Cloud instance when you create it but also each time you reboot. Therefore, if you want to reconfigure your hostname, whether due to an error when creating your instance, or because you need to reconfigure your mail server for example, you will need to disable the cloud-init program that configures the hostname, to prevent it from being reset.

This guide explains how to reconfigure cloud-init so that you can change your instance hostname.

Prerequisites

  • An instance

Disabling the cloud-init program

  • Edit the configuration file:
[email protected]:~$ sudo vim /etc/cloud/cloud.cfg
  • Edit the status of these modules:
preserve_hostname: true
manage_etc_hosts: false

Changing the host name

  • Edit the /etc/hostname file:
[email protected]:~$ sudo vim /etc/hostname

webserver
  • Edit the /etc/hosts file:
[email protected]:~$ sudo vim /etc/hosts

127.0.1.1 webserver.localdomain webserver
127.0.0.1 localhost
  • Reboot the instance
[email protected]:~$ sudo reboot

Following the reboot the host name change has been correctly registered:

[email protected]:~$ sudo cat /etc/hosts

127.0.1.1 webserver.localdomain webserver
127.0.0.1 localhost
 
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Become root and select a password

To carry out certain actions, you may need to become root. These include: Installing...

Create an instance in your customer account

The Public Cloud lets you create virtual servers (instances) quickly and easily in just a few...

Logging in to Public Cloud Instance

Objective Logging in to your Public Cloud instance is similar to a standard login for a VPS or...

Install Wordpress on an instance

WordPress is a content management system (CMS) which lets you create your website quickly and...

Create and configure an additional disk on an instance

It is possible to create additional disks for your Public Cloud instances. This can be useful in...