
When you deploy a new Vultr cloud server, you can set the Server Hostname on the deployment page. Later, if you decide to change the server name, you can use the Change Hostname form in the server's Settings menu.
However, if you use this method to change the hostname, Vultr destroys the cloud server and reinstalls a new operating system image, which wipes all the data on the server.
This guide uses example names: olddog for the old name and newtricks for the new.
This section applies to:
Procedure:
Important: Disable automatic hostname updates from cloud-init by editing /etc/cloud/cloud.cfg.
Change the value of preserve_hostname to true.
Save and exit the file.
Check the current hostname with the hostname command.
You can also use hostnamectl.
Change the hostname to newtricks.
Change any instances of the old hostname in /etc/hosts. If you have a DNS name pointed to this instance, it's also best practice to set that name here.
Example of old hosts file:
Example of new hosts file.
Reboot the server.
Test your change with hostnamectl and hostname.
This section applies to any recently updated version of Arch Linux.
Procedure:
Important: Disable automatic hostname updates from cloud-init by editing /etc/cloud/cloud.cfg.
Change the value of preserve_hostname to true.
Save and exit the file.
Check the current hostname using the hostnamectl tool.
Check the hosts file with the getent tool.
Change the hostname to newtricks.
Change any instances of the old hostname in /etc/hosts. If you have a DNS name pointed to this instance, it's also best practice to set that name here.
Example of old hosts file:
Example of new hosts file:
Either reboot the server or log out and back in again to your user session.
Test the change with the hostnamectl tool.
Test the change with the getent tool.
統 Note: For a system with a permanent IP address, that permanent IP address should be used instead of 127.0.1.1. The order of hostnames in /etc/hosts is significant. The first string is the canonical hostname. Subsequent names on the same line are aliases.
This section applies to:
Procedure:
Important: Disable automatic hostname updates from cloud-init by editing /etc/cloud/cloud.cfg.
Change the value of preserve_hostname to true.
Save and exit the file.
Check the current hostname with the hostname command.
You can also use hostnamectl.
Change the hostname to newtricks.
Change any instances of the old hostname in /etc/hosts. If you have a DNS name pointed to this instance, it's also best practice to set that name here.
Example of old hosts file:
Example of new hosts file.
Reboot the server.
Test your change with hostnamectl and hostname.
Fedora CoreOS (FCOS) uses the Ignition file to set the server hostname. If you decide to rename a running server, you'll need to update the name from the command line.
Connect to your FCOS instance and change to the root user.
Check the hostname with hostname.
You can also use hostnamectl.
Change the hostname to newtricks.
Reboot the server.
Test your change with hostnamectl and hostname.
This section applies to all versions of FreeBSD.
Procedure:
Check the current hostname with the hostname command.
Change the hostname to newtricks using a text editor.
Reboot the server.
Test your change with hostname.
This section applies to all versions of OpenBSD.
Procedure:
Check the current hostname with the hostname command.
Change the hostname to newtricks using a text editor:
Reboot the server.
Test your change with hostname.
This section applies to Windows Server 2012 and later.
Open an elevated PowerShell. If you are in standard PowerShell, elevate your access as shown:
Check the hostname with $env:computername.
Change the hostname to NEWTRICKS. Using the -Restart parameter will also immediately restart the server. Full documentation on the Rename-Computer cmdlet is available at Microsoft.
Verify the hostname has changed with $env:computername.
A hostname is what identifies a server. Most Windows Server users name their servers with the hostname consisting of two parts: role.domain. The role part is the role installed on the server, followed by the number. For example, if dc01 is the first server that acts as a DC in this particular network, Windows makes this an FQDN by putting the Active Directory domain as the domain part. For example, if this is the third web server in this network, and the domain is example.com, the hostname would be:
Note that changing the hostname on Windows Server may conflict with some installed roles. Changing the hostname before installing roles on the server is a good idea. For recovery purposes, make a snapshot first if you decide to change the hostname on a Windows Server.
0 Comments
Be the first to comment and share your perspective with the community.