How to change Centos Hostname server

Every server is started with the server’s given name as the hostname. Sometimes when the server host some  softwares, such as cPanel, that requires a valid Fully Qualified Domain Name (FQDN) for the hostname to be used during their licensing verification system. So its important to set the FQDN hostname for your server .

Change a server’s hostname

First you have to Login to your server using root username privileges and edit the file /etc/sysconfig/network by running the following command

vi /etc/sysconfig/network

then you have to change HOSTNAME= value to your FQDN hostname for example:

HOSTNAME=yourserver.mydomain.com

Now you need to change the Hostname in the file hosts ,that file used for internal network mapping IPs by running the command

vi /etc/hosts

the new values of the content file should be

127.0.0.1 localhost localhost.localdomain

93.184.216.34 yourserver.mydomain.com       yourserver

Now you can run the hostname command. This command change the hostname on the server that the command line remembers, but it does not actively update all programs that are running under the old hostname.

hostname yourserver.mydomain.com
hostname
yourserver.mydomain.com

Also you need to restart networking on your server to check that changes will persist on restart.

/etc/init.d/network restart

 

1,276 total views, 3 views today

How to change Centos Hostname server
5 (100%) 1 vote

Leave a Reply

Your email address will not be published. Required fields are marked *

*