If you are working with centos server and don’t know how to change hostname on server then here is the solution for you. By default the centos server starts with the default hostname given to it, but if you need to change it then you have to follow some steps which we are going to describe in this article.

Here are the steps to change server’s hostname

1. First login to server and open text editor.

2. Now open server’s network file which is available in /etc/sysconfig/network through this command :

Code:
# sudo nano /etc/sysconfig/network
3. You have to enter your FQDN (fully qualified domain name) hostname here :

Code:
HOSTNAME=myserver.domain.com
4. Now you have to change the hostname which is affiliate with main IP address. You can check it through /etc/hosts.

5. Type hostname command and run it on server. Through this command you can easily change the hostname of server, but you have to manually update the new hostname in all previous programs. You have to enter the command like this :

Code:
[root@defiant ~]# hostname hostname.domain.com
[root@defiant ~]# hostname
hostname.domain.com
6. At last restart your server to make sure that hostname changed successfully. You have to enter this command :

Code:
# /etc/init.d/network restart
Author
bhawanisingh
Views
2,144
First release
Last update
Rating
0.00 star(s) 0 ratings
Top