Change Hostname

The hostname is the name with which the server identifies itself on the network. It should be set correctly especially if the server sends emails or is part of a more complex infrastructure.

02

View current hostname

bash
hostname
hostnamectl
03

Change the hostname

bash
hostnamectl set-hostname new-hostname

The hostname must be a valid name: only letters, numbers and hyphens. No spaces or special characters. If you want to use an FQDN (e.g. server1.example.com):

bash
hostnamectl set-hostname server1.example.com
04

Update /etc/hosts

After changing the hostname, update the /etc/hosts file to avoid slowdowns and warnings:

bash
nano /etc/hosts

Modify the line containing the old hostname. It should be similar to:

127.0.1.1 new-hostname 127.0.1.1 server1.example.com server1

Complete example of /etc/hosts:

127.0.0.1 localhost 127.0.1.1 server1.example.com server1 ::1 localhost ip6-localhost ip6-loopback
05

Verify after change

bash
# Verify short hostname
hostname

# Verify FQDN (fully qualified domain name)
hostname -f

# Verify everything
hostnamectl status
06

Change hostname from VirtFusion panel

You can also change the hostname directly from the panel:

The change from VirtFusion panel updates the hostname at the VM configuration level, but you still need to update /etc/hostname and /etc/hosts inside the server to make the change effective on the OS.

  • Log into VirtFusion panel
  • Select server → Options
  • Find the Hostname field
  • Enter the new hostname and save
07

Hostname and email

If the server sends email, the hostname affects reputation. Always use a hostname that corresponds to a valid DNS record. See: Reverse DNS

The Reverse DNS (PTR record) should match the server's hostname. Example:

  • Hostname: mail.example.com
  • PTR record of IP: mail.example.com
  • A record: mail.example.com → server IP

DeluxHost, founded in 2023, offers high-quality hosting solutions for various digital needs. We provide shared hosting, VPS, and dedicated servers with advanced security and global data centers.

© DeluxHost, All rights reserved. | VAT Number : IT17734661006
All Systems Operational