• Sales: 1-800-961-2888
  • Support: 1-800-961-4454

CentOS - Hostname Change


This article will cover a simple server hostname change in CentOS. By default your server will be kicked with the server's given name as the hostname. Some software such as CPanel require a valid Fully Qualified Domain Name or FQDN for the hostname to be used during their Licensing verification system.

Contents

Hostname Change

There are 4 steps in a hostname change, luckily all the steps are easy.

Sysconfig/Network

Open the /etc/sysconfig/network file with your favorite text editor. Modify the HOSTNAME= value to match your FQDN host name.

# sudo nano /etc/sysconfig/network
HOSTNAME=myserver.domain.com

Hosts File

Change the host that is associated to your main IPaddress for your server, this is for internal networking (found at /etc/hosts):

hosts.png

Run Hostname

The 'hostname' command will let you change the hostname on the server that the commandline remembers, but it will not actively update all programs that are running under the old hostname.

hostname.png

Restart Networking

At this point all the necessary changes that needed to be made have been made, you will want to restart networking on your server to make sure that changes will be persistent on reboot:

# /etc/init.d/network restart

 

List of Articles



© 2011-2013 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License


See license specifics and DISCLAIMER

4 Comments

Do we also have to add a CNAME record to correspond to this? I feel it is required. Do correct me if I'm wrong.

Not necessarily. The hostname doesn't have to be associated with DNS at all, and if you're running a web server with virtual hosts you probably shouldn't use a fully-qualified domain name as your hostname (which makes me think we need to update this article).

If you do want to use a domain name as your hostname, and access it from other machines, you'll usually want to set it up in DNS as either an A or CNAME record. But if you have the hostname in your /etc/hosts file associated with an IP address, the server will always associate the hostname with an address with or without a corresponding DNS record.

Rackspace cloud servers are not Virtual Servers, per se, right? As far as I know, we can configure them fully as if though they are physical machines. Would be great if you can clarify this for me...

Thanks for your Replay Jared!

Well, the Cloud Servers are virtual in the sense that they're a share of a large physical machine. When the server is created you build it with a barebones operating system image installed (like a Linux distribution or Windows Server). From there you install and configure software like you would on a regular server. You can tweak parts of the OS that communicate with the virtual hardware (like compiling a new kernel), so long as it's done in a way that it will work with the virtualization.

What sort of configuration were you looking to do?

Add new comment