Changing the Hostname
... / Changing the Hostname
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Question

Changing the Hostname

by
ilyabakhlinlebedev
Created on 2024-06-06 15:42:35 (edited on 2024-09-04 14:23:31) in Compute

Hello, OVH Community.

I've got a brand new VPS and I'm setting everything up.

However, I've found myself in a little trouble, when trying to rename my VPS' hostname.

I've followed the following steps:

1. Follow this guide and edit the `/etc/cloud/cloud.cfg` file, adding and changing the following lines:

```
preserve_hostname: true
manage_etc_hosts: false
```

2. Use the `hostnamectl` command as follows:

```
hostnamectl set-hostname subdomain.domain.tld
```

3. Edit the `/etc/hosts` file accordingly.

However, after a reboot, if I access the `/etc/hosts` file, it preserves all the changes, but keeps adding the following line:

```
127.0.1.1 vps-XXXXXXXX.vps.ovh.net vps-XXXXXXXX
```

What is the precise procedure to rename your virtual private server?

Regards.


1 Reply ( Latest reply on 2025-04-29 14:25:56 by
LF
)

Hi,

  1. comment out the '-update_etc_hosts' parameter in the '/etc/cloud/cloud.cfg' file .
  2. Use the `hostnamectl` command as follows: hostnamectl set-hostname [hostname.domain]
  3. edit the `/etc/hosts`

that's how it works for me.

Tested on almalinux and centos.