Centos – How to reset and persist the hostname and FQDN of an WIdows Azure Centos instance

azurecentoshosthostnamelocalhost

How does one reset a hostname and domain name (FQDN) to localhost.localdomain on a Centos 6.2 Azure Instance? I've tried editing /etc/sysconfig/network, /etc/sysctl.conf, setting the hostname manually, but whatever I do, cannot get FQDN (i.e. the output of hostname -f command to localhost.localdomain.

Is there any specific way of persisting an FQDN such as this one on Centos?

Thanks

Best Answer

Hostname can be set in CentOS / Redhat / Fedora:

Editing /etc/sysconfig/network

HOSTNAME=localhost.localdomain

OR running:

hostname localhost.localdomain

You most likely will need to restart networking:

service network restart

Side Note: Verify that your /etc/hosts isn't the one playing tricks on you. Shouldn't be the case in your example but a good point to keep in mind.