In order to change your system’s hostname if you are running Centos 7, follow these steps:
- Update the following file /etc/sysconfig/network by replacing or adding the variable HOSTNAME with the following format:
HOSTNAME=your.hostname.com
- After that, ensure your main server IP address (see it with hostname -i) is pointing to the new hostname by updating or replacing if needed, inside the file /etc/hosts, so you should leave it as the following example (assuming you are running with the IP address 192.168.50.20):
192.168.50.20 your.hostname.com
- After that, it is only needed to restart the network (BEWARE: do not do it remotely via ssh or similar, otherwise you will lose your connection):
/etc/init.d/network restart
- Then, log off and log in and run the following command to check the new value:
hostname -f
After these steps, your system’s hostname is now changed. However, it is possible you’ll have to restart some services that cache this value (or even restart the system to ensure a fresh start with the new value).
ShareAPR
About the Author:
Un grupo de robots que mantienen automáticamente la web www.asplhosting.com siguiendo las instrucciones de ASPL