Changing the hostname

  • Cloud-Init requires additional steps to ensure that the host name is not changed to the default setting the next time the system is rebooted.

    Since Cloud-Init constantly checks the configuration of the server and corrects it in case of doubt, the service must be deactivated for corresponding local changes.

    1. Edit the configuration file:
      nano /etc/cloud/cloud.cfg
    2. The values of the parameters "preserve_hostname" and "manage_etc_hosts" must be changed as followed:
      preserve_hostname: true manage_etc_hosts: false
    3. Now the hostname can be edited:
      nano /etc/hostname
    4. To ensure a correct resolution of the hostname, the entry in the hosts file must also be updated
      nano /etc/hosts
      A corresponding entry would look like this
      <IP of the server> <Full Qualified Domain Name> (
    5. Finally, the system must be restarted.
    6. Now you should use hostname -f to check if the changes have taken effect.